[PATCH] D42624: [clang-tidy] Add a utility Matcher to match the next statement within a statement sequence

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 29 05:28:22 PST 2018


aaron.ballman added inline comments.


================
Comment at: clang-tidy/utils/Matchers.h:16
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Analysis/CFG.h"
 
----------------
This will require linking in the clangAnalysis library as well; are we sure we want to take on this dependency here for all matchers?


================
Comment at: clang-tidy/utils/Matchers.h:58-60
+  // We get the first parent, making sure that we're not in a case statement
+  // not in a compound statement directly inside a switch, because this causes
+  // the buildCFG call to crash.
----------------
Why does it cause the crash? Should that crash not be fixed instead of applying this workaround?


================
Comment at: clang-tidy/utils/Matchers.h:70
+
+  // We build a Control Flow Graph (CFG) from the parent statement.
+  std::unique_ptr<CFG> StatementCFG =
----------------
No need for the parenthetical. It's generally understood what a CFG is, so you can just use the acronym.


================
Comment at: clang-tidy/utils/Matchers.h:74-75
+                  CFG::BuildOptions());
+
+  if (!StatementCFG) {
+    return false;
----------------
Elide braces (here and elsewhere).


================
Comment at: clang-tidy/utils/Matchers.h:81
+  // all the possible branches of the code and therefore cover all statements.
+  for (auto& Block : *StatementCFG) {
+    if (!Block) {
----------------
Formatting (here and elsewhere): you should run the patch through clang-format.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42624





More information about the cfe-commits mailing list