hokein updated this revision to Diff 75595. hokein added a comment. Don't mess up with other patches.
https://reviews.llvm.org/D25911 Files: clang-tidy/performance/UnnecessaryCopyInitialization.cpp test/clang-tidy/performance-unnecessary-copy-initialization.cpp Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp =================================================================== --- test/clang-tidy/performance-unnecessary-copy-initialization.cpp +++ 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-tidy/performance/UnnecessaryCopyInitialization.cpp =================================================================== --- clang-tidy/performance/UnnecessaryCopyInitialization.cpp +++ clang-tidy/performance/UnnecessaryCopyInitialization.cpp @@ -57,6 +57,7 @@ declStmt( has(varDecl(hasLocalStorage(), hasType(matchers::isExpensiveToCopy()), + unless(isImplicit()), hasInitializer( cxxConstructExpr( hasDeclaration(cxxConstructorDecl(
Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp =================================================================== --- test/clang-tidy/performance-unnecessary-copy-initialization.cpp +++ 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-tidy/performance/UnnecessaryCopyInitialization.cpp =================================================================== --- clang-tidy/performance/UnnecessaryCopyInitialization.cpp +++ clang-tidy/performance/UnnecessaryCopyInitialization.cpp @@ -57,6 +57,7 @@ declStmt( has(varDecl(hasLocalStorage(), hasType(matchers::isExpensiveToCopy()), + unless(isImplicit()), hasInitializer( cxxConstructExpr( hasDeclaration(cxxConstructorDecl(
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits