[clang-tidy] Simplify const params check
authorStephen Kelly <steveire@gmail.com>
Tue, 29 Dec 2020 13:44:05 +0000 (13:44 +0000)
committerStephen Kelly <steveire@gmail.com>
Wed, 17 Feb 2021 10:20:12 +0000 (10:20 +0000)
Differential Revision: https://reviews.llvm.org/D96141

clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h

index aed01ab..d35cc07 100644 (file)
@@ -33,14 +33,6 @@ void AvoidConstParamsInDecls::registerMatchers(MatchFinder *Finder) {
       parmVarDecl(hasType(qualType(isConstQualified()))).bind("param");
   Finder->addMatcher(
       functionDecl(unless(isDefinition()),
-                   // Lambdas are always their own definition, but they
-                   // generate a non-definition FunctionDecl too. Ignore those.
-                   // Class template instantiations have a non-definition
-                   // CXXMethodDecl for methods that aren't used in this
-                   // translation unit. Ignore those, as the template will have
-                   // already been checked.
-                   unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf(
-                       isLambda(), ast_matchers::isTemplateInstantiation()))))),
                    has(typeLoc(forEach(ConstParamDecl))))
           .bind("func"),
       this);
index 08aac94..d366949 100644 (file)
@@ -24,6 +24,9 @@ public:
 
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  llvm::Optional<TraversalKind> getCheckTraversalKind() const override {
+    return TK_IgnoreUnlessSpelledInSource;
+  }
 };
 
 } // namespace readability