This revision was automatically updated to reflect the committed changes. Closed by commit rGfefe20b99313: [clang-tidy] performance-unnecessary-copy-initialization: Correctly match theā¦ (authored by flx).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114212/new/ https://reviews.llvm.org/D114212 Files: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization-excluded-container-types.cpp Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization-excluded-container-types.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization-excluded-container-types.cpp +++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization-excluded-container-types.cpp @@ -58,3 +58,13 @@ const auto E = C.secretlyMutates(); E.constMethod(); } + +void excludedConstIncorrectTypeAsPointer(ConstInCorrectType *C) { + const auto E = C->secretlyMutates(); + E.constMethod(); +} + +void excludedConstIncorrectTypeAsReference(const ConstInCorrectType &C) { + const auto E = C.secretlyMutates(); + E.constMethod(); +} Index: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp =================================================================== --- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp +++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp @@ -87,11 +87,9 @@ callee(cxxMethodDecl( returns(hasCanonicalType(matchers::isReferenceToConst()))) .bind(MethodDeclId)), - on(declRefExpr(to( - varDecl( - unless(hasType(qualType(hasCanonicalType(hasDeclaration(namedDecl( - matchers::matchesAnyListedName(ExcludedContainerTypes)))))))) - .bind(ObjectArgId))))); + on(declRefExpr(to(varDecl().bind(ObjectArgId)))), + thisPointerType(namedDecl( + unless(matchers::matchesAnyListedName(ExcludedContainerTypes))))); } AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningFunctionCall) {
Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization-excluded-container-types.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization-excluded-container-types.cpp +++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization-excluded-container-types.cpp @@ -58,3 +58,13 @@ const auto E = C.secretlyMutates(); E.constMethod(); } + +void excludedConstIncorrectTypeAsPointer(ConstInCorrectType *C) { + const auto E = C->secretlyMutates(); + E.constMethod(); +} + +void excludedConstIncorrectTypeAsReference(const ConstInCorrectType &C) { + const auto E = C.secretlyMutates(); + E.constMethod(); +} Index: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp =================================================================== --- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp +++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp @@ -87,11 +87,9 @@ callee(cxxMethodDecl( returns(hasCanonicalType(matchers::isReferenceToConst()))) .bind(MethodDeclId)), - on(declRefExpr(to( - varDecl( - unless(hasType(qualType(hasCanonicalType(hasDeclaration(namedDecl( - matchers::matchesAnyListedName(ExcludedContainerTypes)))))))) - .bind(ObjectArgId))))); + on(declRefExpr(to(varDecl().bind(ObjectArgId)))), + thisPointerType(namedDecl( + unless(matchers::matchesAnyListedName(ExcludedContainerTypes))))); } AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningFunctionCall) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits