Disable several more clang-tidy modernize checkers when not compiling in C++ mode. Loop conversion would make recommendations for C code, so added a test to ensure that does not happen. The pass by value, use auto and replace auto_ptr checkers would not make recommendations for C code, and are disabled for performance reasons, but do not require an extra test.
llvm-svn: 246310
diff --git a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
index b688f10..6aa57e9 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
@@ -238,8 +238,12 @@
} // namespace
void UseAutoCheck::registerMatchers(MatchFinder *Finder) {
- Finder->addMatcher(makeIteratorDeclMatcher(), this);
- Finder->addMatcher(makeDeclWithNewMatcher(), this);
+ // Only register the matchers for C++; the functionality currently does not
+ // provide any benefit to other languages, despite being benign.
+ if (getLangOpts().CPlusPlus) {
+ Finder->addMatcher(makeIteratorDeclMatcher(), this);
+ Finder->addMatcher(makeDeclWithNewMatcher(), this);
+ }
}
void UseAutoCheck::replaceIterators(const DeclStmt *D, ASTContext *Context) {