This revision was automatically updated to reflect the committed changes. Closed by commit rG35763baf9aa9: [clang-tidy] Simplify redundant member init check (authored by stephenkelly).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D97147/new/ https://reviews.llvm.org/D97147 Files: clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.h Index: clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.h =================================================================== --- clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.h +++ clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.h @@ -32,6 +32,9 @@ void storeOptions(ClangTidyOptions::OptionMap &Opts) override; 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; + } private: bool IgnoreBaseInCopyConstructors; Index: clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp +++ clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp @@ -26,26 +26,21 @@ } void RedundantMemberInitCheck::registerMatchers(MatchFinder *Finder) { - auto Construct = - cxxConstructExpr( - hasDeclaration(cxxConstructorDecl(hasParent( - cxxRecordDecl(unless(isTriviallyDefaultConstructible())))))) - .bind("construct"); - Finder->addMatcher( - traverse( - TK_AsIs, - cxxConstructorDecl( - unless(isDelegatingConstructor()), - ofClass(unless( - anyOf(isUnion(), ast_matchers::isTemplateInstantiation()))), - forEachConstructorInitializer( - cxxCtorInitializer( - isWritten(), withInitializer(ignoringImplicit(Construct)), - unless(forField(hasType(isConstQualified()))), - unless(forField(hasParent(recordDecl(isUnion()))))) - .bind("init"))) - .bind("constructor")), + cxxConstructorDecl( + unless(isDelegatingConstructor()), ofClass(unless(isUnion())), + forEachConstructorInitializer( + cxxCtorInitializer( + withInitializer( + cxxConstructExpr( + hasDeclaration( + cxxConstructorDecl(ofClass(cxxRecordDecl( + unless(isTriviallyDefaultConstructible())))))) + .bind("construct")), + unless(forField(hasType(isConstQualified()))), + unless(forField(hasParent(recordDecl(isUnion()))))) + .bind("init"))) + .bind("constructor"), this); }
Index: clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.h =================================================================== --- clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.h +++ clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.h @@ -32,6 +32,9 @@ void storeOptions(ClangTidyOptions::OptionMap &Opts) override; 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; + } private: bool IgnoreBaseInCopyConstructors; Index: clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp +++ clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp @@ -26,26 +26,21 @@ } void RedundantMemberInitCheck::registerMatchers(MatchFinder *Finder) { - auto Construct = - cxxConstructExpr( - hasDeclaration(cxxConstructorDecl(hasParent( - cxxRecordDecl(unless(isTriviallyDefaultConstructible())))))) - .bind("construct"); - Finder->addMatcher( - traverse( - TK_AsIs, - cxxConstructorDecl( - unless(isDelegatingConstructor()), - ofClass(unless( - anyOf(isUnion(), ast_matchers::isTemplateInstantiation()))), - forEachConstructorInitializer( - cxxCtorInitializer( - isWritten(), withInitializer(ignoringImplicit(Construct)), - unless(forField(hasType(isConstQualified()))), - unless(forField(hasParent(recordDecl(isUnion()))))) - .bind("init"))) - .bind("constructor")), + cxxConstructorDecl( + unless(isDelegatingConstructor()), ofClass(unless(isUnion())), + forEachConstructorInitializer( + cxxCtorInitializer( + withInitializer( + cxxConstructExpr( + hasDeclaration( + cxxConstructorDecl(ofClass(cxxRecordDecl( + unless(isTriviallyDefaultConstructible())))))) + .bind("construct")), + unless(forField(hasType(isConstQualified()))), + unless(forField(hasParent(recordDecl(isUnion()))))) + .bind("init"))) + .bind("constructor"), this); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits