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(


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(
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to