[PATCH] D17488: Extend UnnecessaryCopyInitialization check to trigger on non-const copies that can be safely converted to const references.

Felix Berger via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 27 20:05:05 PST 2016


flx added inline comments.

================
Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.h:19
@@ -18,3 +18,3 @@
 
-// A check that detects const local variable declarations that are copy
+// A check that detects local variable declarations that are copy
 // initialized with the const reference of a function call or the const
----------------
alexfh wrote:
> Maybe just "The check detects local variable declarations ...."?
> 
> Also, should the .rst file be updated as well?
.rst file didn't exist. Added one now.

================
Comment at: clang-tidy/utils/FixItHintUtils.h:21
@@ +20,3 @@
+/// \brief Creates fix to make VarDecl a reference by adding '&'.
+FixItHint createReferenceFix(const VarDecl &Var, ASTContext &Context);
+
----------------
alexfh wrote:
> Since this is now a library, we should make names clear and unambiguous. I'd pull a part of the name's meaning to the namespace and expand the name with the needed details. Maybe something like this:
> 
>   namespace clang {
>   namespace tidy {
>   namespace utils {
>   namespace create_fixit {
>   
>   FixItHint changeVarDeclToReference(...);
>   FixItHint changeVarDeclToConst(...);
Done, but put an extra underscore in the create_fix_it namespace to be consistent with the camelcase of the class.


http://reviews.llvm.org/D17488





More information about the cfe-commits mailing list