[PATCH] D18149: Add check for unneeded copies of locals

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 21 07:10:41 PDT 2016

hokein added inline comments.

Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:87
@@ +86,3 @@
+namespace {
+void recordFixes(const VarDecl &Var, ASTContext &Context,
I prefer to move the anonymous namespace under `namespace performance {` statement.

Comment at: test/clang-tidy/performance-unnecessary-copy-initialization.cpp:232
@@ +231,3 @@
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_1 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_1' of the variable 'orig' is never modified; consider avoiding the copy [performance-unnecessary-copy-initialization]
It would be nice to add a test case with `copy_2` like:

 ExpensiveToCopyType orig;
 ExpensiveToCopyType copy_1 = orig;
 ExpensiveToCopyType copy_2 = copy_1;


More information about the cfe-commits mailing list