[clang] [clang][ASTMatchers] format ASTMatchers.h (PR #203766)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 14 11:30:15 PDT 2026
https://github.com/vbvictor updated https://github.com/llvm/llvm-project/pull/203766
>From 27fbd42aa4ed52c299b01d37e23c508358a5bd87 Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Sun, 14 Jun 2026 21:30:02 +0300
Subject: [PATCH] ~
---
clang/include/clang/ASTMatchers/ASTMatchers.h | 417 +++++++-----------
1 file changed, 165 insertions(+), 252 deletions(-)
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index bc0f35898a2c9..99ebf2f44ab15 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -115,8 +115,7 @@ class BoundNodes {
///
/// Returns NULL if there was no node bound to \c ID or if there is a node but
/// it cannot be converted to the specified type.
- template <typename T>
- const T *getNodeAs(StringRef ID) const {
+ template <typename T> const T *getNodeAs(StringRef ID) const {
return MyBoundNodes.getNodeAs<T>(ID);
}
@@ -126,9 +125,7 @@ class BoundNodes {
using IDToNodeMap = internal::BoundNodesMap::IDToNodeMap;
/// Retrieve mapping from binding identifiers to bound nodes.
- const IDToNodeMap &getMap() const {
- return MyBoundNodes.getMap();
- }
+ const IDToNodeMap &getMap() const { return MyBoundNodes.getMap(); }
private:
friend class internal::BoundNodesTreeBuilder;
@@ -334,13 +331,15 @@ AST_POLYMORPHIC_MATCHER_P(isExpandedFromMacro,
std::string, MacroName) {
// Verifies that the statement' beginning and ending are both expanded from
// the same instance of the given macro.
- auto& Context = Finder->getASTContext();
+ auto &Context = Finder->getASTContext();
std::optional<SourceLocation> B =
internal::getExpansionLocOfMacro(MacroName, Node.getBeginLoc(), Context);
- if (!B) return false;
+ if (!B)
+ return false;
std::optional<SourceLocation> E =
internal::getExpansionLocOfMacro(MacroName, Node.getEndLoc(), Context);
- if (!E) return false;
+ if (!E)
+ return false;
return *B == *E;
}
@@ -706,9 +705,7 @@ AST_POLYMORPHIC_MATCHER(isPrivate,
/// \endcode
/// fieldDecl(isBitField())
/// matches 'int a;' but not 'int b;'.
-AST_MATCHER(FieldDecl, isBitField) {
- return Node.isBitField();
-}
+AST_MATCHER(FieldDecl, isBitField) { return Node.isBitField(); }
/// Matches non-static data members that are bit-fields of the specified
/// bit width.
@@ -751,9 +748,7 @@ AST_MATCHER_P(FieldDecl, hasInClassInitializer, internal::Matcher<Expr>,
/// Determines whether the function is "main", which is the entry point
/// into an executable program.
-AST_MATCHER(FunctionDecl, isMain) {
- return Node.isMain();
-}
+AST_MATCHER(FunctionDecl, isMain) { return Node.isMain(); }
/// Matches the specialized template of a specialization declaration.
///
@@ -767,9 +762,8 @@ AST_MATCHER(FunctionDecl, isMain) {
/// declaration of 'A' at #1.
AST_MATCHER_P(ClassTemplateSpecializationDecl, hasSpecializedTemplate,
internal::Matcher<ClassTemplateDecl>, InnerMatcher) {
- const ClassTemplateDecl* Decl = Node.getSpecializedTemplate();
- return (Decl != nullptr &&
- InnerMatcher.matches(*Decl, Finder, Builder));
+ const ClassTemplateDecl *Decl = Node.getSpecializedTemplate();
+ return (Decl != nullptr && InnerMatcher.matches(*Decl, Finder, Builder));
}
/// Matches an entity that has been implicitly added by the compiler (e.g.
@@ -927,8 +921,7 @@ traverse(TraversalKind TK, const internal::MapAnyOfHelper<T...> &InnerMatcher) {
/// varDecl(hasInitializer(cxxConstructExpr()))
/// \endcode
/// only match the declarations for b and c.
-AST_MATCHER_P(Expr, ignoringImplicit, internal::Matcher<Expr>,
- InnerMatcher) {
+AST_MATCHER_P(Expr, ignoringImplicit, internal::Matcher<Expr>, InnerMatcher) {
return InnerMatcher.matches(*Node.IgnoreImplicit(), Finder, Builder);
}
@@ -957,8 +950,7 @@ AST_MATCHER_P(Expr, ignoringImplicit, internal::Matcher<Expr>,
/// varDecl(hasInitializer(declRefExpr()))
/// \endcode
/// only match the declarations for a.
-AST_MATCHER_P(Expr, ignoringImpCasts,
- internal::Matcher<Expr>, InnerMatcher) {
+AST_MATCHER_P(Expr, ignoringImpCasts, internal::Matcher<Expr>, InnerMatcher) {
return InnerMatcher.matches(*Node.IgnoreImpCasts(), Finder, Builder);
}
@@ -1004,8 +996,8 @@ AST_MATCHER_P(Expr, ignoringParenCasts, internal::Matcher<Expr>, InnerMatcher) {
/// varDecl(hasInitializer(integerLiteral()))
/// varDecl(hasInitializer(declRefExpr()))
/// would only match the declaration for a.
-AST_MATCHER_P(Expr, ignoringParenImpCasts,
- internal::Matcher<Expr>, InnerMatcher) {
+AST_MATCHER_P(Expr, ignoringParenImpCasts, internal::Matcher<Expr>,
+ InnerMatcher) {
return InnerMatcher.matches(*Node.IgnoreParenImpCasts(), Finder, Builder);
}
@@ -1151,8 +1143,8 @@ AST_POLYMORPHIC_MATCHER_P(
/// classTemplateSpecializationDecl(hasAnyTemplateArgument(refersToType(
/// recordType(hasDeclaration(recordDecl(hasName("X")))))))
/// matches the specialization of \c struct A generated by \c A<X>.
-AST_MATCHER_P(TemplateArgument, refersToType,
- internal::Matcher<QualType>, InnerMatcher) {
+AST_MATCHER_P(TemplateArgument, refersToType, internal::Matcher<QualType>,
+ InnerMatcher) {
if (Node.getKind() != TemplateArgument::Type)
return false;
return InnerMatcher.matches(Node.getAsType(), Finder, Builder);
@@ -1189,8 +1181,8 @@ AST_MATCHER_P(TemplateArgument, refersToTemplate,
/// refersToDeclaration(fieldDecl(hasName("next")))))
/// matches the specialization \c A<&B::next> with \c fieldDecl(...) matching
/// \c B::next
-AST_MATCHER_P(TemplateArgument, refersToDeclaration,
- internal::Matcher<Decl>, InnerMatcher) {
+AST_MATCHER_P(TemplateArgument, refersToDeclaration, internal::Matcher<Decl>,
+ InnerMatcher) {
if (Node.getKind() == TemplateArgument::Declaration)
return InnerMatcher.matches(*Node.getAsDecl(), Finder, Builder);
return false;
@@ -1260,8 +1252,7 @@ AST_MATCHER_P(TemplateArgument, refersToIntegralType,
/// classTemplateSpecializationDecl(
/// hasAnyTemplateArgument(equalsIntegralValue("42")))
/// matches the implicit instantiation of C in C<42>.
-AST_MATCHER_P(TemplateArgument, equalsIntegralValue,
- std::string, Value) {
+AST_MATCHER_P(TemplateArgument, equalsIntegralValue, std::string, Value) {
if (Node.getKind() != TemplateArgument::Integral)
return false;
return toString(Node.getAsIntegral(), 10) == Value;
@@ -1278,7 +1269,8 @@ AST_MATCHER_P(TemplateArgument, equalsIntegralValue,
/// autoreleasePoolStmt(stmt()) matches the declaration of "x"
/// inside the autorelease pool.
extern const internal::VariadicDynCastAllOfMatcher<Stmt,
- ObjCAutoreleasePoolStmt> autoreleasePoolStmt;
+ ObjCAutoreleasePoolStmt>
+ autoreleasePoolStmt;
/// Matches any export declaration.
///
@@ -1687,8 +1679,7 @@ extern const internal::VariadicDynCastAllOfMatcher<Decl, ObjCMethodDecl>
/// printf("%d", p);
/// })
/// \endcode
-extern const internal::VariadicDynCastAllOfMatcher<Decl, BlockDecl>
- blockDecl;
+extern const internal::VariadicDynCastAllOfMatcher<Decl, BlockDecl> blockDecl;
/// Matches Objective-C instance variable declarations.
///
@@ -1777,8 +1768,8 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, InitListExpr>
/// Matches the syntactic form of init list expressions
/// (if expression have it).
-AST_MATCHER_P(InitListExpr, hasSyntacticForm,
- internal::Matcher<Expr>, InnerMatcher) {
+AST_MATCHER_P(InitListExpr, hasSyntacticForm, internal::Matcher<Expr>,
+ InnerMatcher) {
const Expr *SyntForm = Node.getSyntacticForm();
return (SyntForm != nullptr &&
InnerMatcher.matches(*SyntForm, Finder, Builder));
@@ -2057,7 +2048,8 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDeleteExpr>
extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNoexceptExpr>
cxxNoexceptExpr;
-/// Matches a loop initializing the elements of an array in a number of contexts:
+/// Matches a loop initializing the elements of an array in a number of
+/// contexts:
/// * in the implicit copy/move constructor for a class with an array member
/// * when a lambda-expression captures an array by value
/// * when a decomposition declaration decomposes an array
@@ -2071,16 +2063,16 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNoexceptExpr>
/// };
/// }
/// \endcode
-/// arrayInitLoopExpr() matches the implicit loop that initializes each element of
-/// the implicit array field inside the lambda object, that represents the array `a`
-/// captured by value.
+/// arrayInitLoopExpr() matches the implicit loop that initializes each element
+/// of the implicit array field inside the lambda object, that represents the
+/// array `a` captured by value.
extern const internal::VariadicDynCastAllOfMatcher<Stmt, ArrayInitLoopExpr>
arrayInitLoopExpr;
/// The arrayInitIndexExpr consists of two subexpressions: a common expression
-/// (the source array) that is evaluated once up-front, and a per-element initializer
-/// that runs once for each array element. Within the per-element initializer,
-/// the current index may be obtained via an ArrayInitIndexExpr.
+/// (the source array) that is evaluated once up-front, and a per-element
+/// initializer that runs once for each array element. Within the per-element
+/// initializer, the current index may be obtained via an ArrayInitIndexExpr.
///
/// Given
/// \code
@@ -2246,8 +2238,7 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, ForStmt> forStmt;
/// \code
/// for (x; x < N; ++x) { }
/// \endcode
-AST_MATCHER_P(ForStmt, hasIncrement, internal::Matcher<Stmt>,
- InnerMatcher) {
+AST_MATCHER_P(ForStmt, hasIncrement, internal::Matcher<Stmt>, InnerMatcher) {
const Stmt *const Increment = Node.getInc();
return (Increment != nullptr &&
InnerMatcher.matches(*Increment, Finder, Builder));
@@ -2261,8 +2252,7 @@ AST_MATCHER_P(ForStmt, hasIncrement, internal::Matcher<Stmt>,
/// \code
/// for (int x = 0; x < N; ++x) { }
/// \endcode
-AST_MATCHER_P(ForStmt, hasLoopInit, internal::Matcher<Stmt>,
- InnerMatcher) {
+AST_MATCHER_P(ForStmt, hasLoopInit, internal::Matcher<Stmt>, InnerMatcher) {
const Stmt *const Init = Node.getInit();
return (Init != nullptr && InnerMatcher.matches(*Init, Finder, Builder));
}
@@ -2650,8 +2640,7 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, CXXNullPtrLiteralExpr>
cxxNullPtrLiteralExpr;
/// Matches GNU __builtin_choose_expr.
-extern const internal::VariadicDynCastAllOfMatcher<Stmt, ChooseExpr>
- chooseExpr;
+extern const internal::VariadicDynCastAllOfMatcher<Stmt, ChooseExpr> chooseExpr;
/// Matches builtin function __builtin_convertvector.
extern const internal::VariadicDynCastAllOfMatcher<Stmt, ConvertVectorExpr>
@@ -3181,8 +3170,8 @@ AST_MATCHER_P(UnaryExprOrTypeTraitExpr, ofKind, UnaryExprOrTypeTrait, Kind) {
/// Same as unaryExprOrTypeTraitExpr, but only matching
/// alignof.
-inline internal::BindableMatcher<Stmt> alignOfExpr(
- const internal::Matcher<UnaryExprOrTypeTraitExpr> &InnerMatcher) {
+inline internal::BindableMatcher<Stmt>
+alignOfExpr(const internal::Matcher<UnaryExprOrTypeTraitExpr> &InnerMatcher) {
return stmt(unaryExprOrTypeTraitExpr(
allOf(anyOf(ofKind(UETT_AlignOf), ofKind(UETT_PreferredAlignOf)),
InnerMatcher)));
@@ -3190,10 +3179,10 @@ inline internal::BindableMatcher<Stmt> alignOfExpr(
/// Same as unaryExprOrTypeTraitExpr, but only matching
/// sizeof.
-inline internal::BindableMatcher<Stmt> sizeOfExpr(
- const internal::Matcher<UnaryExprOrTypeTraitExpr> &InnerMatcher) {
- return stmt(unaryExprOrTypeTraitExpr(
- allOf(ofKind(UETT_SizeOf), InnerMatcher)));
+inline internal::BindableMatcher<Stmt>
+sizeOfExpr(const internal::Matcher<UnaryExprOrTypeTraitExpr> &InnerMatcher) {
+ return stmt(
+ unaryExprOrTypeTraitExpr(allOf(ofKind(UETT_SizeOf), InnerMatcher)));
}
/// Matches NamedDecl nodes that have the specified name.
@@ -3424,10 +3413,10 @@ AST_POLYMORPHIC_MATCHER_P(hasDependentName,
/// \endcode
///
/// Usable as: Matcher<CXXRecordDecl>, Matcher<ObjCInterfaceDecl>
-AST_POLYMORPHIC_MATCHER_P(
- isDerivedFrom,
- AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl),
- internal::Matcher<NamedDecl>, Base) {
+AST_POLYMORPHIC_MATCHER_P(isDerivedFrom,
+ AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl,
+ ObjCInterfaceDecl),
+ internal::Matcher<NamedDecl>, Base) {
// Check if the node is a C++ struct/union/class.
if (const auto *RD = dyn_cast<CXXRecordDecl>(&Node))
return Finder->classIsDerivedFrom(RD, Base, Builder, /*Directly=*/false);
@@ -3612,9 +3601,7 @@ AST_MATCHER_P(CXXRecordDecl, hasMethod, internal::Matcher<CXXMethodDecl>,
///
/// \c cxxRecordDecl(isLambda()) matches the implicit class declaration of
/// \c decltype(x)
-AST_MATCHER(CXXRecordDecl, isLambda) {
- return Node.isLambda();
-}
+AST_MATCHER(CXXRecordDecl, isLambda) { return Node.isLambda(); }
/// Matches AST nodes that have child AST nodes that match the
/// provided matcher.
@@ -3852,15 +3839,13 @@ AST_MATCHER_P(NamedDecl, hasUnderlyingDecl, internal::Matcher<NamedDecl>,
/// matches `(g()).m()`.
///
/// FIXME: Overload to allow directly matching types?
-AST_MATCHER_P(CXXMemberCallExpr, on, internal::Matcher<Expr>,
- InnerMatcher) {
- const Expr *ExprNode = Node.getImplicitObjectArgument()
- ->IgnoreParenImpCasts();
+AST_MATCHER_P(CXXMemberCallExpr, on, internal::Matcher<Expr>, InnerMatcher) {
+ const Expr *ExprNode =
+ Node.getImplicitObjectArgument()->IgnoreParenImpCasts();
return (ExprNode != nullptr &&
InnerMatcher.matches(*ExprNode, Finder, Builder));
}
-
/// Matches on the receiver of an ObjectiveC Message expression.
///
/// Example
@@ -3889,9 +3874,7 @@ AST_MATCHER_P(ObjCMessageExpr, hasReceiverType, internal::Matcher<QualType>,
/// \code
/// @interface I - (void)bar; @end
/// \endcode
-AST_MATCHER(ObjCMethodDecl, isClassMethod) {
- return Node.isClassMethod();
-}
+AST_MATCHER(ObjCMethodDecl, isClassMethod) { return Node.isClassMethod(); }
/// Returns true when the Objective-C method declaration is an instance method.
///
@@ -3922,9 +3905,7 @@ AST_MATCHER(ObjCMethodDecl, isInstanceMethod) {
/// NSString *x = @"hello";
/// [x containsString:@"h"];
/// \endcode
-AST_MATCHER(ObjCMessageExpr, isClassMessage) {
- return Node.isClassMessage();
-}
+AST_MATCHER(ObjCMessageExpr, isClassMessage) { return Node.isClassMessage(); }
/// Returns true when the Objective-C message is sent to an instance.
///
@@ -3984,9 +3965,8 @@ AST_MATCHER_P(ObjCMessageExpr, hasSelector, std::string, BaseName) {
/// [myObj methodB:argB];
/// \endcode
extern const internal::VariadicFunction<internal::Matcher<ObjCMessageExpr>,
- StringRef,
- internal::hasAnySelectorFunc>
- hasAnySelector;
+ StringRef, internal::hasAnySelectorFunc>
+ hasAnySelector;
/// Matches ObjC selectors whose name contains
/// a substring matched by the given RegExp.
@@ -4180,7 +4160,7 @@ AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
/// \endcode
///
/// Example matches class Derived
-/// (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
+/// matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")))))
/// \code
/// class Base {};
/// class Derived : Base {};
@@ -4268,9 +4248,7 @@ AST_MATCHER_P(QualType, asString, std::string, Name) {
/// class Y { public: void x(); };
/// void z() { Y *y; y->x(); }
/// \endcode
-AST_MATCHER_P(
- QualType, pointsTo, internal::Matcher<QualType>,
- InnerMatcher) {
+AST_MATCHER_P(QualType, pointsTo, internal::Matcher<QualType>, InnerMatcher) {
return (!Node.isNull() && Node->isAnyPointerType() &&
InnerMatcher.matches(Node->getPointeeType(), Finder, Builder));
}
@@ -4311,8 +4289,7 @@ AST_MATCHER_P(Type, hasUnqualifiedDesugaredType, internal::Matcher<Type>,
/// }
/// };
/// \endcode
-AST_MATCHER_P(QualType, references, internal::Matcher<QualType>,
- InnerMatcher) {
+AST_MATCHER_P(QualType, references, internal::Matcher<QualType>, InnerMatcher) {
return (!Node.isNull() && Node->isReferenceType() &&
InnerMatcher.matches(Node->getPointeeType(), Finder, Builder));
}
@@ -4386,7 +4363,7 @@ AST_MATCHER_P(CXXMemberCallExpr, onImplicitObjectArgument,
AST_MATCHER_P_OVERLOAD(CXXMemberCallExpr, thisPointerType,
internal::Matcher<QualType>, InnerMatcher, 0) {
return onImplicitObjectArgument(
- anyOf(hasType(InnerMatcher), hasType(pointsTo(InnerMatcher))))
+ anyOf(hasType(InnerMatcher), hasType(pointsTo(InnerMatcher))))
.matches(Node, Finder, Builder);
}
@@ -4394,7 +4371,7 @@ AST_MATCHER_P_OVERLOAD(CXXMemberCallExpr, thisPointerType,
AST_MATCHER_P_OVERLOAD(CXXMemberCallExpr, thisPointerType,
internal::Matcher<Decl>, InnerMatcher, 1) {
return onImplicitObjectArgument(
- anyOf(hasType(InnerMatcher), hasType(pointsTo(InnerMatcher))))
+ anyOf(hasType(InnerMatcher), hasType(pointsTo(InnerMatcher))))
.matches(Node, Finder, Builder);
}
@@ -4407,8 +4384,7 @@ AST_MATCHER_P_OVERLOAD(CXXMemberCallExpr, thisPointerType,
/// bool x;
/// if (x) {}
/// \endcode
-AST_MATCHER_P(DeclRefExpr, to, internal::Matcher<Decl>,
- InnerMatcher) {
+AST_MATCHER_P(DeclRefExpr, to, internal::Matcher<Decl>, InnerMatcher) {
const Decl *DeclNode = Node.getDecl();
return (DeclNode != nullptr &&
InnerMatcher.matches(*DeclNode, Finder, Builder));
@@ -4498,9 +4474,7 @@ AST_MATCHER_P(DeclStmt, hasSingleDecl, internal::Matcher<Decl>, InnerMatcher) {
/// bool y() { return true; }
/// bool x = y();
/// \endcode
-AST_MATCHER_P(
- VarDecl, hasInitializer, internal::Matcher<Expr>,
- InnerMatcher) {
+AST_MATCHER_P(VarDecl, hasInitializer, internal::Matcher<Expr>, InnerMatcher) {
const Expr *Initializer = Node.getAnyInitializer();
return (Initializer != nullptr &&
InnerMatcher.matches(*Initializer, Finder, Builder));
@@ -4555,9 +4529,7 @@ AST_MATCHER_P(LambdaExpr, forEachLambdaCapture,
/// }
/// static int z;
/// \endcode
-AST_MATCHER(VarDecl, isStaticLocal) {
- return Node.isStaticLocal();
-}
+AST_MATCHER(VarDecl, isStaticLocal) { return Node.isStaticLocal(); }
/// Matches a variable declaration that has function scope and is a
/// non-static local variable.
@@ -4570,9 +4542,7 @@ AST_MATCHER(VarDecl, isStaticLocal) {
/// }
/// int z;
/// \endcode
-AST_MATCHER(VarDecl, hasLocalStorage) {
- return Node.hasLocalStorage();
-}
+AST_MATCHER(VarDecl, hasLocalStorage) { return Node.hasLocalStorage(); }
/// Matches a variable declaration that does not have local storage.
///
@@ -4584,9 +4554,7 @@ AST_MATCHER(VarDecl, hasLocalStorage) {
/// }
/// int z;
/// \endcode
-AST_MATCHER(VarDecl, hasGlobalStorage) {
- return Node.hasGlobalStorage();
-}
+AST_MATCHER(VarDecl, hasGlobalStorage) { return Node.hasGlobalStorage(); }
/// Matches a variable declaration that has automatic storage duration.
///
@@ -4651,9 +4619,7 @@ AST_MATCHER(VarDecl, hasThreadStorageDuration) {
/// }
/// }
/// \endcode
-AST_MATCHER(VarDecl, isExceptionVariable) {
- return Node.isExceptionVariable();
-}
+AST_MATCHER(VarDecl, isExceptionVariable) { return Node.isExceptionVariable(); }
/// Checks that a call expression or a constructor call expression has
/// a specific number of arguments (including absent default arguments).
@@ -4850,7 +4816,7 @@ AST_MATCHER(CXXFoldExpr, isBinaryFold) { return Node.getInit() != nullptr; }
AST_MATCHER_P2(InitListExpr, hasInit, unsigned, N, internal::Matcher<Expr>,
InnerMatcher) {
return N < Node.getNumInits() &&
- InnerMatcher.matches(*Node.getInit(N), Finder, Builder);
+ InnerMatcher.matches(*Node.getInit(N), Finder, Builder);
}
/// Matches declaration statements that contain a specific number of
@@ -4949,11 +4915,11 @@ AST_MATCHER_P(CXXConstructorDecl, hasAnyConstructorInitializer,
/// forField(hasName("foo_"))))))
/// matches Foo
/// with forField matching foo_
-AST_MATCHER_P(CXXCtorInitializer, forField,
- internal::Matcher<FieldDecl>, InnerMatcher) {
+AST_MATCHER_P(CXXCtorInitializer, forField, internal::Matcher<FieldDecl>,
+ InnerMatcher) {
const FieldDecl *NodeAsDecl = Node.getAnyMember();
return (NodeAsDecl != nullptr &&
- InnerMatcher.matches(*NodeAsDecl, Finder, Builder));
+ InnerMatcher.matches(*NodeAsDecl, Finder, Builder));
}
/// Matches the initializer expression of a constructor initializer.
@@ -4969,11 +4935,11 @@ AST_MATCHER_P(CXXCtorInitializer, forField,
/// withInitializer(integerLiteral(equals(1)))))))
/// matches Foo
/// with withInitializer matching (1)
-AST_MATCHER_P(CXXCtorInitializer, withInitializer,
- internal::Matcher<Expr>, InnerMatcher) {
- const Expr* NodeAsExpr = Node.getInit();
+AST_MATCHER_P(CXXCtorInitializer, withInitializer, internal::Matcher<Expr>,
+ InnerMatcher) {
+ const Expr *NodeAsExpr = Node.getInit();
return (NodeAsExpr != nullptr &&
- InnerMatcher.matches(*NodeAsExpr, Finder, Builder));
+ InnerMatcher.matches(*NodeAsExpr, Finder, Builder));
}
/// Matches a constructor initializer if it is explicitly written in
@@ -4989,9 +4955,7 @@ AST_MATCHER_P(CXXCtorInitializer, withInitializer,
/// \endcode
/// cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
/// will match Foo(int), but not Foo()
-AST_MATCHER(CXXCtorInitializer, isWritten) {
- return Node.isWritten();
-}
+AST_MATCHER(CXXCtorInitializer, isWritten) { return Node.isWritten(); }
/// Matches a constructor initializer if it is initializing a base, as
/// opposed to a member.
@@ -5188,14 +5152,12 @@ AST_MATCHER(CXXConstructExpr, requiresZeroInitialization) {
/// the matcher objcMethodDecl(hasParameter(0, hasName("y")))
/// matches the declaration of method f with hasParameter
/// matching y.
-AST_POLYMORPHIC_MATCHER_P2(hasParameter,
- AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
- ObjCMethodDecl,
- BlockDecl),
- unsigned, N, internal::Matcher<ParmVarDecl>,
- InnerMatcher) {
- return (N < Node.parameters().size()
- && InnerMatcher.matches(*Node.parameters()[N], Finder, Builder));
+AST_POLYMORPHIC_MATCHER_P2(
+ hasParameter,
+ AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, ObjCMethodDecl, BlockDecl),
+ unsigned, N, internal::Matcher<ParmVarDecl>, InnerMatcher) {
+ return (N < Node.parameters().size() &&
+ InnerMatcher.matches(*Node.parameters()[N], Finder, Builder));
}
/// Matches if the given method declaration declares a member function with an
@@ -5255,8 +5217,8 @@ AST_POLYMORPHIC_MATCHER_P2(forEachArgumentWithParam,
bool Matched = false;
for (; ArgIndex < Node.getNumArgs(); ++ArgIndex) {
BoundNodesTreeBuilder ArgMatches(*Builder);
- if (ArgMatcher.matches(*(Node.getArg(ArgIndex)->IgnoreParenCasts()),
- Finder, &ArgMatches)) {
+ if (ArgMatcher.matches(*(Node.getArg(ArgIndex)->IgnoreParenCasts()), Finder,
+ &ArgMatches)) {
BoundNodesTreeBuilder ParamMatches(ArgMatches);
if (expr(anyOf(cxxConstructExpr(hasDeclaration(cxxConstructorDecl(
hasParameter(ParamIndex, ParamMatcher)))),
@@ -5390,8 +5352,7 @@ AST_POLYMORPHIC_MATCHER_P(hasAnyParameter,
AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
ObjCMethodDecl,
BlockDecl),
- internal::Matcher<ParmVarDecl>,
- InnerMatcher) {
+ internal::Matcher<ParmVarDecl>, InnerMatcher) {
return matchesFirstInPointerRange(InnerMatcher, Node.param_begin(),
Node.param_end(), Finder,
Builder) != Node.param_end();
@@ -5490,8 +5451,8 @@ AST_MATCHER(FunctionDecl, isNoReturn) { return Node.isNoReturn(); }
/// \endcode
/// cxxMethodDecl(returns(asString("int")))
/// matches int f() { return 1; }
-AST_MATCHER_P(FunctionDecl, returns,
- internal::Matcher<QualType>, InnerMatcher) {
+AST_MATCHER_P(FunctionDecl, returns, internal::Matcher<QualType>,
+ InnerMatcher) {
return InnerMatcher.matches(Node.getReturnType(), Finder, Builder);
}
@@ -5544,9 +5505,7 @@ AST_POLYMORPHIC_MATCHER(isStaticStorageClass,
/// \endcode
/// functionDecl(isDeleted())
/// matches the declaration of DeletedFunc, but not Func.
-AST_MATCHER(FunctionDecl, isDeleted) {
- return Node.isDeleted();
-}
+AST_MATCHER(FunctionDecl, isDeleted) { return Node.isDeleted(); }
/// Matches defaulted function declarations.
///
@@ -5557,9 +5516,7 @@ AST_MATCHER(FunctionDecl, isDeleted) {
/// \endcode
/// functionDecl(isDefaulted())
/// matches the declaration of ~B, but not ~A.
-AST_MATCHER(FunctionDecl, isDefaulted) {
- return Node.isDefaulted();
-}
+AST_MATCHER(FunctionDecl, isDefaulted) { return Node.isDefaulted(); }
/// Matches weak function declarations.
///
@@ -5660,8 +5617,7 @@ AST_POLYMORPHIC_MATCHER(isConsteval,
/// ifStmt(isConstexpr())
/// matches the if statement in baz.
AST_POLYMORPHIC_MATCHER(isConstexpr,
- AST_POLYMORPHIC_SUPPORTED_TYPES(VarDecl,
- FunctionDecl,
+ AST_POLYMORPHIC_SUPPORTED_TYPES(VarDecl, FunctionDecl,
IfStmt)) {
return Node.isConstexpr();
}
@@ -5813,8 +5769,8 @@ AST_POLYMORPHIC_MATCHER_P(hasConditionVariableStatement,
WhileStmt,
SwitchStmt),
internal::Matcher<DeclStmt>, InnerMatcher) {
- const DeclStmt* const DeclarationStatement =
- Node.getConditionVariableDeclStmt();
+ const DeclStmt *const DeclarationStatement =
+ Node.getConditionVariableDeclStmt();
return DeclarationStatement != nullptr &&
InnerMatcher.matches(*DeclarationStatement, Finder, Builder);
}
@@ -5828,9 +5784,9 @@ AST_POLYMORPHIC_MATCHER_P(hasConditionVariableStatement,
/// \endcode
/// arraySubscriptExpression(hasIndex(integerLiteral()))
/// matches \c i[1] with the \c integerLiteral() matching \c 1
-AST_MATCHER_P(ArraySubscriptExpr, hasIndex,
- internal::Matcher<Expr>, InnerMatcher) {
- if (const Expr* Expression = Node.getIdx())
+AST_MATCHER_P(ArraySubscriptExpr, hasIndex, internal::Matcher<Expr>,
+ InnerMatcher) {
+ if (const Expr *Expression = Node.getIdx())
return InnerMatcher.matches(*Expression, Finder, Builder);
return false;
}
@@ -5845,9 +5801,9 @@ AST_MATCHER_P(ArraySubscriptExpr, hasIndex,
/// arraySubscriptExpression(hasBase(implicitCastExpr(
/// hasSourceExpression(declRefExpr()))))
/// matches \c i[1] with the \c declRefExpr() matching \c i
-AST_MATCHER_P(ArraySubscriptExpr, hasBase,
- internal::Matcher<Expr>, InnerMatcher) {
- if (const Expr* Expression = Node.getBase())
+AST_MATCHER_P(ArraySubscriptExpr, hasBase, internal::Matcher<Expr>,
+ InnerMatcher) {
+ if (const Expr *Expression = Node.getBase())
return InnerMatcher.matches(*Expression, Finder, Builder);
return false;
}
@@ -5904,14 +5860,12 @@ AST_POLYMORPHIC_MATCHER_P(
/// with compoundStmt()
/// matching '{}'
/// but does not match 'void g();'
-AST_MATCHER_P(FunctionDecl, hasAnyBody,
- internal::Matcher<Stmt>, InnerMatcher) {
+AST_MATCHER_P(FunctionDecl, hasAnyBody, internal::Matcher<Stmt>, InnerMatcher) {
const Stmt *const Statement = Node.getBody();
return (Statement != nullptr &&
InnerMatcher.matches(*Statement, Finder, Builder));
}
-
/// Matches compound statements where at least one substatement matches
/// a given matcher. Also matches StmtExprs that have CompoundStmt as children.
///
@@ -5981,32 +5935,31 @@ equals(const ValueT &Value) {
Value);
}
-AST_POLYMORPHIC_MATCHER_P_OVERLOAD(equals,
- AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral,
- CXXBoolLiteralExpr,
- IntegerLiteral),
- bool, Value, 0) {
- return internal::ValueEqualsMatcher<NodeType, ParamT>(Value)
- .matchesNode(Node);
+AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
+ equals,
+ AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral, CXXBoolLiteralExpr,
+ IntegerLiteral),
+ bool, Value, 0) {
+ return internal::ValueEqualsMatcher<NodeType, ParamT>(Value).matchesNode(
+ Node);
}
-AST_POLYMORPHIC_MATCHER_P_OVERLOAD(equals,
- AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral,
- CXXBoolLiteralExpr,
- IntegerLiteral),
- unsigned, Value, 1) {
- return internal::ValueEqualsMatcher<NodeType, ParamT>(Value)
- .matchesNode(Node);
+AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
+ equals,
+ AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral, CXXBoolLiteralExpr,
+ IntegerLiteral),
+ unsigned, Value, 1) {
+ return internal::ValueEqualsMatcher<NodeType, ParamT>(Value).matchesNode(
+ Node);
}
-AST_POLYMORPHIC_MATCHER_P_OVERLOAD(equals,
- AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral,
- CXXBoolLiteralExpr,
- FloatingLiteral,
- IntegerLiteral),
- double, Value, 2) {
- return internal::ValueEqualsMatcher<NodeType, ParamT>(Value)
- .matchesNode(Node);
+AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
+ equals,
+ AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral, CXXBoolLiteralExpr,
+ FloatingLiteral, IntegerLiteral),
+ double, Value, 2) {
+ return internal::ValueEqualsMatcher<NodeType, ParamT>(Value).matchesNode(
+ Node);
}
/// Matches the operator Name of operator expressions and fold expressions
@@ -6220,8 +6173,8 @@ AST_MATCHER_P(CastExpr, hasCastKind, CastKind, Kind) {
///
/// (Note: Clang's AST refers to other conversions as "casts" too, and calls
/// actual casts "explicit" casts.)
-AST_MATCHER_P(ExplicitCastExpr, hasDestinationType,
- internal::Matcher<QualType>, InnerMatcher) {
+AST_MATCHER_P(ExplicitCastExpr, hasDestinationType, internal::Matcher<QualType>,
+ InnerMatcher) {
const QualType NodeType = Node.getTypeAsWritten();
return InnerMatcher.matches(NodeType, Finder, Builder);
}
@@ -6242,9 +6195,7 @@ AST_MATCHER_P(ImplicitCastExpr, hasImplicitDestinationType,
/// union U {};
/// enum E {};
/// \endcode
-AST_MATCHER(TagDecl, isStruct) {
- return Node.isStruct();
-}
+AST_MATCHER(TagDecl, isStruct) { return Node.isStruct(); }
/// Matches TagDecl object that are spelled with "union."
///
@@ -6255,9 +6206,7 @@ AST_MATCHER(TagDecl, isStruct) {
/// union U {};
/// enum E {};
/// \endcode
-AST_MATCHER(TagDecl, isUnion) {
- return Node.isUnion();
-}
+AST_MATCHER(TagDecl, isUnion) { return Node.isUnion(); }
/// Matches TagDecl object that are spelled with "class."
///
@@ -6268,9 +6217,7 @@ AST_MATCHER(TagDecl, isUnion) {
/// union U {};
/// enum E {};
/// \endcode
-AST_MATCHER(TagDecl, isClass) {
- return Node.isClass();
-}
+AST_MATCHER(TagDecl, isClass) { return Node.isClass(); }
/// Matches TagDecl object that are spelled with "enum."
///
@@ -6281,9 +6228,7 @@ AST_MATCHER(TagDecl, isClass) {
/// union U {};
/// enum E {};
/// \endcode
-AST_MATCHER(TagDecl, isEnum) {
- return Node.isEnum();
-}
+AST_MATCHER(TagDecl, isEnum) { return Node.isEnum(); }
/// Matches the true branch expression of a conditional operator.
///
@@ -6355,9 +6300,7 @@ AST_POLYMORPHIC_MATCHER(isDefinition,
/// template <typename... Ts> void h(Ts...);
/// void i();
/// \endcode
-AST_MATCHER(FunctionDecl, isVariadic) {
- return Node.isVariadic();
-}
+AST_MATCHER(FunctionDecl, isVariadic) { return Node.isVariadic(); }
/// Matches the class declaration that the given method declaration
/// belongs to.
@@ -6376,14 +6319,13 @@ AST_MATCHER(FunctionDecl, isVariadic) {
/// };
/// A a = A();
/// \endcode
-AST_MATCHER_P(CXXMethodDecl, ofClass,
- internal::Matcher<CXXRecordDecl>, InnerMatcher) {
+AST_MATCHER_P(CXXMethodDecl, ofClass, internal::Matcher<CXXRecordDecl>,
+ InnerMatcher) {
ASTChildrenNotSpelledInSourceScope RAII(Finder, false);
const CXXRecordDecl *Parent = Node.getParent();
- return (Parent != nullptr &&
- InnerMatcher.matches(*Parent, Finder, Builder));
+ return (Parent != nullptr && InnerMatcher.matches(*Parent, Finder, Builder));
}
/// Matches each method overridden by the given method. This matcher may
@@ -6518,9 +6460,7 @@ AST_MATCHER(CXXMethodDecl, isPure) { return Node.isPureVirtual(); }
/// \endcode
///
/// cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
-AST_MATCHER(CXXMethodDecl, isConst) {
- return Node.isConst();
-}
+AST_MATCHER(CXXMethodDecl, isConst) { return Node.isConst(); }
/// Matches if the given method declaration declares a copy assignment
/// operator.
@@ -6585,9 +6525,7 @@ AST_MATCHER(CXXMethodDecl, isOverride) {
/// };
/// \endcode
/// cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
-AST_MATCHER(CXXMethodDecl, isUserProvided) {
- return Node.isUserProvided();
-}
+AST_MATCHER(CXXMethodDecl, isUserProvided) { return Node.isUserProvided(); }
/// Matches member expressions that are called with '->' as opposed
/// to '.'.
@@ -6629,9 +6567,7 @@ AST_POLYMORPHIC_MATCHER(
/// \endcode
/// functionDecl(hasAnyParameter(hasType(isInteger())))
/// matches "a(int)", "b(unsigned long)", but not "c(double)".
-AST_MATCHER(QualType, isInteger) {
- return Node->isIntegerType();
-}
+AST_MATCHER(QualType, isInteger) { return Node->isIntegerType(); }
/// Matches QualType nodes that are of unsigned integer type.
///
@@ -6644,7 +6580,7 @@ AST_MATCHER(QualType, isInteger) {
/// functionDecl(hasAnyParameter(hasType(isUnsignedInteger())))
/// matches "b(unsigned long)", but not "a(int)" and "c(double)".
AST_MATCHER(QualType, isUnsignedInteger) {
- return Node->isUnsignedIntegerType();
+ return Node->isUnsignedIntegerType();
}
/// Matches QualType nodes that are of signed integer type.
@@ -6657,9 +6593,7 @@ AST_MATCHER(QualType, isUnsignedInteger) {
/// \endcode
/// functionDecl(hasAnyParameter(hasType(isSignedInteger())))
/// matches "a(int)", but not "b(unsigned long)" and "c(double)".
-AST_MATCHER(QualType, isSignedInteger) {
- return Node->isSignedIntegerType();
-}
+AST_MATCHER(QualType, isSignedInteger) { return Node->isSignedIntegerType(); }
/// Matches QualType nodes that are of character type.
///
@@ -6671,9 +6605,7 @@ AST_MATCHER(QualType, isSignedInteger) {
/// \endcode
/// functionDecl(hasAnyParameter(hasType(isAnyCharacter())))
/// matches "a(char)", "b(wchar_t)", but not "c(double)".
-AST_MATCHER(QualType, isAnyCharacter) {
- return Node->isAnyCharacterType();
-}
+AST_MATCHER(QualType, isAnyCharacter) { return Node->isAnyCharacterType(); }
/// Matches QualType nodes that are of any pointer type; this includes
/// the Objective-C object pointer type, which is different despite being
@@ -6691,9 +6623,7 @@ AST_MATCHER(QualType, isAnyCharacter) {
/// \endcode
/// varDecl(hasType(isAnyPointer()))
/// matches "int *i" and "Foo *f", but not "int j".
-AST_MATCHER(QualType, isAnyPointer) {
- return Node->isAnyPointerType();
-}
+AST_MATCHER(QualType, isAnyPointer) { return Node->isAnyPointerType(); }
/// Matches QualType nodes that are const-qualified, i.e., that
/// include "top-level" const.
@@ -6710,9 +6640,7 @@ AST_MATCHER(QualType, isAnyPointer) {
/// matches "void b(int const)", "void c(const int)" and
/// "void e(int const) {}". It does not match d as there
/// is no top-level const on the parameter type "const int *".
-AST_MATCHER(QualType, isConstQualified) {
- return Node.isConstQualified();
-}
+AST_MATCHER(QualType, isConstQualified) { return Node.isConstQualified(); }
/// Matches QualType nodes that are volatile-qualified, i.e., that
/// include "top-level" volatile.
@@ -6746,9 +6674,7 @@ AST_MATCHER(QualType, isVolatileQualified) {
/// \endcode
/// \c varDecl(hasType(hasLocalQualifiers())) matches only \c j and \c k.
/// \c i is const-qualified but the qualifier is not local.
-AST_MATCHER(QualType, hasLocalQualifiers) {
- return Node.hasLocalQualifiers();
-}
+AST_MATCHER(QualType, hasLocalQualifiers) { return Node.hasLocalQualifiers(); }
/// Matches a member expression where the member is matched by a
/// given matcher.
@@ -6762,8 +6688,7 @@ AST_MATCHER(QualType, hasLocalQualifiers) {
/// memberExpr(member(hasName("first")))
/// matches second.first
/// but not first.second (because the member name there is "second").
-AST_MATCHER_P(MemberExpr, member,
- internal::Matcher<ValueDecl>, InnerMatcher) {
+AST_MATCHER_P(MemberExpr, member, internal::Matcher<ValueDecl>, InnerMatcher) {
return InnerMatcher.matches(*Node.getMemberDecl(), Finder, Builder);
}
@@ -6825,8 +6750,8 @@ AST_MATCHER_P(BaseUsingDecl, hasAnyUsingShadowDecl,
/// usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
/// matches \code using X::b \endcode
/// but not \code using X::a \endcode
-AST_MATCHER_P(UsingShadowDecl, hasTargetDecl,
- internal::Matcher<NamedDecl>, InnerMatcher) {
+AST_MATCHER_P(UsingShadowDecl, hasTargetDecl, internal::Matcher<NamedDecl>,
+ InnerMatcher) {
return InnerMatcher.matches(*Node.getTargetDecl(), Finder, Builder);
}
@@ -7147,9 +7072,7 @@ AST_POLYMORPHIC_MATCHER_P(
/// \endcode
/// functionDecl(returns(booleanType()))
/// matches "bool func();"
-AST_MATCHER(Type, booleanType) {
- return Node.isBooleanType();
-}
+AST_MATCHER(Type, booleanType) { return Node.isBooleanType(); }
/// Matches type \c void.
///
@@ -7159,9 +7082,7 @@ AST_MATCHER(Type, booleanType) {
/// \endcode
/// functionDecl(returns(voidType()))
/// matches "void func();"
-AST_MATCHER(Type, voidType) {
- return Node.isVoidType();
-}
+AST_MATCHER(Type, voidType) { return Node.isVoidType(); }
template <typename NodeType>
using AstTypeMatcher = internal::VariadicDynCastAllOfMatcher<Type, NodeType>;
@@ -7211,9 +7132,7 @@ extern const AstTypeMatcher<ComplexType> complexType;
/// \endcode
/// realFloatingPointType()
/// matches "float f" but not "int i"
-AST_MATCHER(Type, realFloatingPointType) {
- return Node.isRealFloatingType();
-}
+AST_MATCHER(Type, realFloatingPointType) { return Node.isRealFloatingType(); }
/// Matches arrays and C99 complex types that have a specific element
/// type.
@@ -7335,8 +7254,8 @@ extern const AstTypeMatcher<VariableArrayType> variableArrayType;
/// variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
/// varDecl(hasName("b")))))))
/// matches "int a[b]"
-AST_MATCHER_P(VariableArrayType, hasSizeExpr,
- internal::Matcher<Expr>, InnerMatcher) {
+AST_MATCHER_P(VariableArrayType, hasSizeExpr, internal::Matcher<Expr>,
+ InnerMatcher) {
return InnerMatcher.matches(*Node.getSizeExpr(), Finder, Builder);
}
@@ -7789,7 +7708,8 @@ extern const AstTypeMatcher<InjectedClassNameType> injectedClassNameType;
/// Matches decayed type
/// Example matches i[] in declaration of f.
-/// (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
+/// (matcher =
+/// valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
/// Example matches i[1].
/// (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())))))
/// \code
@@ -7831,7 +7751,8 @@ extern const AstTypeMatcher<DependentNameType> dependentNameType;
/// declaration of \c class \c D.
AST_MATCHER_P(Decl, hasDeclContext, internal::Matcher<Decl>, InnerMatcher) {
const DeclContext *DC = Node.getDeclContext();
- if (!DC) return false;
+ if (!DC)
+ return false;
return InnerMatcher.matches(*Decl::castFromDeclContext(DC), Finder, Builder);
}
@@ -7877,8 +7798,8 @@ AST_MATCHER_FUNCTION_P_OVERLOAD(
/// hasDeclaration(cxxRecordDecl(hasName("A")))
/// ))
/// matches "A::"
-AST_MATCHER_P(NestedNameSpecifier, specifiesType,
- internal::Matcher<QualType>, InnerMatcher) {
+AST_MATCHER_P(NestedNameSpecifier, specifiesType, internal::Matcher<QualType>,
+ InnerMatcher) {
if (Node.getKind() != NestedNameSpecifier::Kind::Type)
return false;
return InnerMatcher.matches(QualType(Node.getAsType(), 0), Finder, Builder);
@@ -8003,20 +7924,20 @@ extern const internal::VariadicAllOfMatcher<Attr> attr;
/// Matches if a node equals another node.
///
/// \c Decl has pointer identity in the AST.
-AST_MATCHER_P_OVERLOAD(Decl, equalsNode, const Decl*, Other, 0) {
+AST_MATCHER_P_OVERLOAD(Decl, equalsNode, const Decl *, Other, 0) {
return &Node == Other;
}
/// Matches if a node equals another node.
///
/// \c Stmt has pointer identity in the AST.
-AST_MATCHER_P_OVERLOAD(Stmt, equalsNode, const Stmt*, Other, 1) {
+AST_MATCHER_P_OVERLOAD(Stmt, equalsNode, const Stmt *, Other, 1) {
return &Node == Other;
}
/// Matches if a node equals another node.
///
/// \c Type has pointer identity in the AST.
-AST_MATCHER_P_OVERLOAD(Type, equalsNode, const Type*, Other, 2) {
- return &Node == Other;
+AST_MATCHER_P_OVERLOAD(Type, equalsNode, const Type *, Other, 2) {
+ return &Node == Other;
}
/// @}
@@ -8188,9 +8109,11 @@ AST_POLYMORPHIC_MATCHER(isExplicit, AST_POLYMORPHIC_SUPPORTED_TYPES(
/// S(int) -> S<true> // #5
/// explicit S(double) -> S<false> // #6
/// \endcode
-/// cxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2.
-/// cxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4.
-/// cxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6.
+/// cxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8
+/// and #9, but not #1 or #2.
+/// cxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or
+/// #4. cxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not
+/// match #5 or #6.
AST_MATCHER_P(FunctionDecl, hasExplicitSpecifier, internal::Matcher<Expr>,
InnerMatcher) {
ExplicitSpecifier ES = ExplicitSpecifier::getFromDecl(&Node);
@@ -8240,9 +8163,7 @@ AST_POLYMORPHIC_MATCHER(isInline, AST_POLYMORPHIC_SUPPORTED_TYPES(NamespaceDecl,
/// }
/// \endcode
/// namespaceDecl(isAnonymous()) will match #1 but not ::n.
-AST_MATCHER(NamespaceDecl, isAnonymous) {
- return Node.isAnonymousNamespace();
-}
+AST_MATCHER(NamespaceDecl, isAnonymous) { return Node.isAnonymousNamespace(); }
/// Matches declarations in the namespace `std`, but not in nested namespaces.
///
@@ -8598,9 +8519,7 @@ AST_MATCHER(NamedDecl, hasExternalFormalLinkage) {
/// A matcher such as
/// parmVarDecl(hasInitializer(anything()))
/// is equivalent to parmVarDecl(hasDefaultArgument()).
-AST_MATCHER(ParmVarDecl, hasDefaultArgument) {
- return Node.hasDefaultArg();
-}
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { return Node.hasDefaultArg(); }
/// Matches array new expressions.
///
@@ -8610,9 +8529,7 @@ AST_MATCHER(ParmVarDecl, hasDefaultArgument) {
/// \endcode
/// cxxNewExpr(isArray())
/// matches the expression 'new MyClass[10]'.
-AST_MATCHER(CXXNewExpr, isArray) {
- return Node.isArray();
-}
+AST_MATCHER(CXXNewExpr, isArray) { return Node.isArray(); }
/// Matches placement new expression arguments.
///
@@ -8663,9 +8580,7 @@ AST_MATCHER_P(CXXNewExpr, hasArraySize, internal::Matcher<Expr>, InnerMatcher) {
/// class x {};
/// class y;
/// \endcode
-AST_MATCHER(CXXRecordDecl, hasDefinition) {
- return Node.hasDefinition();
-}
+AST_MATCHER(CXXRecordDecl, hasDefinition) { return Node.hasDefinition(); }
/// Matches C++11 scoped enum declaration.
///
@@ -8674,9 +8589,7 @@ AST_MATCHER(CXXRecordDecl, hasDefinition) {
/// enum X {};
/// enum class Y {};
/// \endcode
-AST_MATCHER(EnumDecl, isScoped) {
- return Node.isScoped();
-}
+AST_MATCHER(EnumDecl, isScoped) { return Node.isScoped(); }
/// Matches a function declared with a trailing return type.
///
More information about the cfe-commits
mailing list