Go to the documentation of this file.
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) {}
69 private llvm::TrailingObjects<CXXTryStmt, Stmt *> {
71 friend TrailingObjects;
76 size_t numTrailingObjects(OverloadToken<Stmt *>)
const {
return NumHandlers; }
79 CXXTryStmt(EmptyShell Empty,
unsigned numHandlers)
80 :
Stmt(CXXTryStmtClass), NumHandlers(numHandlers) { }
82 Stmt *
const *getStmts()
const {
return getTrailingObjects<Stmt *>(); }
83 Stmt **getStmts() {
return getTrailingObjects<Stmt *>(); }
86 static CXXTryStmt *
Create(
const ASTContext &
C, SourceLocation tryLoc,
87 Stmt *tryBlock, ArrayRef<Stmt*> handlers);
89 static CXXTryStmt *
Create(
const ASTContext &
C, EmptyShell Empty,
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]);
136 enum { INIT, RANGE, BEGINSTMT, ENDSTMT, COND, INC, LOOPVAR, BODY, END };
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)) { }
319 private llvm::TrailingObjects<CoroutineBodyStmt, Stmt *> {
331 ReturnStmtOnAllocFailure,
338 friend TrailingObjects;
340 Stmt **getStoredStmts() {
return getTrailingObjects<Stmt *>(); }
342 Stmt *
const *getStoredStmts()
const {
return getTrailingObjects<Stmt *>(); }
377 return getStoredStmts()[SubStmt::Body];
381 return getStoredStmts()[SubStmt::Promise];
388 return getStoredStmts()[SubStmt::InitSuspend];
391 return getStoredStmts()[SubStmt::FinalSuspend];
395 return getStoredStmts()[SubStmt::OnException];
398 return getStoredStmts()[SubStmt::OnFallthrough];
402 return cast_or_null<Expr>(getStoredStmts()[SubStmt::Allocate]);
405 return cast_or_null<Expr>(getStoredStmts()[SubStmt::Deallocate]);
413 return RS->getRetValue();
417 return getStoredStmts()[SubStmt::ReturnStmtOnAllocFailure];
420 return {getStoredStmts() + SubStmt::FirstParamMove, NumParams};
433 getStoredStmts() + SubStmt::FirstParamMove + NumParams);
438 SubStmt::FirstParamMove +
461 enum SubStmt { Operand, PromiseCall, Count };
462 Stmt *SubStmts[SubStmt::Count];
469 bool IsImplicit =
false)
470 :
Stmt(CoreturnStmtClass), CoreturnLoc(CoreturnLoc),
471 IsImplicit(IsImplicit) {
472 SubStmts[SubStmt::Operand] = Operand;
473 SubStmts[SubStmt::PromiseCall] = PromiseCall;
488 return static_cast<Expr*
>(SubStmts[PromiseCall]);
501 return child_range(SubStmts + SubStmt::PromiseCall,
502 SubStmts + SubStmt::Count);
503 return child_range(SubStmts, SubStmts + SubStmt::Count);
509 SubStmts + SubStmt::Count);
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
QualType getCaughtType() const
CoreturnStmt(SourceLocation CoreturnLoc, Stmt *Operand, Stmt *PromiseCall, bool IsImplicit=false)
ArrayRef< Stmt * > ParamMoves
SourceLocation getBeginLoc() const LLVM_READONLY
static bool classof(const Stmt *T)
SourceLocation getBeginLoc() const LLVM_READONLY
CXXForRangeStmt(Stmt *InitStmt, DeclStmt *Range, DeclStmt *Begin, DeclStmt *End, Expr *Cond, Expr *Inc, DeclStmt *LoopVar, Stmt *Body, SourceLocation FL, SourceLocation CAL, SourceLocation CL, SourceLocation RPL)
Stmt * getReturnStmt() const
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getEndLoc() const LLVM_READONLY
MSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, CompoundStmt *SubStmt)
unsigned getNumHandlers() const
CXXCatchStmt(EmptyShell Empty)
SourceLocation getKeywordLoc() const
Encodes a location in the source.
SourceLocation getEndLoc() const LLVM_READONLY
Expr * getPromiseCall() const
Retrieve the promise call that results from this 'co_return' statement.
static bool classof(const Stmt *T)
CXXCatchStmt(SourceLocation catchLoc, VarDecl *exDecl, Stmt *handlerBlock)
A (possibly-)qualified type.
bool hasDependentPromiseType() const
SourceLocation getCoawaitLoc() const
Expr * getReturnValue() const
DeclStmt * getBeginStmt()
const DeclStmt * getRangeStmt() const
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we're testing for, along with location information.
CXXCatchStmt * getHandler(unsigned i)
Represents a 'co_return' statement in the C++ Coroutines TS.
Stmt * getBody() const
Retrieve the body of the coroutine as written.
const DeclStmt * getLoopVarStmt() const
SourceLocation getEndLoc() const
static CoroutineBodyStmt * Create(const ASTContext &C, CtorArgs const &Args)
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
SourceLocation getRParenLoc() const
void setRangeStmt(Stmt *S)
Stmt * getHandlerBlock() const
Expr * getAllocate() const
const Stmt * getInit() const
static bool classof(const Stmt *T)
CompoundStmt - This represents a group of statements like { stmt stmt }.
void setIsImplicit(bool value=true)
Stmt * getInitSuspendStmt() const
bool ReturnValue(const T &V, APValue &R)
Convert a value to an APValue.
static CXXTryStmt * Create(const ASTContext &C, SourceLocation tryLoc, Stmt *tryBlock, ArrayRef< Stmt * > handlers)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const CXXCatchStmt * getHandler(unsigned i) const
SourceLocation getCatchLoc() const
Stmt * getFinalSuspendStmt() const
const_child_range children() const
Stmt * getReturnStmtOnAllocFailure() const
DeclStmt * getRangeStmt()
Expr * getReturnValueInit() const
static bool classof(const Stmt *T)
const Expr * getCond() const
SourceLocation getEndLoc() const LLVM_READONLY
const_child_range children() const
Represents a variable declaration or definition.
Stmt * getExceptionHandler() const
Expr * getDeallocate() const
SourceLocation getKeywordLoc() const
Retrieve the location of the __if_exists or __if_not_exists keyword.
CompoundStmt * getTryBlock()
CXXTryStmt - A C++ try block, including all handlers.
A C++ nested-name-specifier augmented with source location information.
void setBeginStmt(Stmt *S)
llvm::iterator_range< child_iterator > child_range
VarDecl * getLoopVariable()
Expr * getOperand() const
Retrieve the operand of the 'co_return' statement.
const Stmt * getBody() const
llvm::iterator_range< const_child_iterator > const_child_range
SourceLocation getBeginLoc() const LLVM_READONLY
static bool classof(const Stmt *T)
Stmt * getFallthroughHandler() const
const DeclStmt * getBeginStmt() const
SourceLocation getColonLoc() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
StmtClass getStmtClass() const
SourceLocation getEndLoc() const LLVM_READONLY
DeclStmt * getLoopVarStmt()
bool isIfNotExists() const
Determine whether this is an __if_exists statement.
void setLoopVarStmt(Stmt *S)
bool isIfExists() const
Determine whether this is an __if_exists statement.
Represents the body of a coroutine.
Stmt * getPromiseDeclStmt() const
ArrayRef< Stmt const * > getParamMoves() const
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Reads an AST files chain containing the contents of a translation unit.
const_child_range children() const
static bool classof(const Stmt *T)
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
const DeclStmt * getEndStmt() const
SourceLocation getForLoc() const
SourceLocation getEndLoc() const LLVM_READONLY
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
const CompoundStmt * getTryBlock() const
CXXCatchStmt - This represents a C++ catch block.
VarDecl * getPromiseDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
const_child_range children() const
SourceLocation getTryLoc() const
const Expr * getInc() const
This represents one expression.
VarDecl * getExceptionDecl() const
CXXForRangeStmt(EmptyShell Empty)
Stmt * ReturnStmtOnAllocFailure
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
const_child_range children() const
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getEndLoc() const LLVM_READONLY
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
const_child_range children() const
void setRangeInit(Expr *E)
SourceLocation getBeginLoc() const LLVM_READONLY