[PATCH] D91893: [clang-tidy] performance-unnecessary-copy-initialization: Prevent false positives when dependent variable is modified.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 10 06:59:45 PST 2020


aaron.ballman added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp:92
+  // to reference it and avoid the copy.
+  if (!isa<ReferenceType>(T) && !isa<PointerType>(T))
+    return true;
----------------



================
Comment at: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp:492
+  Orig.nonConstMethod();
+}
----------------
Making sure I understand properly, if you were calling `Orig.constMethod()` then the diagnostic should be triggered, correct? Assuming so, having those test cases would be useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91893



More information about the cfe-commits mailing list