Index: clang-tools-extra/trunk/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -207,7 +207,7 @@
}
bool isStandardSmartPointer(const ValueDecl *VD) {
- const Type *TheType = VD->getType().getTypePtrOrNull();
+ const Type *TheType = VD->getType().getNonReferenceType().getTypePtrOrNull();
if (!TheType)
return false;
Index: clang-tools-extra/trunk/test/clang-tidy/bugprone-use-after-move.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-use-after-move.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-use-after-move.cpp
@@ -244,6 +244,19 @@
std::move(ptr);
ptr.get();
}
+ // Make sure we treat references to smart pointers correctly.
+ {
+ std::unique_ptr ptr;
+ std::unique_ptr& ref_to_ptr = ptr;
+ std::move(ref_to_ptr);
+ ref_to_ptr.get();
+ }
+ {
+ std::unique_ptr ptr;
+ std::unique_ptr&& 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.
{