[PATCH] D19865: [clang-tidy] - PerformanceUnnecesaryCopyInitialization - only trigger for decl stmts with single VarDecl.
Felix Berger via cfe-commits
cfe-commits at lists.llvm.org
Tue May 3 06:36:12 PDT 2016
flx created this revision.
flx added a reviewer: alexfh.
flx added a subscriber: cfe-commits.
flx set the repository for this revision to rL LLVM.
This fixes bug: https://llvm.org/bugs/show_bug.cgi?id=27325
Repository:
rL LLVM
http://reviews.llvm.org/D19865
Files:
clang-tidy/performance/UnnecessaryCopyInitialization.cpp
test/clang-tidy/performance-unnecessary-copy-initialization.cpp
Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===================================================================
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -338,3 +338,8 @@
WeirdCopyCtorType neg_weird_1(orig, false);
WeirdCopyCtorType neg_weird_2(orig, true);
}
+
+void NegativeMultiDeclStmt() {
+ ExpensiveToCopyType orig;
+ ExpensiveToCopyType copy = orig, copy2;
+}
Index: clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===================================================================
--- clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -56,16 +56,15 @@
auto localVarCopiedFrom = [](const internal::Matcher<Expr> &CopyCtorArg) {
return compoundStmt(
- forEachDescendant(
+ forEachDescendant(declStmt(hasSingleDecl(
varDecl(hasLocalStorage(),
hasType(matchers::isExpensiveToCopy()),
hasInitializer(cxxConstructExpr(
hasDeclaration(cxxConstructorDecl(
isCopyConstructor())),
hasArgument(0, CopyCtorArg))
.bind("ctorCall")))
- .bind("newVarDecl")))
- .bind("blockStmt");
+ .bind("newVarDecl"))))).bind("blockStmt");
};
Finder->addMatcher(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19865.55982.patch
Type: text/x-patch
Size: 1621 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160503/09a5df3e/attachment-0001.bin>
More information about the cfe-commits
mailing list