[clang] [llvm] [clang] Add hasAdjSubstatements matcher (PR #169965)

Denis Mikhailov via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 9 04:57:28 PST 2025


================
@@ -2283,6 +2283,37 @@ using HasOpNameMatcher =
 
 HasOpNameMatcher hasAnyOperatorNameFunc(ArrayRef<const StringRef *> NameRefs);
 
+/// Matches nodes of type T (CompoundStmt or StmtExpr) that contain a sequence
+/// of consecutive substatements matching the provided matchers in order.
+///
+/// See \c hasAdjSubstatements() in ASTMatchers.h for details.
+template <typename T, typename ArgT = std::vector<Matcher<Stmt>>>
+class HasAdjSubstatementsMatcher : public MatcherInterface<T> {
+  static_assert(std::is_same<T, CompoundStmt>::value ||
+                    std::is_same<T, StmtExpr>::value,
+                "Matcher only supports `CompoundStmt` and `StmtExpr`");
----------------
denzor200 wrote:

This matcher is already polymorphic, by that logic. I built it using `hasAnyOperatorName` :)
<img width="603" height="119" alt="image" src="https://github.com/user-attachments/assets/57e34a7d-51fe-494e-91d8-b99f11fef2dd" />


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


More information about the llvm-commits mailing list