[PATCH] D26041: [clang-tidy] Extend misc-use-after-move to support unique_ptr and shared_ptr.

Martin Böhme via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 1 17:05:13 PDT 2016


mboehme marked 4 inline comments as done.
mboehme added a comment.

Please take another look.



================
Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:467
+StringRef getName(const NamedDecl *ND) {
+  if (!ND->getIdentifier())
+    return StringRef();
----------------
aaron.ballman wrote:
> 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()`.
> However, I'm not certain that this function is needed at all -- it's pretty simple and is only used from isStandardSmartPointer().

Good point -- I've inlined it there.


================
Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:482
+  StringRef Name = getName(RecordDecl);
+  if (Name != "unique_ptr" && Name != "shared_ptr")
+    return false;
----------------
aaron.ballman wrote:
> Shouldn't this improvement also include `weak_ptr`?
Good point -- done.


https://reviews.llvm.org/D26041





More information about the cfe-commits mailing list