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) {}
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]);
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]);
255 :
Stmt(MSDependentExistsStmtClass),
256 KeywordLoc(KeywordLoc), IsIfExists(IsIfExists),
257 QualifierLoc(QualifierLoc), NameInfo(NameInfo),
258 SubStmt(reinterpret_cast<
Stmt *>(SubStmt)) { }
314 ReturnStmtOnAllocFailure,
323 Stmt **getStoredStmts() {
return getTrailingObjects<Stmt *>(); }
325 Stmt *
const *getStoredStmts()
const {
return getTrailingObjects<Stmt *>(); }
361 return getStoredStmts()[SubStmt::Body];
365 return getStoredStmts()[SubStmt::Promise];
372 return getStoredStmts()[SubStmt::InitSuspend];
375 return getStoredStmts()[SubStmt::FinalSuspend];
379 return getStoredStmts()[SubStmt::OnException];
382 return getStoredStmts()[SubStmt::OnFallthrough];
386 return cast_or_null<Expr>(getStoredStmts()[SubStmt::Allocate]);
389 return cast_or_null<Expr>(getStoredStmts()[SubStmt::Deallocate]);
392 return cast<Expr>(getStoredStmts()[SubStmt::ReturnValue]);
397 return getStoredStmts()[SubStmt::ReturnStmtOnAllocFailure];
400 return {getStoredStmts() + SubStmt::FirstParamMove, NumParams};
413 getStoredStmts() + SubStmt::FirstParamMove + NumParams);
435 enum SubStmt { Operand, PromiseCall, Count };
436 Stmt *SubStmts[SubStmt::Count];
443 bool IsImplicit =
false)
444 :
Stmt(CoreturnStmtClass), CoreturnLoc(CoreturnLoc),
445 IsImplicit(IsImplicit) {
446 SubStmts[SubStmt::Operand] = Operand;
447 SubStmts[SubStmt::PromiseCall] = PromiseCall;
452 SourceLocation getKeywordLoc()
const {
return CoreturnLoc; }
456 Expr *getOperand()
const {
return static_cast<Expr*
>(SubStmts[Operand]); }
461 Expr *getPromiseCall()
const {
462 return static_cast<Expr*
>(SubStmts[PromiseCall]);
465 bool isImplicit()
const {
return IsImplicit; }
466 void setIsImplicit(
bool value =
true) { IsImplicit = value; }
468 SourceLocation
getLocStart() const LLVM_READONLY {
return CoreturnLoc; }
469 SourceLocation
getLocEnd() const LLVM_READONLY {
470 return getOperand() ? getOperand()->getLocEnd() :
getLocStart();
475 return child_range(SubStmts + SubStmt::PromiseCall,
476 SubStmts + SubStmt::Count);
477 return child_range(SubStmts, SubStmts + SubStmt::Count);
481 return T->getStmtClass() == CoreturnStmtClass;
StmtClass getStmtClass() const
void setRangeStmt(Stmt *S)
CXXCatchStmt(SourceLocation catchLoc, VarDecl *exDecl, Stmt *handlerBlock)
Stmt * getReturnStmt() const
SourceLocation getLocStart() const LLVM_READONLY
A (possibly-)qualified type.
bool hasDependentPromiseType() 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)
static bool classof(const Stmt *T)
SourceLocation getCoawaitLoc() const
SourceLocation getLocEnd() const LLVM_READONLY
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)
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
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 * ReturnStmtOnAllocFailure
Stmt * getHandlerBlock() const
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...
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 getLocEnd() const LLVM_READONLY
SourceLocation getLocEnd() const LLVM_READONLY
Expr * getReturnValueInit() const
Expr - This represents one expression.
CXXTryStmt - A C++ try block, including all handlers.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
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.
Stmt * getReturnStmtOnAllocFailure() const
ArrayRef< Stmt const * > getParamMoves() const
static CoroutineBodyStmt * Create(const ASTContext &C, CtorArgs const &Args)
MSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, CompoundStmt *SubStmt)
Encodes a location in the source.
llvm::iterator_range< child_iterator > child_range
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. ...
SourceLocation getLocEnd() const LLVM_READONLY
ArrayRef< Stmt * > ParamMoves
static bool classof(const Stmt *T)
SourceLocation getLocEnd() const LLVM_READONLY
Expr * getDeallocate() const
Expr * getAllocate() const
SourceLocation getForLoc() 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...
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.
CoreturnStmt(SourceLocation CoreturnLoc, Stmt *Operand, Stmt *PromiseCall, bool IsImplicit=false)
Reads an AST files chain containing the contents of a translation unit.
unsigned getNumHandlers() const
QualType getCaughtType() const
SourceLocation getLocStart() const LLVM_READONLY
detail::InMemoryDirectory::const_iterator E
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Stmt * getResultDecl() const
Represents the body of a coroutine.
Stmt * getExceptionHandler() const
static bool classof(const OMPClause *T)
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()
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation ColonLoc
Location of ':'.
SourceLocation getCatchLoc() const
SourceLocation getLocStart() const LLVM_READONLY