Add NamingStyle option to modernize-loop-convert.
Summary: Add an option to specify wich style must be followed when choosing the new index name.
Reviewers: alexfh
Subscribers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D13052
llvm-svn: 248517
diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
index a476f6c..b233196 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -410,11 +410,21 @@
Options.get("MinConfidence", "reasonable"))
.Case("safe", Confidence::CL_Safe)
.Case("risky", Confidence::CL_Risky)
- .Default(Confidence::CL_Reasonable)) {}
+ .Default(Confidence::CL_Reasonable)),
+ NamingStyle(StringSwitch<VariableNamer::NamingStyle>(
+ Options.get("NamingStyle", "CamelCase"))
+ .Case("camelBack", VariableNamer::NS_CamelBack)
+ .Case("lower_case", VariableNamer::NS_LowerCase)
+ .Case("UPPER_CASE", VariableNamer::NS_UpperCase)
+ .Default(VariableNamer::NS_CamelCase)) {}
void LoopConvertCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
SmallVector<std::string, 3> Confs{"risky", "reasonable", "safe"};
Options.store(Opts, "MinConfidence", Confs[static_cast<int>(MinConfidence)]);
+
+ SmallVector<std::string, 4> Styles{"camelBack", "CamelCase", "lower_case",
+ "UPPER_CASE"};
+ Options.store(Opts, "NamingStyle", Styles[static_cast<int>(NamingStyle)]);
}
void LoopConvertCheck::registerMatchers(MatchFinder *Finder) {
@@ -466,7 +476,7 @@
} else {
VariableNamer Namer(&TUInfo->getGeneratedDecls(),
&TUInfo->getParentFinder().getStmtToParentStmtMap(),
- Loop, IndexVar, MaybeContainer, Context);
+ Loop, IndexVar, MaybeContainer, Context, NamingStyle);
VarName = Namer.createIndexName();
// First, replace all usages of the array subscript expression with our new
// variable.