[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

Kefu Chai via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 7 19:40:17 PDT 2024


================
@@ -69,6 +73,30 @@ class UseAfterMoveFinder {
   llvm::SmallPtrSet<const CFGBlock *, 8> Visited;
 };
 
+/// Returns whether the `Before` block can reach the `After` block.
+bool reaches(const CFGBlock *Before, const CFGBlock *After) {
+  llvm::SmallVector<const CFGBlock *> Stack;
+  llvm::SmallPtrSet<const CFGBlock *, 1> Visited;
+
+  Stack.push_back(Before);
+  while (!Stack.empty()) {
+    const CFGBlock *Current = Stack.back();
+    Stack.pop_back();
+
+    if (Current == After)
+      return true;
+
+    Visited.insert(Current);
+
+    for (const CFGBlock *Succ : Current->succs()) {
+      if (Succ && !Visited.contains(Succ))
+        Stack.push_back(Succ);
+    }
+  }
+
+  return false;
+}
+
----------------
tchaikov wrote:

yeah, it's equivalent to `reaches()`. will use it instead in the next revision.

https://github.com/llvm/llvm-project/pull/93623


More information about the cfe-commits mailing list