[PATCH] D23353: [clang-tidy] Add check 'misc-use-after-move'

Piotr Padlewski via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 17 09:50:58 PDT 2016


Prazek added a comment.

In https://reviews.llvm.org/D23353#516314, @mboehme wrote:

> In https://reviews.llvm.org/D23353#511362, @Prazek wrote:
>
> > I will review it later, but my first thoughts:
> >
> > 1. I think we should make some other group, because misc seems to be overloaded. I discussed it with Alex months ago - something like bugprone would be good.
>
>
> Agree that "misc" seems pretty overcrowded. I'll defer to those who have been working on clang-tidy longer than me to make this call.
>
> > 2. Also it would be good to make link in cppcoreguidelines.
>
>
> How exactly would I create such a "link"? Are you just thinking of a link in the documentation, or is there a way to have one clang-tidy check activate another (and is this what you're thinking of)?


I am not sure if there is any other mechanism than just links in documentation. 
In the perfect word it would be nice to invoke this check using cppcoreguidelines-use-after-move also with some special options like Pedantic=1 (That would warn about any use after move, even after reinitialization - this is what cppcoreguidelines says)


================
Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:134
@@ +133,3 @@
+/// various internal helper functions).
+class UseAfterMoveFinder {
+public:
----------------
What do you think about moving this, and maybe other things to some different header file to make it not so scary?

================
Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:649-652
@@ +648,6 @@
+    FunctionBody = ContainingFunc->getBody();
+  }
+
+  if (!FunctionBody)
+    return;
+
----------------
you can replace it with 
  else
    return;

================
Comment at: test/clang-tidy/misc-use-after-move.cpp:504-505
@@ +503,4 @@
+    std::move(a);
+    a = A();
+    a.foo();
+  }
----------------
I would like to mark it as use after move with some pedantic flag


https://reviews.llvm.org/D23353





More information about the cfe-commits mailing list