[PATCH] D20010: [clang-tidy] UnnecessaryCopyInitialization - Extend to trigger on non-const "this" object argument if it is not modified

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Wed May 11 10:43:01 PDT 2016


alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

How many more (in relative numbers) results does this check generate now?


================
Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:45
@@ -44,7 +44,3 @@
 
-  // Match method call expressions where the this argument is a const
-  // type or const reference. This returned const reference is highly likely to
-  // outlive the local const reference of the variable being declared.
-  // The assumption is that the const reference being returned either points
-  // to a global static variable or to a member of the called object.
-  auto ConstRefReturningMethodCallOfConstParam = cxxMemberCallExpr(
+  // Match method call expressions where the 'this' argument is only used as
+  // const, this will be checked in check() part. This returned const reference
----------------
Please enclose inline code snippets in backquotes (`this`, `check()`, etc.).

================
Comment at: test/clang-tidy/performance-unnecessary-copy-initialization.cpp:133
@@ -132,3 +132,3 @@
   auto AutoCopyConstructed(ExpensiveTypeReference());
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable
   // CHECK-FIXES: const auto& AutoCopyConstructed(ExpensiveTypeReference());
----------------
Please include dynamic parts of the message to the CHECK lines (in this case - the variable name).


Repository:
  rL LLVM

http://reviews.llvm.org/D20010





More information about the cfe-commits mailing list