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

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 17 10:29:12 PDT 2016


alexfh requested changes to this revision.
This revision now requires changes to proceed.

================
Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:29
@@ +28,3 @@
+/// Provides information about the evaluation order of (sub-)expressions within
+/// a CFGBlock.
+///
----------------
Please enclose inline code snippets in double backquotes (doxygen supports markdown to a certain degree).

================
Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:46
@@ +45,3 @@
+///   API),
+/// - Removing the dependency of SequenceChecker on Sema, and
+/// - (Probably) modifying SequenceChecker to make it suitable to be used in
----------------
Does it look feasible?

================
Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:135
@@ +134,3 @@
+class UseAfterMoveFinder {
+public:
+  UseAfterMoveFinder(ASTContext *TheContext);
----------------
It's definitely subjective, but I don't think it's scary. And the size of the file doesn't seem to be an issue yet. IMO, a reason to move this to a header would appear once this class is needed elsewhere. 

================
Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:216
@@ +215,3 @@
+    : Context(TheContext) {
+  for (CFG::synthetic_stmt_iterator I = TheCFG->synthetic_stmt_begin(),
+                                    E = TheCFG->synthetic_stmt_end();
----------------
nit: How about `for (const auto &SyntheticStmt : llvm::make_range(TheCFG->synthetic_stmt_begin(), TheCFG->synthetic_stmt_end())) ...`?

Alternatively, we could add `CFG::synthetic_stmt()` method that would return an `iterator_range<...>`.

================
Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:435
@@ +434,3 @@
+  if (Reinits.empty()) {
+    for (CFGBlock::const_succ_iterator I = Block->succ_begin(),
+                                       E = Block->succ_end();
----------------
Use `llvm::make_range` and a range-for loop?

================
Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:465
@@ +464,3 @@
+  std::sort(Uses->begin(), Uses->end(),
+            [](const DeclRefExpr *d1, const DeclRefExpr *d2) {
+              return d1->getExprLoc() < d2->getExprLoc();
----------------
nit: Variable names should start with a capital letter.


https://reviews.llvm.org/D23353





More information about the cfe-commits mailing list