13 #ifndef LLVM_CLANG_AST_STMTCXX_H 14 #define LLVM_CLANG_AST_STMTCXX_H 20 #include "llvm/Support/Compiler.h" 37 :
Stmt(CXXCatchStmtClass), CatchLoc(catchLoc), ExceptionDecl(exDecl),
38 HandlerBlock(handlerBlock) {}
41 :
Stmt(CXXCatchStmtClass), ExceptionDecl(nullptr), HandlerBlock(nullptr) {}
76 size_t numTrailingObjects(OverloadToken<Stmt *>)
const {
return NumHandlers; }
80 :
Stmt(CXXTryStmtClass), NumHandlers(numHandlers) { }
82 Stmt *
const *getStmts()
const {
return getTrailingObjects<Stmt *>(); }
83 Stmt **getStmts() {
return getTrailingObjects<Stmt *>(); }
90 unsigned numHandlers);
96 return getStmts()[NumHandlers]->getEndLoc();
100 return cast<CompoundStmt>(getStmts()[0]);
103 return cast<CompoundStmt>(getStmts()[0]);
108 return cast<CXXCatchStmt>(getStmts()[i + 1]);
111 return cast<CXXCatchStmt>(getStmts()[i + 1]);
119 return child_range(getStmts(), getStmts() + getNumHandlers() + 1);
136 enum { INIT,
RANGE, BEGINSTMT, ENDSTMT, COND, INC, LOOPVAR, BODY, END };
154 Expr *getRangeInit();
157 const VarDecl *getLoopVariable()
const;
158 const Expr *getRangeInit()
const;
163 return cast_or_null<DeclStmt>(SubExprs[BEGINSTMT]);
172 return cast<DeclStmt>(SubExprs[
RANGE]);
175 return cast_or_null<DeclStmt>(SubExprs[BEGINSTMT]);
178 return cast_or_null<DeclStmt>(SubExprs[ENDSTMT]);
181 return cast_or_null<Expr>(SubExprs[COND]);
184 return cast_or_null<Expr>(SubExprs[INC]);
187 return cast<DeclStmt>(SubExprs[LOOPVAR]);
267 :
Stmt(MSDependentExistsStmtClass),
268 KeywordLoc(KeywordLoc), IsIfExists(IsIfExists),
269 QualifierLoc(QualifierLoc), NameInfo(NameInfo),
270 SubStmt(reinterpret_cast<
Stmt *>(SubStmt)) { }
332 ReturnStmtOnAllocFailure,
341 Stmt **getStoredStmts() {
return getTrailingObjects<Stmt *>(); }
343 Stmt *
const *getStoredStmts()
const {
return getTrailingObjects<Stmt *>(); }
350 Expr *InitialSuspend =
nullptr;
359 Stmt *ReturnStmtOnAllocFailure =
nullptr;
373 return getPromiseDecl()->getType()->isDependentType();
379 return getStoredStmts()[SubStmt::Body];
383 return getStoredStmts()[SubStmt::Promise];
386 return cast<VarDecl>(cast<DeclStmt>(getPromiseDeclStmt())->getSingleDecl());
390 return getStoredStmts()[SubStmt::InitSuspend];
393 return getStoredStmts()[SubStmt::FinalSuspend];
397 return getStoredStmts()[SubStmt::OnException];
400 return getStoredStmts()[SubStmt::OnFallthrough];
404 return cast_or_null<Expr>(getStoredStmts()[SubStmt::Allocate]);
407 return cast_or_null<Expr>(getStoredStmts()[SubStmt::Deallocate]);
410 return cast<Expr>(getStoredStmts()[SubStmt::ReturnValue]);
415 return getStoredStmts()[SubStmt::ReturnStmtOnAllocFailure];
418 return {getStoredStmts() + SubStmt::FirstParamMove, NumParams};
422 return getBody() ? getBody()->getBeginLoc()
423 : getPromiseDecl()->getBeginLoc();
426 return getBody() ? getBody()->getEndLoc() : getPromiseDecl()->getEndLoc();
431 getStoredStmts() + SubStmt::FirstParamMove + NumParams);
436 SubStmt::FirstParamMove +
459 enum SubStmt { Operand, PromiseCall, Count };
460 Stmt *SubStmts[SubStmt::Count];
467 bool IsImplicit =
false)
468 :
Stmt(CoreturnStmtClass), CoreturnLoc(CoreturnLoc),
469 IsImplicit(IsImplicit) {
470 SubStmts[SubStmt::Operand] = Operand;
471 SubStmts[SubStmt::PromiseCall] = PromiseCall;
486 return static_cast<Expr*
>(SubStmts[PromiseCall]);
494 return getOperand() ? getOperand()->getEndLoc() :
getBeginLoc();
499 return child_range(SubStmts + SubStmt::PromiseCall,
500 SubStmts + SubStmt::Count);
501 return child_range(SubStmts, SubStmts + SubStmt::Count);
507 SubStmts + SubStmt::Count);
void setRangeStmt(Stmt *S)
CXXCatchStmt(SourceLocation catchLoc, VarDecl *exDecl, Stmt *handlerBlock)
SourceLocation getForLoc() const
const DeclStmt * getRangeStmt() const
A (possibly-)qualified type.
const CompoundStmt * getTryBlock() const
CXXForRangeStmt(EmptyShell Empty)
static bool classof(const Stmt *T)
Represents a 'co_return' statement in the C++ Coroutines TS.
Stmt - This represents one statement.
CXXCatchStmt * getHandler(unsigned i)
Stmt * getHandlerBlock() const
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we're testing for, along with location information.
const_child_range children() const
Stmt * getPromiseDeclStmt() const
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
llvm::iterator_range< child_iterator > child_range
static bool classof(const Stmt *T)
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getCoawaitLoc() const
Stmt * getExceptionHandler() const
Expr * getDeallocate() const
Represents a variable declaration or definition.
static bool classof(const Stmt *T)
Stmt * getResultDecl() const
void setBeginStmt(Stmt *S)
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getKeywordLoc() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
QualType getCaughtType() const
void setRangeInit(Expr *E)
const DeclStmt * getLoopVarStmt() const
void setIsImplicit(bool value=true)
VarDecl * getPromiseDecl() const
SourceLocation getEndLoc() const LLVM_READONLY
static bool classof(const Stmt *T)
SourceLocation getCatchLoc() const
const_child_range children() const
ArrayRef< Stmt const * > getParamMoves() const
SourceLocation getRParenLoc() const
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
SourceLocation getEndLoc() const LLVM_READONLY
const_child_range children() const
const CXXCatchStmt * getHandler(unsigned i) const
Stmt * getReturnStmt() const
llvm::iterator_range< const_child_iterator > const_child_range
CompoundStmt - This represents a group of statements like { stmt stmt }.
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getTryLoc() const
This represents one expression.
VarDecl * getExceptionDecl() const
bool isIfNotExists() const
Determine whether this is an __if_exists statement.
const_child_range children() const
CXXTryStmt - A C++ try block, including all handlers.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getKeywordLoc() const
Retrieve the location of the __if_exists or __if_not_exists keyword.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
SourceLocation getEndLoc() const LLVM_READONLY
MSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, CompoundStmt *SubStmt)
SourceLocation getBeginLoc() const LLVM_READONLY
Encodes a location in the source.
unsigned getNumHandlers() const
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
SourceLocation getBeginLoc() const LLVM_READONLY
static bool classof(const Stmt *T)
ArrayRef< Stmt * > ParamMoves
static bool classof(const Stmt *T)
const_child_range children() const
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
SourceLocation getEndLoc() const LLVM_READONLY
Dataflow Directional Tag Classes.
CoreturnStmt(SourceLocation CoreturnLoc, Stmt *Operand, Stmt *PromiseCall, bool IsImplicit=false)
Stmt * getReturnStmtOnAllocFailure() const
Expr * getAllocate() const
SourceLocation getEndLoc() const LLVM_READONLY
bool hasDependentPromiseType() const
Reads an AST files chain containing the contents of a translation unit.
Expr * getReturnValueInit() const
StmtClass getStmtClass() const
Expr * getOperand() const
Retrieve the operand of the 'co_return' statement.
Stmt * getInitSuspendStmt() const
bool isIfExists() const
Determine whether this is an __if_exists statement.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Represents the body of a coroutine.
const_child_range children() const
const Stmt * getInit() const
const Expr * getInc() const
const DeclStmt * getBeginStmt() const
DeclStmt * getRangeStmt()
const DeclStmt * getEndStmt() const
const Stmt * getBody() const
Expr * getPromiseCall() const
Retrieve the promise call that results from this 'co_return' statement.
Stmt * getFallthroughHandler() const
SourceLocation getColonLoc() const
CXXCatchStmt - This represents a C++ catch block.
CompoundStmt * getTryBlock()
CXXCatchStmt(EmptyShell Empty)
void setLoopVarStmt(Stmt *S)
Stmt * getBody() const
Retrieve the body of the coroutine as written.
SourceLocation getEndLoc() const
DeclStmt * getLoopVarStmt()
DeclStmt * getBeginStmt()
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation ColonLoc
Location of ':'.
const Expr * getCond() const
Stmt * getFinalSuspendStmt() const
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.