llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Baranov Victor (vbvictor) <details> <summary>Changes</summary> Reformat with clang-format. This commit will be added to blame-ignore-revs to not disturb meaningful history. --- Patch is 44.19 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/203766.diff 1 Files Affected: - (modified) clang/include/clang/ASTMatchers/ASTMatchers.h (+165-252) ``````````diff 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_M... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/203766 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
