diff options
author | Haojian Wu <hokein@google.com> | 2016-11-08 00:45:34 +0000 |
---|---|---|
committer | Haojian Wu <hokein@google.com> | 2016-11-08 00:45:34 +0000 |
commit | 06e39a3aed315950d58617f6f9c1f208c356fd02 (patch) | |
tree | 27df1be74748b594df1581faa905d2901d3d2593 /clang-tools-extra/test/clang-tidy/performance-unnecessary-copy-initialization.cpp | |
parent | 9ac0eba6724806d65d2b28b6e96cceded33b4e35 (diff) | |
download | bcm5719-llvm-06e39a3aed315950d58617f6f9c1f208c356fd02.tar.gz bcm5719-llvm-06e39a3aed315950d58617f6f9c1f208c356fd02.zip |
[clang-tidy] Don't warn implicit variables in peformance-unnecessary-copy-initialization.
Summary:
This will prevent the check warning the variables which have been
implicitly added by compiler, like the following case (in for-range loop):
the variable '__end' is copy-constructed from a const reference...
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25911
llvm-svn: 286186
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/performance-unnecessary-copy-initialization.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/performance-unnecessary-copy-initialization.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/performance-unnecessary-copy-initialization.cpp b/clang-tools-extra/test/clang-tidy/performance-unnecessary-copy-initialization.cpp index b8c22ee2739..50dcfd8f8bf 100644 --- a/clang-tools-extra/test/clang-tidy/performance-unnecessary-copy-initialization.cpp +++ b/clang-tools-extra/test/clang-tidy/performance-unnecessary-copy-initialization.cpp @@ -368,3 +368,22 @@ void WarningOnlyMultiDeclStmt() { // 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()) { + } +} |