summaryrefslogtreecommitdiff
path: root/clang-tools-extra/test
diff options
context:
space:
mode:
authorMartin Bohme <mboehme@google.com>2019-01-16 07:53:25 +0000
committerMartin Bohme <mboehme@google.com>2019-01-16 07:53:25 +0000
commit9259c236ce36ac76b8dcc8209f6490c748ec60a5 (patch)
tree635ae706a890abc4c24b33583298da3b4c9d65e8 /clang-tools-extra/test
parent6177eda8577856233853ed2c036617e320c48126 (diff)
[clang-tidy] Treat references to smart pointers correctly in use-after-move.
Summary: Previously, we weren't recognizing these as smart pointers and thus weren't allowing non-dereference accesses as we should -- see new test cases which fail without the fix. Reviewers: alexfh, hokein, aaron.ballman, JonasToth Reviewed By: JonasToth Subscribers: xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D56585
Diffstat (limited to 'clang-tools-extra/test')
-rw-r--r--clang-tools-extra/test/clang-tidy/bugprone-use-after-move.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/bugprone-use-after-move.cpp b/clang-tools-extra/test/clang-tidy/bugprone-use-after-move.cpp
index 59dcb90cb49..dd37aec67b5 100644
--- a/clang-tools-extra/test/clang-tidy/bugprone-use-after-move.cpp
+++ b/clang-tools-extra/test/clang-tidy/bugprone-use-after-move.cpp
@@ -244,6 +244,19 @@ void standardSmartPtr() {
std::move(ptr);
ptr.get();
}
+ // Make sure we treat references to smart pointers correctly.
+ {
+ std::unique_ptr<A> ptr;
+ std::unique_ptr<A>& ref_to_ptr = ptr;
+ std::move(ref_to_ptr);
+ ref_to_ptr.get();
+ }
+ {
+ std::unique_ptr<A> ptr;
+ std::unique_ptr<A>&& rvalue_ref_to_ptr = std::move(ptr);
+ std::move(rvalue_ref_to_ptr);
+ rvalue_ref_to_ptr.get();
+ }
// We don't give any special treatment to types that are called "unique_ptr"
// or "shared_ptr" but are not in the "::std" namespace.
{