14 #ifndef LLVM_CLANG_AST_STMTCXX_H
15 #define LLVM_CLANG_AST_STMTCXX_H
21 #include "llvm/Support/Compiler.h"
38 :
Stmt(CXXCatchStmtClass), CatchLoc(catchLoc), ExceptionDecl(exDecl),
39 HandlerBlock(handlerBlock) {}
42 :
Stmt(CXXCatchStmtClass), ExceptionDecl(nullptr), HandlerBlock(nullptr) {}
46 return HandlerBlock->getLocEnd();
55 return T->getStmtClass() == CXXCatchStmtClass;
58 child_range
children() {
return child_range(&HandlerBlock, &HandlerBlock+1); }
71 CXXTryStmt(EmptyShell Empty,
unsigned numHandlers)
72 :
Stmt(CXXTryStmtClass), NumHandlers(numHandlers) { }
74 Stmt const *
const *getStmts()
const {
75 return reinterpret_cast<Stmt const * const*
>(
this + 1);
78 return reinterpret_cast<Stmt **
>(
this + 1);
86 unsigned numHandlers);
93 return getStmts()[NumHandlers]->getLocEnd();
97 return cast<CompoundStmt>(getStmts()[0]);
100 return cast<CompoundStmt>(getStmts()[0]);
105 return cast<CXXCatchStmt>(getStmts()[i + 1]);
108 return cast<CXXCatchStmt>(getStmts()[i + 1]);
112 return T->getStmtClass() == CXXTryStmtClass;
116 return child_range(getStmts(), getStmts() +
getNumHandlers() + 1);
130 enum { RANGE, BEGINSTMT, ENDSTMT, COND, INC, LOOPVAR, BODY, END };
156 return cast_or_null<DeclStmt>(SubExprs[BEGINSTMT]);
165 return cast<DeclStmt>(SubExprs[RANGE]);
168 return cast_or_null<DeclStmt>(SubExprs[BEGINSTMT]);
171 return cast_or_null<DeclStmt>(SubExprs[ENDSTMT]);
174 return cast_or_null<Expr>(SubExprs[COND]);
177 return cast_or_null<Expr>(SubExprs[INC]);
180 return cast<DeclStmt>(SubExprs[LOOPVAR]);
200 return SubExprs[BODY]->getLocEnd();
204 return T->getStmtClass() == CXXForRangeStmtClass;
209 return child_range(&SubExprs[0], &SubExprs[END]);
255 :
Stmt(MSDependentExistsStmtClass),
256 KeywordLoc(KeywordLoc), IsIfExists(IsIfExists),
257 QualifierLoc(QualifierLoc), NameInfo(NameInfo),
258 SubStmt(reinterpret_cast<
Stmt *>(SubStmt)) { }
288 return child_range(&SubStmt, &SubStmt+1);
292 return T->getStmtClass() == MSDependentExistsStmtClass;
310 Stmt *SubStmts[SubStmt::FirstParamMove];
315 Stmt *FinalSuspend,
Stmt *OnException,
Stmt *OnFallthrough,
317 :
Stmt(CoroutineBodyStmtClass) {
318 SubStmts[CoroutineBodyStmt::Body] = Body;
319 SubStmts[CoroutineBodyStmt::Promise] = Promise;
320 SubStmts[CoroutineBodyStmt::InitSuspend] = InitSuspend;
321 SubStmts[CoroutineBodyStmt::FinalSuspend] = FinalSuspend;
322 SubStmts[CoroutineBodyStmt::OnException] = OnException;
323 SubStmts[CoroutineBodyStmt::OnFallthrough] = OnFallthrough;
324 SubStmts[CoroutineBodyStmt::ReturnValue] = ReturnValue;
326 assert(ParamMoves.empty() &&
"not implemented yet");
332 return SubStmts[SubStmt::Body];
345 return SubStmts[SubStmt::OnFallthrough];
349 return cast<Expr>(SubStmts[SubStmt::ReturnValue]);
353 return getBody()->getLocStart();
360 return child_range(SubStmts, SubStmts + SubStmt::FirstParamMove);
364 return T->getStmtClass() == CoroutineBodyStmtClass;
382 enum SubStmt { Operand, PromiseCall, Count };
388 :
Stmt(CoreturnStmtClass), CoreturnLoc(CoreturnLoc) {
389 SubStmts[SubStmt::Operand] = Operand;
390 SubStmts[SubStmt::PromiseCall] = PromiseCall;
403 return static_cast<Expr*
>(SubStmts[PromiseCall]);
416 return T->getStmtClass() == CoreturnStmtClass;
void setRangeStmt(Stmt *S)
CXXCatchStmt(SourceLocation catchLoc, VarDecl *exDecl, Stmt *handlerBlock)
SourceLocation getLocStart() const LLVM_READONLY
A (possibly-)qualified type.
CXXForRangeStmt(EmptyShell Empty)
static bool classof(const Stmt *T)
Represents a 'co_return' statement in the C++ Coroutines TS.
CXXCatchStmt * getHandler(unsigned i)
static bool classof(const Stmt *T)
SourceLocation getCoawaitLoc() const
const DeclStmt * getBeginStmt() const
SourceLocation getLocEnd() const LLVM_READONLY
VarDecl - An instance of this class is created to represent a variable declaration or definition...
static bool classof(const Stmt *T)
SourceLocation getLocStart() const LLVM_READONLY
const Stmt * getBody() const
void setBeginStmt(Stmt *S)
const Expr * getInc() const
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
SourceLocation getLocStart() const LLVM_READONLY
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.
void setRangeInit(Expr *E)
Stmt * getFinalSuspendStmt() const
Stmt * getFallthroughHandler() const
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we're testing for, along with location information.
static bool classof(const Stmt *T)
Stmt * getHandlerBlock() const
Expr * getPromiseCall() const
Retrieve the promise call that results from this 'co_return' statement.
static CXXTryStmt * Create(const ASTContext &C, SourceLocation tryLoc, Stmt *tryBlock, ArrayRef< Stmt * > handlers)
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
SourceLocation getKeywordLoc() const
VarDecl * getPromiseDecl() const
const CXXCatchStmt * getHandler(unsigned i) const
SourceLocation getEndLoc() const
SourceLocation getTryLoc() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
Stmt * getPromiseDeclStmt() const
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getLocEnd() const LLVM_READONLY
Expr * getReturnValueInit() const
Expr - This represents one expression.
CXXTryStmt - A C++ try block, including all handlers.
SourceLocation getLocStart() const LLVM_READONLY
const DeclStmt * getLoopVarStmt() const
Stmt * getInitSuspendStmt() const
SourceLocation getKeywordLoc() const
Retrieve the location of the __if_exists or __if_not_exists keyword.
MSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, CompoundStmt *SubStmt)
Encodes a location in the source.
const DeclStmt * getEndStmt() const
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
const DeclStmt * getRangeStmt() const
SourceLocation getLocEnd() const LLVM_READONLY
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Expr * getOperand() const
Retrieve the operand of the 'co_return' statement.
SourceLocation getLocEnd() const LLVM_READONLY
static bool classof(const Stmt *T)
static bool classof(const Stmt *T)
SourceLocation getLocEnd() const LLVM_READONLY
SourceLocation getLocEnd() const LLVM_READONLY
SourceLocation getForLoc() const
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
CoreturnStmt(SourceLocation CoreturnLoc, Stmt *Operand, Stmt *PromiseCall)
CXXForRangeStmt(DeclStmt *Range, DeclStmt *Begin, DeclStmt *End, Expr *Cond, Expr *Inc, DeclStmt *LoopVar, Stmt *Body, SourceLocation FL, SourceLocation CAL, SourceLocation CL, SourceLocation RPL)
Stmt * getBody() const
Retrieve the body of the coroutine as written.
Reads an AST files chain containing the contents of a translation unit.
unsigned getNumHandlers() const
QualType getCaughtType() const
detail::InMemoryDirectory::const_iterator E
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Represents the body of a coroutine.
Stmt * getExceptionHandler() const
DeclStmt * getRangeStmt()
const CompoundStmt * getTryBlock() const
CXXCatchStmt - This represents a C++ catch block.
VarDecl * getLoopVariable()
CompoundStmt * getTryBlock()
bool isIfNotExists() const
Determine whether this is an __if_exists statement.
CXXCatchStmt(EmptyShell Empty)
const Expr * getCond() const
void setLoopVarStmt(Stmt *S)
bool isIfExists() const
Determine whether this is an __if_exists statement.
SourceLocation getColonLoc() const
VarDecl * getExceptionDecl() const
DeclStmt * getLoopVarStmt()
SourceLocation getRParenLoc() const
DeclStmt * getBeginStmt()
CoroutineBodyStmt(Stmt *Body, Stmt *Promise, Stmt *InitSuspend, Stmt *FinalSuspend, Stmt *OnException, Stmt *OnFallthrough, Expr *ReturnValue, ArrayRef< Expr * > ParamMoves)
SourceLocation ColonLoc
Location of ':'.
SourceLocation getCatchLoc() const
SourceLocation getLocStart() const LLVM_READONLY