[PATCH] D25911: [clang-tidy] Don't warn implicit variables in peformance-unnecessary-copy-initialization.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 7 16:55:18 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286186: [clang-tidy] Don't warn implicit variables in peformance-unnecessary-copy… (authored by hokein).
Changed prior to commit:
https://reviews.llvm.org/D25911?vs=75595&id=77122#toc
Repository:
rL LLVM
https://reviews.llvm.org/D25911
Files:
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp
Index: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -368,3 +368,22 @@
// CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy' of the variable 'orig' is never modified; consider avoiding the copy [performance-unnecessary-copy-initialization]
// CHECK-FIXES: ExpensiveToCopyType copy = orig, copy2;
}
+
+class Element {};
+class Container {
+public:
+ class Iterator {
+ public:
+ void operator++();
+ Element operator*();
+ bool operator!=(const Iterator &);
+ WeirdCopyCtorType c;
+ };
+ const Iterator &begin() const;
+ const Iterator &end() const;
+};
+
+void implicitVarFalsePositive() {
+ for (const Element &E : Container()) {
+ }
+}
Index: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -57,6 +57,7 @@
declStmt(
has(varDecl(hasLocalStorage(),
hasType(matchers::isExpensiveToCopy()),
+ unless(isImplicit()),
hasInitializer(
cxxConstructExpr(
hasDeclaration(cxxConstructorDecl(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25911.77122.patch
Type: text/x-patch
Size: 1721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161108/b45c04c7/attachment.bin>
More information about the cfe-commits
mailing list