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) {}
54 return T->getStmtClass() == CXXCatchStmtClass;
69 private llvm::TrailingObjects<CXXTryStmt, Stmt *> {
71 friend TrailingObjects;
76 size_t numTrailingObjects(OverloadToken<Stmt *>)
const {
return NumHandlers; }
81 :
Stmt(CXXTryStmtClass), NumHandlers(numHandlers) { }
83 Stmt *
const *getStmts()
const {
return getTrailingObjects<Stmt *>(); }
84 Stmt **getStmts() {
return getTrailingObjects<Stmt *>(); }
87 static CXXTryStmt *
Create(
const ASTContext &
C, SourceLocation tryLoc,
88 CompoundStmt *tryBlock, ArrayRef<Stmt *> handlers);
90 static CXXTryStmt *
Create(
const ASTContext &
C, EmptyShell
Empty,
91 unsigned numHandlers);
97 return getStmts()[NumHandlers]->
getEndLoc();
101 return cast<CompoundStmt>(getStmts()[0]);
104 return cast<CompoundStmt>(getStmts()[0]);
109 return cast<CXXCatchStmt>(getStmts()[i + 1]);
112 return cast<CXXCatchStmt>(getStmts()[i + 1]);
116 return T->getStmtClass() == CXXTryStmtClass;
137 enum { INIT, RANGE, BEGINSTMT, ENDSTMT, COND, INC, LOOPVAR, BODY, END };
164 return cast_or_null<DeclStmt>(SubExprs[BEGINSTMT]);
173 return cast<DeclStmt>(SubExprs[RANGE]);
176 return cast_or_null<DeclStmt>(SubExprs[BEGINSTMT]);
179 return cast_or_null<DeclStmt>(SubExprs[ENDSTMT]);
182 return cast_or_null<Expr>(SubExprs[COND]);
185 return cast_or_null<Expr>(SubExprs[INC]);
188 return cast<DeclStmt>(SubExprs[LOOPVAR]);
213 return T->getStmtClass() == CXXForRangeStmtClass;
268 :
Stmt(MSDependentExistsStmtClass),
269 KeywordLoc(KeywordLoc), IsIfExists(IsIfExists),
270 QualifierLoc(QualifierLoc), NameInfo(NameInfo),
271 SubStmt(reinterpret_cast<
Stmt *>(SubStmt)) { }
311 return T->getStmtClass() == MSDependentExistsStmtClass;
320 private llvm::TrailingObjects<CoroutineBodyStmt, Stmt *> {
333 ReturnStmtOnAllocFailure,
340 friend TrailingObjects;
342 Stmt **getStoredStmts() {
return getTrailingObjects<Stmt *>(); }
344 Stmt *
const *getStoredStmts()
const {
return getTrailingObjects<Stmt *>(); }
381 return cast<CompoundStmt>(getStoredStmts()[SubStmt::Body]);
385 return getStoredStmts()[SubStmt::Promise];
392 return getStoredStmts()[SubStmt::InitSuspend];
395 return getStoredStmts()[SubStmt::FinalSuspend];
399 return getStoredStmts()[SubStmt::OnException];
402 return getStoredStmts()[SubStmt::OnFallthrough];
406 return cast_or_null<Expr>(getStoredStmts()[SubStmt::Allocate]);
409 return cast_or_null<Expr>(getStoredStmts()[SubStmt::Deallocate]);
413 return cast<Expr>(getStoredStmts()[SubStmt::ReturnValue]);
416 auto *RS = dyn_cast_or_null<clang::ReturnStmt>(
getReturnStmt());
417 return RS ? RS->getRetValue() :
nullptr;
421 return getStoredStmts()[SubStmt::ReturnStmtOnAllocFailure];
424 return {getStoredStmts() + SubStmt::FirstParamMove, NumParams};
437 getStoredStmts() + SubStmt::FirstParamMove + NumParams);
442 SubStmt::FirstParamMove +
447 return child_range(getStoredStmts() + SubStmt::Body + 1,
448 getStoredStmts() + SubStmt::FirstParamMove + NumParams);
453 getStoredStmts() + SubStmt::FirstParamMove +
458 return T->getStmtClass() == CoroutineBodyStmtClass;
476 enum SubStmt { Operand, PromiseCall, Count };
477 Stmt *SubStmts[SubStmt::Count];
484 bool IsImplicit =
false)
485 :
Stmt(CoreturnStmtClass), CoreturnLoc(CoreturnLoc),
486 IsImplicit(IsImplicit) {
487 SubStmts[SubStmt::Operand] = Operand;
488 SubStmts[SubStmt::PromiseCall] = PromiseCall;
503 return static_cast<Expr*
>(SubStmts[PromiseCall]);
515 return child_range(SubStmts, SubStmts + SubStmt::Count);
523 return T->getStmtClass() == CoreturnStmtClass;
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Reads an AST files chain containing the contents of a translation unit.
CXXCatchStmt - This represents a C++ catch block.
SourceLocation getEndLoc() const LLVM_READONLY
CXXCatchStmt(SourceLocation catchLoc, VarDecl *exDecl, Stmt *handlerBlock)
SourceLocation getCatchLoc() const
Stmt * getHandlerBlock() const
SourceLocation getBeginLoc() const LLVM_READONLY
CXXCatchStmt(EmptyShell Empty)
static bool classof(const Stmt *T)
const_child_range children() const
VarDecl * getExceptionDecl() const
QualType getCaughtType() const
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
void setLoopVarStmt(Stmt *S)
void setRangeStmt(Stmt *S)
DeclStmt * getBeginStmt()
DeclStmt * getLoopVarStmt()
const DeclStmt * getRangeStmt() const
SourceLocation getForLoc() const
const DeclStmt * getEndStmt() const
DeclStmt * getRangeStmt()
const DeclStmt * getBeginStmt() const
const Expr * getCond() const
SourceLocation getRParenLoc() const
const Expr * getInc() const
SourceLocation getColonLoc() const
void setBeginStmt(Stmt *S)
const_child_range children() const
VarDecl * getLoopVariable()
SourceLocation getEndLoc() const LLVM_READONLY
CXXForRangeStmt(EmptyShell Empty)
const Stmt * getBody() const
SourceLocation getCoawaitLoc() const
static bool classof(const Stmt *T)
const DeclStmt * getLoopVarStmt() const
void setRangeInit(Expr *E)
const Stmt * getInit() const
SourceLocation getBeginLoc() const LLVM_READONLY
CXXTryStmt - A C++ try block, including all handlers.
SourceLocation getTryLoc() const
const CXXCatchStmt * getHandler(unsigned i) const
static bool classof(const Stmt *T)
const_child_range children() const
CXXCatchStmt * getHandler(unsigned i)
unsigned getNumHandlers() const
SourceLocation getEndLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
const CompoundStmt * getTryBlock() const
CompoundStmt * getTryBlock()
CompoundStmt - This represents a group of statements like { stmt stmt }.
SourceLocation getBeginLoc() const
SourceLocation getEndLoc() const
Represents a 'co_return' statement in the C++ Coroutines TS.
Expr * getOperand() const
Retrieve the operand of the 'co_return' statement.
void setIsImplicit(bool value=true)
Expr * getPromiseCall() const
Retrieve the promise call that results from this 'co_return' statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getKeywordLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
CoreturnStmt(SourceLocation CoreturnLoc, Stmt *Operand, Stmt *PromiseCall, bool IsImplicit=false)
static bool classof(const Stmt *T)
const_child_range children() const
Represents the body of a coroutine.
CompoundStmt * getBody() const
Retrieve the body of the coroutine as written.
static bool classof(const Stmt *T)
Stmt * getReturnStmtOnAllocFailure() const
Expr * getReturnValueInit() const
Stmt * getReturnStmt() const
bool hasDependentPromiseType() const
Stmt * getResultDecl() const
child_range childrenExclBody()
Stmt * getInitSuspendStmt() const
Expr * getAllocate() const
Stmt * getPromiseDeclStmt() const
VarDecl * getPromiseDecl() const
Expr * getDeallocate() const
Stmt * getFallthroughHandler() const
Stmt * getExceptionHandler() const
SourceLocation getBeginLoc() const LLVM_READONLY
Expr * getReturnValue() const
SourceLocation getEndLoc() const LLVM_READONLY
Stmt * getFinalSuspendStmt() const
const_child_range children() const
ArrayRef< Stmt const * > getParamMoves() const
const_child_range childrenExclBody() const
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
This represents one expression.
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
bool isIfExists() const
Determine whether this is an __if_exists statement.
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we're testing for, along with location information.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getKeywordLoc() const
Retrieve the location of the __if_exists or __if_not_exists keyword.
static bool classof(const Stmt *T)
bool isIfNotExists() const
Determine whether this is an __if_exists statement.
const_child_range children() const
MSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, CompoundStmt *SubStmt)
SourceLocation getBeginLoc() const LLVM_READONLY
A C++ nested-name-specifier augmented with source location information.
A (possibly-)qualified type.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Encodes a location in the source.
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
llvm::iterator_range< child_iterator > child_range
llvm::iterator_range< const_child_iterator > const_child_range
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Represents a variable declaration or definition.
The JSON file list parser is used to communicate input to InstallAPI.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
const FunctionProtoType * T
Stmt * ReturnStmtOnAllocFailure
ArrayRef< Stmt * > ParamMoves
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....