This revision was automatically updated to reflect the committed changes. Closed by commit rG187e050b33bb: [clang-tidy] performance-unnecessary-copy-initialization: Disable structured… (authored by flx).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D105727/new/ https://reviews.llvm.org/D105727 Files: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp +++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t +// RUN: %check_clang_tidy -std=c++17 %s performance-unnecessary-copy-initialization %t template <typename T> struct Iterator { @@ -637,3 +637,18 @@ } }; } + +void negativeStructuredBinding() { + // Structured bindings are not yet supported but can trigger false positives + // since the DecompositionDecl itself is unused and the check doesn't traverse + // VarDecls of the BindingDecls. + struct Pair { + ExpensiveToCopyType first; + ExpensiveToCopyType second; + }; + + Pair P; + const auto [C, D] = P; + C.constMethod(); + D.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 @@ -147,6 +147,7 @@ return compoundStmt( forEachDescendant( declStmt( + unless(has(decompositionDecl())), has(varDecl(hasLocalStorage(), hasType(qualType( hasCanonicalType(allOf(
Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp +++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t +// RUN: %check_clang_tidy -std=c++17 %s performance-unnecessary-copy-initialization %t template <typename T> struct Iterator { @@ -637,3 +637,18 @@ } }; } + +void negativeStructuredBinding() { + // Structured bindings are not yet supported but can trigger false positives + // since the DecompositionDecl itself is unused and the check doesn't traverse + // VarDecls of the BindingDecls. + struct Pair { + ExpensiveToCopyType first; + ExpensiveToCopyType second; + }; + + Pair P; + const auto [C, D] = P; + C.constMethod(); + D.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 @@ -147,6 +147,7 @@ return compoundStmt( forEachDescendant( declStmt( + unless(has(decompositionDecl())), has(varDecl(hasLocalStorage(), hasType(qualType( hasCanonicalType(allOf(
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits