[PATCH] D102175: [clang-tidy] performance-unnecessary-copy-initialization: Remove the complete statement when the copied variable is unused.

Felix Berger via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 9 12:51:34 PDT 2021


flx added a comment.

Thank you for the review, Yitzhak!



================
Comment at: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp:541
   Orig.constMethod();
+  UnnecessaryCopy.constMethod();
 }
----------------
ymandel wrote:
> If this line weren't here, then we'd delete line 537, in which case `Ref` itself becomes unused and so line 536 should be deleted as well. Do you handle this case?
Good catch. This case is not handled. It would require recursively checking whether the deleted statement was the only reference to another reference which is hard and requires subtracting that decl ref from all these calculations.  

 I would like to to see this being a common enough issue before addressing it. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102175/new/

https://reviews.llvm.org/D102175



More information about the cfe-commits mailing list