[PATCH] D26041: [clang-tidy] Extend misc-use-after-move to support unique_ptr and shared_ptr.
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 31 07:27:57 PDT 2016
aaron.ballman added inline comments.
================
Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:467
+StringRef getName(const NamedDecl *ND) {
+ if (!ND->getIdentifier())
+ return StringRef();
----------------
This logic could be improved as:
```
if (const auto *ID = ND->getIdentifier())
return ID->getName();
return "";
```
However, I'm not certain that this function is needed at all -- it's pretty simple and is only used from `isStandardSmartPointer()`.
================
Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:482
+ StringRef Name = getName(RecordDecl);
+ if (Name != "unique_ptr" && Name != "shared_ptr")
+ return false;
----------------
Shouldn't this improvement also include `weak_ptr`?
================
Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:542
+ auto StandardSmartPointerTypeMatcher = hasType(
+ cxxRecordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr")));
+
----------------
And `::std::weak_ptr`?
Repository:
rL LLVM
https://reviews.llvm.org/D26041
More information about the cfe-commits
mailing list