clang: lib/AST/StmtCXX.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

14

16

17using namespace clang;

18

20 if (ExceptionDecl)

21 return ExceptionDecl->getType();

23}

24

28 const size_t Size = totalSizeToAlloc<Stmt *>(handlers.size() + 1);

29 void *Mem = C.Allocate(Size, alignof(CXXTryStmt));

30 return new (Mem) CXXTryStmt(tryLoc, tryBlock, handlers);

31}

32

34 unsigned numHandlers) {

35 const size_t Size = totalSizeToAlloc<Stmt *>(numHandlers + 1);

36 void *Mem = C.Allocate(Size, alignof(CXXTryStmt));

38}

39

42 : Stmt(CXXTryStmtClass), TryLoc(tryLoc), NumHandlers(handlers.size()) {

43 Stmt **Stmts = getStmts();

44 Stmts[0] = tryBlock;

45 std::copy(handlers.begin(), handlers.end(), Stmts + 1);

46}

47

54 : Stmt(CXXForRangeStmtClass), ForLoc(FL), CoawaitLoc(CAL), ColonLoc(CL),

55 RParenLoc(RPL) {

56 SubExprs[INIT] = Init;

57 SubExprs[RANGE] = Range;

58 SubExprs[BEGINSTMT] = BeginStmt;

59 SubExprs[ENDSTMT] = EndStmt;

60 SubExprs[COND] = Cond;

61 SubExprs[INC] = Inc;

62 SubExprs[LOOPVAR] = LoopVar;

63 SubExprs[BODY] = Body;

64}

65

69 assert(RangeDecl && "for-range should have a single var decl");

70 return RangeDecl->getInit();

71}

72

75}

76

79 assert(LV && "No loop variable in CXXForRangeStmt");

80 return cast(LV);

81}

82

85}

86

89 std::size_t Size = totalSizeToAlloc<Stmt *>(

90 CoroutineBodyStmt::FirstParamMove + Args.ParamMoves.size());

91

94}

95

97 unsigned NumParams) {

98 std::size_t Size = totalSizeToAlloc<Stmt *>(

99 CoroutineBodyStmt::FirstParamMove + NumParams);

100

103 Result->NumParams = NumParams;

104 auto *ParamBegin = Result->getStoredStmts() + SubStmt::FirstParamMove;

105 std::uninitialized_fill(ParamBegin, ParamBegin + NumParams,

106 static_cast<Stmt *>(nullptr));

108}

109

111 : Stmt(CoroutineBodyStmtClass), NumParams(Args.ParamMoves.size()) {

112 Stmt **SubStmts = getStoredStmts();

113 SubStmts[CoroutineBodyStmt::Body] = Args.Body;

114 SubStmts[CoroutineBodyStmt::Promise] = Args.Promise;

115 SubStmts[CoroutineBodyStmt::InitSuspend] = Args.InitialSuspend;

116 SubStmts[CoroutineBodyStmt::FinalSuspend] = Args.FinalSuspend;

117 SubStmts[CoroutineBodyStmt::OnException] = Args.OnException;

118 SubStmts[CoroutineBodyStmt::OnFallthrough] = Args.OnFallthrough;

119 SubStmts[CoroutineBodyStmt::Allocate] = Args.Allocate;

120 SubStmts[CoroutineBodyStmt::Deallocate] = Args.Deallocate;

121 SubStmts[CoroutineBodyStmt::ResultDecl] = Args.ResultDecl;

122 SubStmts[CoroutineBodyStmt::ReturnValue] = Args.ReturnValue;

123 SubStmts[CoroutineBodyStmt::ReturnStmt] = Args.ReturnStmt;

124 SubStmts[CoroutineBodyStmt::ReturnStmtOnAllocFailure] =

128}

Defines the clang::ASTContext interface.

Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...

QualType getCaughtType() const

CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...

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)

DeclStmt * getLoopVarStmt()

DeclStmt * getRangeStmt()

VarDecl * getLoopVariable()

CXXTryStmt - A C++ try block, including all handlers.

static CXXTryStmt * Create(const ASTContext &C, SourceLocation tryLoc, CompoundStmt *tryBlock, ArrayRef< Stmt * > handlers)

CompoundStmt - This represents a group of statements like { stmt stmt }.

Represents the body of a coroutine.

static CoroutineBodyStmt * Create(const ASTContext &C, CtorArgs const &Args)

ArrayRef< Stmt const * > getParamMoves() const

DeclStmt - Adaptor class for mixing declarations with statements and expressions.

const Decl * getSingleDecl() const

Decl - This represents one declaration (or definition), e.g.

This represents one expression.

A (possibly-)qualified type.

Encodes a location in the source.

Stmt - This represents one statement.

Represents a variable declaration or definition.

const Expr * getInit() const

The JSON file list parser is used to communicate input to InstallAPI.

@ Result

The result type of a method or function.

Stmt * ReturnStmtOnAllocFailure

ArrayRef< Stmt * > ParamMoves

A placeholder type used to construct an empty shell of a type, that will be filled in later (e....