This revision was automatically updated to reflect the committed changes. Closed by commit rC358288: [AST][NFC] Add const children() accessors to all AST nodes (authored by brunoricci, committed by ).
Changed prior to commit: https://reviews.llvm.org/D60029?vs=193288&id=194897#toc Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60029/new/ https://reviews.llvm.org/D60029 Files: include/clang/AST/Expr.h include/clang/AST/ExprCXX.h include/clang/AST/ExprObjC.h include/clang/AST/ExprOpenMP.h include/clang/AST/OpenMPClause.h include/clang/AST/Stmt.h include/clang/AST/StmtCXX.h include/clang/AST/StmtObjC.h include/clang/AST/StmtOpenMP.h lib/AST/ExprObjC.cpp lib/AST/Stmt.cpp
Index: include/clang/AST/ExprCXX.h =================================================================== --- include/clang/AST/ExprCXX.h +++ include/clang/AST/ExprCXX.h @@ -587,6 +587,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// The null pointer literal (C++11 [lex.nullptr]) @@ -616,6 +620,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// Implicit construction of a std::initializer_list<T> object from an @@ -658,6 +666,10 @@ } child_range children() { return child_range(&SubExpr, &SubExpr + 1); } + + const_child_range children() const { + return const_child_range(&SubExpr, &SubExpr + 1); + } }; /// A C++ \c typeid expression (C++ [expr.typeid]), which gets @@ -748,6 +760,15 @@ auto **begin = reinterpret_cast<Stmt **>(&Operand); return child_range(begin, begin + 1); } + + const_child_range children() const { + if (isTypeOperand()) + return const_child_range(const_child_iterator(), const_child_iterator()); + + auto **begin = + reinterpret_cast<Stmt **>(&const_cast<CXXTypeidExpr *>(this)->Operand); + return const_child_range(begin, begin + 1); + } }; /// A member reference to an MSPropertyDecl. @@ -802,6 +823,11 @@ return child_range((Stmt**)&BaseExpr, (Stmt**)&BaseExpr + 1); } + const_child_range children() const { + auto Children = const_cast<MSPropertyRefExpr *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == MSPropertyRefExprClass; } @@ -877,6 +903,10 @@ child_range children() { return child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS); } + + const_child_range children() const { + return const_child_range(&SubExprs[0], &SubExprs[0] + NUM_SUBEXPRS); + } }; /// A Microsoft C++ @c __uuidof expression, which gets @@ -958,6 +988,14 @@ auto **begin = reinterpret_cast<Stmt **>(&Operand); return child_range(begin, begin + 1); } + + const_child_range children() const { + if (isTypeOperand()) + return const_child_range(const_child_iterator(), const_child_iterator()); + auto **begin = + reinterpret_cast<Stmt **>(&const_cast<CXXUuidofExpr *>(this)->Operand); + return const_child_range(begin, begin + 1); + } }; /// Represents the \c this expression in C++. @@ -1004,6 +1042,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// A C++ throw-expression (C++ [except.throw]). @@ -1062,6 +1104,10 @@ child_range children() { return child_range(&Operand, Operand ? &Operand + 1 : &Operand); } + + const_child_range children() const { + return const_child_range(&Operand, Operand ? &Operand + 1 : &Operand); + } }; /// A default argument (C++ [dcl.fct.default]). @@ -1123,6 +1169,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// A use of a default initializer in a constructor or in aggregate @@ -1178,6 +1228,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// Represents a C++ temporary. @@ -1255,6 +1309,10 @@ // Iterators child_range children() { return child_range(&SubExpr, &SubExpr + 1); } + + const_child_range children() const { + return const_child_range(&SubExpr, &SubExpr + 1); + } }; /// Represents a call to a C++ constructor. @@ -1438,6 +1496,11 @@ child_range children() { return child_range(getTrailingArgs(), getTrailingArgs() + getNumArgs()); } + + const_child_range children() const { + auto Children = const_cast<CXXConstructExpr *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } }; /// Represents a call to an inherited base class constructor from an @@ -1506,6 +1569,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// Represents an explicit C++ type conversion that uses "functional" @@ -1863,6 +1930,11 @@ // Includes initialization exprs plus body stmt return child_range(getStoredStmts(), getStoredStmts() + NumCaptures + 1); } + + const_child_range children() const { + return const_child_range(getStoredStmts(), + getStoredStmts() + NumCaptures + 1); + } }; /// An expression "T()" which creates a value-initialized rvalue of type @@ -1906,6 +1978,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// Represents a new-expression for memory allocation and constructor @@ -2162,6 +2238,10 @@ // Iterators child_range children() { return child_range(raw_arg_begin(), raw_arg_end()); } + + const_child_range children() const { + return const_child_range(const_cast<CXXNewExpr *>(this)->children()); + } }; /// Represents a \c delete expression for memory deallocation and @@ -2228,6 +2308,10 @@ // Iterators child_range children() { return child_range(&Argument, &Argument + 1); } + + const_child_range children() const { + return const_child_range(&Argument, &Argument + 1); + } }; /// Stores the type being destroyed by a pseudo-destructor expression. @@ -2416,6 +2500,10 @@ // Iterators child_range children() { return child_range(&Base, &Base + 1); } + + const_child_range children() const { + return const_child_range(&Base, &Base + 1); + } }; /// A type trait used in the implementation of various C++11 and @@ -2500,6 +2588,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// An Embarcadero array type trait, as used in the implementation of @@ -2567,6 +2659,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// An expression trait intrinsic. @@ -2627,6 +2723,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// A reference to an overloaded function set, either an @@ -2919,6 +3019,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == UnresolvedLookupExprClass; } @@ -3073,6 +3177,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// Represents an expression -- generally a full-expression -- that @@ -3142,6 +3250,10 @@ // Iterators child_range children() { return child_range(&SubExpr, &SubExpr + 1); } + + const_child_range children() const { + return const_child_range(&SubExpr, &SubExpr + 1); + } }; /// Describes an explicit type conversion that uses functional @@ -3271,6 +3383,12 @@ auto **begin = reinterpret_cast<Stmt **>(arg_begin()); return child_range(begin, begin + arg_size()); } + + const_child_range children() const { + auto **begin = reinterpret_cast<Stmt **>( + const_cast<CXXUnresolvedConstructExpr *>(this)->arg_begin()); + return const_child_range(begin, begin + arg_size()); + } }; /// Represents a C++ member access expression where the actual @@ -3517,6 +3635,12 @@ return child_range(child_iterator(), child_iterator()); return child_range(&Base, &Base + 1); } + + const_child_range children() const { + if (isImplicitAccess()) + return const_child_range(const_child_iterator(), const_child_iterator()); + return const_child_range(&Base, &Base + 1); + } }; /// Represents a C++ member access expression for which lookup @@ -3680,6 +3804,12 @@ return child_range(child_iterator(), child_iterator()); return child_range(&Base, &Base + 1); } + + const_child_range children() const { + if (isImplicitAccess()) + return const_child_range(const_child_iterator(), const_child_iterator()); + return const_child_range(&Base, &Base + 1); + } }; DeclAccessPair *OverloadExpr::getTrailingResults() { @@ -3749,6 +3879,10 @@ // Iterators child_range children() { return child_range(&Operand, &Operand + 1); } + + const_child_range children() const { + return const_child_range(&Operand, &Operand + 1); + } }; /// Represents a C++11 pack expansion that produces a sequence of @@ -3829,6 +3963,10 @@ child_range children() { return child_range(&Pattern, &Pattern + 1); } + + const_child_range children() const { + return const_child_range(&Pattern, &Pattern + 1); + } }; /// Represents an expression that computes the length of a parameter @@ -3950,6 +4088,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// Represents a reference to a non-type template parameter @@ -3996,6 +4138,10 @@ // Iterators child_range children() { return child_range(&Replacement, &Replacement + 1); } + + const_child_range children() const { + return const_child_range(&Replacement, &Replacement + 1); + } }; /// Represents a reference to a non-type template parameter pack that @@ -4058,6 +4204,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// Represents a reference to a function parameter pack that has been @@ -4130,6 +4280,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// Represents a prvalue temporary that is written into memory so that @@ -4252,6 +4406,15 @@ auto ES = State.get<ExtraState *>(); return child_range(&ES->Temporary, &ES->Temporary + 1); } + + const_child_range children() const { + if (State.is<Stmt *>()) + return const_child_range(State.getAddrOfPtr1(), + State.getAddrOfPtr1() + 1); + + auto ES = State.get<ExtraState *>(); + return const_child_range(&ES->Temporary, &ES->Temporary + 1); + } }; /// Represents a folding of a pack over an operator. @@ -4317,6 +4480,10 @@ // Iterators child_range children() { return child_range(SubExprs, SubExprs + 2); } + + const_child_range children() const { + return const_child_range(SubExprs, SubExprs + 2); + } }; /// Represents an expression that might suspend coroutine execution; @@ -4408,6 +4575,10 @@ return child_range(SubExprs, SubExprs + SubExpr::Count); } + const_child_range children() const { + return const_child_range(SubExprs, SubExprs + SubExpr::Count); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == CoawaitExprClass || T->getStmtClass() == CoyieldExprClass; @@ -4492,6 +4663,10 @@ child_range children() { return child_range(SubExprs, SubExprs + 2); } + const_child_range children() const { + return const_child_range(SubExprs, SubExprs + 2); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == DependentCoawaitExprClass; } Index: include/clang/AST/Stmt.h =================================================================== --- include/clang/AST/Stmt.h +++ include/clang/AST/Stmt.h @@ -1193,6 +1193,11 @@ child_iterator(DG.end(), DG.end())); } + const_child_range children() const { + auto Children = const_cast<DeclStmt *>(this)->children(); + return const_child_range(Children); + } + using decl_iterator = DeclGroupRef::iterator; using const_decl_iterator = DeclGroupRef::const_iterator; using decl_range = llvm::iterator_range<decl_iterator>; @@ -1250,6 +1255,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// CompoundStmt - This represents a group of statements like { stmt stmt }. @@ -1554,6 +1563,12 @@ getTrailingObjects<Stmt *>() + numTrailingObjects(OverloadToken<Stmt *>())); } + + const_child_range children() const { + return const_child_range(getTrailingObjects<Stmt *>(), + getTrailingObjects<Stmt *>() + + numTrailingObjects(OverloadToken<Stmt *>())); + } }; class DefaultStmt : public SwitchCase { @@ -1585,6 +1600,10 @@ // Iterators child_range children() { return child_range(&SubStmt, &SubStmt + 1); } + + const_child_range children() const { + return const_child_range(&SubStmt, &SubStmt + 1); + } }; SourceLocation SwitchCase::getEndLoc() const { @@ -1659,6 +1678,10 @@ child_range children() { return child_range(&SubStmt, &SubStmt + 1); } + const_child_range children() const { + return const_child_range(&SubStmt, &SubStmt + 1); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == LabelStmtClass; } @@ -1716,6 +1739,10 @@ child_range children() { return child_range(&SubStmt, &SubStmt + 1); } + const_child_range children() const { + return const_child_range(&SubStmt, &SubStmt + 1); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == AttributedStmtClass; } @@ -1915,6 +1942,12 @@ numTrailingObjects(OverloadToken<Stmt *>())); } + const_child_range children() const { + return const_child_range(getTrailingObjects<Stmt *>(), + getTrailingObjects<Stmt *>() + + numTrailingObjects(OverloadToken<Stmt *>())); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == IfStmtClass; } @@ -2092,6 +2125,12 @@ numTrailingObjects(OverloadToken<Stmt *>())); } + const_child_range children() const { + return const_child_range(getTrailingObjects<Stmt *>(), + getTrailingObjects<Stmt *>() + + numTrailingObjects(OverloadToken<Stmt *>())); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == SwitchStmtClass; } @@ -2217,6 +2256,12 @@ getTrailingObjects<Stmt *>() + numTrailingObjects(OverloadToken<Stmt *>())); } + + const_child_range children() const { + return const_child_range(getTrailingObjects<Stmt *>(), + getTrailingObjects<Stmt *>() + + numTrailingObjects(OverloadToken<Stmt *>())); + } }; /// DoStmt - This represents a 'do/while' stmt. @@ -2267,6 +2312,10 @@ child_range children() { return child_range(&SubExprs[0], &SubExprs[0] + END_EXPR); } + + const_child_range children() const { + return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR); + } }; /// ForStmt - This represents a 'for (init;cond;inc)' stmt. Note that any of @@ -2336,6 +2385,10 @@ child_range children() { return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR); } + + const_child_range children() const { + return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR); + } }; /// GotoStmt - This represents a direct goto. @@ -2371,6 +2424,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// IndirectGotoStmt - This represents an indirect goto. @@ -2416,6 +2473,10 @@ // Iterators child_range children() { return child_range(&Target, &Target + 1); } + + const_child_range children() const { + return const_child_range(&Target, &Target + 1); + } }; /// ContinueStmt - This represents a continue. @@ -2442,6 +2503,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// BreakStmt - This represents a break. @@ -2468,6 +2533,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// ReturnStmt - This represents a return, optionally of an expression: @@ -2552,6 +2621,12 @@ return child_range(&RetExpr, &RetExpr + 1); return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + if (RetExpr) + return const_child_range(&RetExpr, &RetExpr + 1); + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// AsmStmt is the base class for GCCAsmStmt and MSAsmStmt. @@ -2707,6 +2782,10 @@ child_range children() { return child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs); } + + const_child_range children() const { + return const_child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs); + } }; /// This represents a GCC inline-assembly statement extension. @@ -2983,6 +3062,10 @@ child_range children() { return child_range(&Exprs[0], &Exprs[NumInputs + NumOutputs]); } + + const_child_range children() const { + return const_child_range(&Exprs[0], &Exprs[NumInputs + NumOutputs]); + } }; class SEHExceptStmt : public Stmt { @@ -3020,6 +3103,10 @@ return child_range(Children, Children+2); } + const_child_range children() const { + return const_child_range(Children, Children + 2); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == SEHExceptStmtClass; } @@ -3051,6 +3138,10 @@ return child_range(&Block,&Block+1); } + const_child_range children() const { + return const_child_range(&Block, &Block + 1); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == SEHFinallyStmtClass; } @@ -3099,6 +3190,10 @@ return child_range(Children, Children+2); } + const_child_range children() const { + return const_child_range(Children, Children + 2); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == SEHTryStmtClass; } @@ -3129,6 +3224,10 @@ child_range children() { return child_range(child_iterator(), child_iterator()); } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } }; /// This captures a statement into a function. For example, the following @@ -3349,6 +3448,8 @@ } child_range children(); + + const_child_range children() const; }; } // namespace clang Index: include/clang/AST/Expr.h =================================================================== --- include/clang/AST/Expr.h +++ include/clang/AST/Expr.h @@ -1870,6 +1870,11 @@ return child_range(getTrailingObjects<Stmt *>(), getTrailingObjects<Stmt *>() + hasFunctionName()); } + + const_child_range children() const { + return const_child_range(getTrailingObjects<Stmt *>(), + getTrailingObjects<Stmt *>() + hasFunctionName()); + } }; /// ParenExpr - This represents a parethesized expression, e.g. "(1)". This Index: include/clang/AST/StmtObjC.h =================================================================== --- include/clang/AST/StmtObjC.h +++ include/clang/AST/StmtObjC.h @@ -67,6 +67,10 @@ child_range children() { return child_range(&SubExprs[0], &SubExprs[END_EXPR]); } + + const_child_range children() const { + return const_child_range(&SubExprs[0], &SubExprs[END_EXPR]); + } }; /// Represents Objective-C's \@catch statement. @@ -113,6 +117,10 @@ } child_range children() { return child_range(&Body, &Body + 1); } + + const_child_range children() const { + return const_child_range(&Body, &Body + 1); + } }; /// Represents Objective-C's \@finally statement @@ -147,6 +155,10 @@ child_range children() { return child_range(&AtFinallyStmt, &AtFinallyStmt+1); } + + const_child_range children() const { + return const_child_range(&AtFinallyStmt, &AtFinallyStmt + 1); + } }; /// Represents Objective-C's \@try ... \@catch ... \@finally statement. @@ -248,6 +260,10 @@ return child_range(getStmts(), getStmts() + 1 + NumCatchStmts + HasFinally); } + + const_child_range children() const { + return const_child_range(const_cast<ObjCAtTryStmt *>(this)->children()); + } }; /// Represents Objective-C's \@synchronized statement. @@ -306,6 +322,10 @@ child_range children() { return child_range(&SubStmts[0], &SubStmts[0]+END_EXPR); } + + const_child_range children() const { + return const_child_range(&SubStmts[0], &SubStmts[0] + END_EXPR); + } }; /// Represents Objective-C's \@throw statement. @@ -338,6 +358,10 @@ } child_range children() { return child_range(&Throw, &Throw+1); } + + const_child_range children() const { + return const_child_range(&Throw, &Throw + 1); + } }; /// Represents Objective-C's \@autoreleasepool Statement @@ -369,6 +393,10 @@ } child_range children() { return child_range(&SubStmt, &SubStmt + 1); } + + const_child_range children() const { + return const_child_range(&SubStmt, &SubStmt + 1); + } }; } // end namespace clang Index: include/clang/AST/ExprOpenMP.h =================================================================== --- include/clang/AST/ExprOpenMP.h +++ include/clang/AST/ExprOpenMP.h @@ -122,6 +122,10 @@ child_range children() { return child_range(&SubExprs[BASE], &SubExprs[END_EXPR]); } + + const_child_range children() const { + return const_child_range(&SubExprs[BASE], &SubExprs[END_EXPR]); + } }; } // end namespace clang Index: include/clang/AST/OpenMPClause.h =================================================================== --- include/clang/AST/OpenMPClause.h +++ include/clang/AST/OpenMPClause.h @@ -290,6 +290,10 @@ child_range children() { return child_range(&Allocator, &Allocator + 1); } + const_child_range children() const { + return const_child_range(&Allocator, &Allocator + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_allocator; } @@ -375,6 +379,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPAllocateClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_allocate; } @@ -465,6 +474,10 @@ child_range children() { return child_range(&Condition, &Condition + 1); } + const_child_range children() const { + return const_child_range(&Condition, &Condition + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_if; } @@ -516,6 +529,10 @@ child_range children() { return child_range(&Condition, &Condition + 1); } + const_child_range children() const { + return const_child_range(&Condition, &Condition + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_final; } @@ -577,6 +594,10 @@ child_range children() { return child_range(&NumThreads, &NumThreads + 1); } + const_child_range children() const { + return const_child_range(&NumThreads, &NumThreads + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_num_threads; } @@ -632,6 +653,10 @@ child_range children() { return child_range(&Safelen, &Safelen + 1); } + const_child_range children() const { + return const_child_range(&Safelen, &Safelen + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_safelen; } @@ -686,6 +711,10 @@ child_range children() { return child_range(&Simdlen, &Simdlen + 1); } + const_child_range children() const { + return const_child_range(&Simdlen, &Simdlen + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_simdlen; } @@ -741,6 +770,10 @@ child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); } + const_child_range children() const { + return const_child_range(&NumForLoops, &NumForLoops + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_collapse; } @@ -809,6 +842,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_default; } @@ -879,6 +916,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_proc_bind; } @@ -910,6 +951,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_unified_address; } @@ -941,6 +986,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_unified_shared_memory; } @@ -972,6 +1021,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_reverse_offload; } @@ -1004,6 +1057,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_dynamic_allocators; } @@ -1083,6 +1140,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_atomic_default_mem_order; } @@ -1264,6 +1325,11 @@ reinterpret_cast<Stmt **>(&ChunkSize) + 1); } + const_child_range children() const { + auto Children = const_cast<OMPScheduleClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_schedule; } @@ -1349,6 +1415,10 @@ child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); } + const_child_range children() const { + return const_child_range(&NumForLoops, &NumForLoops + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_ordered; } @@ -1377,6 +1447,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_nowait; } @@ -1405,6 +1479,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_untied; } @@ -1434,6 +1512,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_mergeable; } @@ -1461,6 +1543,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_read; } @@ -1489,6 +1575,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_write; } @@ -1518,6 +1608,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_update; } @@ -1547,6 +1641,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_capture; } @@ -1576,6 +1674,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_seq_cst; } @@ -1669,6 +1771,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPPrivateClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_private; } @@ -1796,6 +1903,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPFirstprivateClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_firstprivate; } @@ -1995,6 +2107,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPLastprivateClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_lastprivate; } @@ -2055,6 +2172,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPSharedClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_shared; } @@ -2277,6 +2399,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPReductionClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_reduction; } @@ -2497,6 +2624,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPTaskReductionClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_task_reduction; } @@ -2740,6 +2872,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPInReductionClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_in_reduction; } @@ -2979,6 +3116,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPLinearClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_linear; } @@ -3066,6 +3208,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPAlignedClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_aligned; } @@ -3230,6 +3377,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPCopyinClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_copyin; } @@ -3381,6 +3533,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPCopyprivateClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_copyprivate; } @@ -3446,6 +3603,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPFlushClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_flush; } @@ -3565,6 +3727,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPDependClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_depend; } @@ -3628,6 +3795,10 @@ child_range children() { return child_range(&Device, &Device + 1); } + const_child_range children() const { + return const_child_range(&Device, &Device + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_device; } @@ -3656,6 +3827,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_threads; } @@ -3683,6 +3858,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_simd; } @@ -4515,6 +4694,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPMapClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_map; } @@ -4579,6 +4763,10 @@ child_range children() { return child_range(&NumTeams, &NumTeams + 1); } + const_child_range children() const { + return const_child_range(&NumTeams, &NumTeams + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_num_teams; } @@ -4644,6 +4832,10 @@ child_range children() { return child_range(&ThreadLimit, &ThreadLimit + 1); } + const_child_range children() const { + return const_child_range(&ThreadLimit, &ThreadLimit + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_thread_limit; } @@ -4701,6 +4893,10 @@ child_range children() { return child_range(&Priority, &Priority + 1); } + const_child_range children() const { + return const_child_range(&Priority, &Priority + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_priority; } @@ -4752,6 +4948,10 @@ child_range children() { return child_range(&Grainsize, &Grainsize + 1); } + const_child_range children() const { + return const_child_range(&Grainsize, &Grainsize + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_grainsize; } @@ -4780,6 +4980,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_nogroup; } @@ -4831,6 +5035,10 @@ child_range children() { return child_range(&NumTasks, &NumTasks + 1); } + const_child_range children() const { + return const_child_range(&NumTasks, &NumTasks + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_num_tasks; } @@ -4881,6 +5089,10 @@ child_range children() { return child_range(&Hint, &Hint + 1); } + const_child_range children() const { + return const_child_range(&Hint, &Hint + 1); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_hint; } @@ -4988,6 +5200,11 @@ reinterpret_cast<Stmt **>(&ChunkSize) + 1); } + const_child_range children() const { + auto Children = const_cast<OMPDistScheduleClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_dist_schedule; } @@ -5089,6 +5306,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_defaultmap; } @@ -5194,6 +5415,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPToClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_to; } @@ -5300,6 +5526,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPFromClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_from; } @@ -5451,6 +5682,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPUseDevicePtrClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_use_device_ptr; } @@ -5542,6 +5778,11 @@ reinterpret_cast<Stmt **>(varlist_end())); } + const_child_range children() const { + auto Children = const_cast<OMPIsDevicePtrClause *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const OMPClause *T) { return T->getClauseKind() == OMPC_is_device_ptr; } Index: include/clang/AST/ExprObjC.h =================================================================== --- include/clang/AST/ExprObjC.h +++ include/clang/AST/ExprObjC.h @@ -72,6 +72,10 @@ // Iterators child_range children() { return child_range(&String, &String+1); } + const_child_range children() const { + return const_child_range(&String, &String + 1); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCStringLiteralClass; } @@ -104,6 +108,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCBoolLiteralExprClass; } @@ -156,6 +164,10 @@ // Iterators child_range children() { return child_range(&SubExpr, &SubExpr+1); } + const_child_range children() const { + return const_child_range(&SubExpr, &SubExpr + 1); + } + using const_arg_iterator = ConstExprIterator; const_arg_iterator arg_begin() const { @@ -234,6 +246,11 @@ reinterpret_cast<Stmt **>(getElements()) + NumElements); } + const_child_range children() const { + auto Children = const_cast<ObjCArrayLiteral *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCArrayLiteralClass; } @@ -374,6 +391,11 @@ NumElements * 2); } + const_child_range children() const { + auto Children = const_cast<ObjCDictionaryLiteral *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCDictionaryLiteralClass; } @@ -419,6 +441,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCEncodeExprClass; } @@ -457,6 +483,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCSelectorExprClass; } @@ -503,6 +533,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCProtocolExprClass; } @@ -566,6 +600,10 @@ // Iterators child_range children() { return child_range(&Base, &Base+1); } + const_child_range children() const { + return const_child_range(&Base, &Base + 1); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCIvarRefExprClass; } @@ -757,6 +795,11 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + auto Children = const_cast<ObjCPropertyRefExpr *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCPropertyRefExprClass; } @@ -866,6 +909,10 @@ return child_range(SubExprs, SubExprs+END_EXPR); } + const_child_range children() const { + return const_child_range(SubExprs, SubExprs + END_EXPR); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCSubscriptRefExprClass; } @@ -1408,6 +1455,8 @@ // Iterators child_range children(); + const_child_range children() const; + using arg_iterator = ExprIterator; using const_arg_iterator = ConstExprIterator; @@ -1494,6 +1543,10 @@ // Iterators child_range children() { return child_range(&Base, &Base+1); } + const_child_range children() const { + return const_child_range(&Base, &Base + 1); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCIsaExprClass; } @@ -1555,6 +1608,10 @@ child_range children() { return child_range(&Operand, &Operand+1); } + const_child_range children() const { + return const_child_range(&Operand, &Operand + 1); + } + // Source locations are determined by the subexpression. SourceLocation getBeginLoc() const LLVM_READONLY { return Operand->getBeginLoc(); @@ -1667,6 +1724,10 @@ return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCAvailabilityCheckExprClass; } Index: include/clang/AST/StmtCXX.h =================================================================== --- include/clang/AST/StmtCXX.h +++ include/clang/AST/StmtCXX.h @@ -56,6 +56,10 @@ child_range children() { return child_range(&HandlerBlock, &HandlerBlock+1); } + const_child_range children() const { + return const_child_range(&HandlerBlock, &HandlerBlock + 1); + } + friend class ASTStmtReader; }; @@ -114,6 +118,10 @@ child_range children() { return child_range(getStmts(), getStmts() + getNumHandlers() + 1); } + + const_child_range children() const { + return const_child_range(getStmts(), getStmts() + getNumHandlers() + 1); + } }; /// CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for @@ -208,6 +216,10 @@ child_range children() { return child_range(&SubExprs[0], &SubExprs[END]); } + + const_child_range children() const { + return const_child_range(&SubExprs[0], &SubExprs[END]); + } }; /// Representation of a Microsoft __if_exists or __if_not_exists @@ -290,6 +302,10 @@ return child_range(&SubStmt, &SubStmt+1); } + const_child_range children() const { + return const_child_range(&SubStmt, &SubStmt + 1); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == MSDependentExistsStmtClass; } @@ -415,6 +431,12 @@ getStoredStmts() + SubStmt::FirstParamMove + NumParams); } + const_child_range children() const { + return const_child_range(getStoredStmts(), getStoredStmts() + + SubStmt::FirstParamMove + + NumParams); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == CoroutineBodyStmtClass; } @@ -479,6 +501,13 @@ return child_range(SubStmts, SubStmts + SubStmt::Count); } + const_child_range children() const { + if (!getOperand()) + return const_child_range(SubStmts + SubStmt::PromiseCall, + SubStmts + SubStmt::Count); + return const_child_range(SubStmts, SubStmts + SubStmt::Count); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == CoreturnStmtClass; } Index: include/clang/AST/StmtOpenMP.h =================================================================== --- include/clang/AST/StmtOpenMP.h +++ include/clang/AST/StmtOpenMP.h @@ -256,6 +256,14 @@ return child_range(ChildStorage, ChildStorage + 1); } + const_child_range children() const { + if (!hasAssociatedStmt()) + return const_child_range(const_child_iterator(), const_child_iterator()); + Stmt **ChildStorage = reinterpret_cast<Stmt **>( + const_cast<OMPExecutableDirective *>(this)->getClauses().end()); + return const_child_range(ChildStorage, ChildStorage + 1); + } + ArrayRef<OMPClause *> clauses() { return getClauses(); } ArrayRef<OMPClause *> clauses() const { Index: lib/AST/Stmt.cpp =================================================================== --- lib/AST/Stmt.cpp +++ lib/AST/Stmt.cpp @@ -1254,6 +1254,10 @@ return child_range(getStoredStmts(), getStoredStmts() + NumCaptures); } +Stmt::const_child_range CapturedStmt::children() const { + return const_child_range(getStoredStmts(), getStoredStmts() + NumCaptures); +} + CapturedDecl *CapturedStmt::getCapturedDecl() { return CapDeclAndKind.getPointer(); } Index: lib/AST/ExprObjC.cpp =================================================================== --- lib/AST/ExprObjC.cpp +++ lib/AST/ExprObjC.cpp @@ -377,6 +377,11 @@ reinterpret_cast<Stmt **>(getArgs() + getNumArgs())); } +Stmt::const_child_range ObjCMessageExpr::children() const { + auto Children = const_cast<ObjCMessageExpr *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); +} + StringRef ObjCBridgedCastExpr::getBridgeKindName() const { switch (getBridgeKind()) { case OBC_Bridge:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits