1 //===--- Stmt.cpp - Statement AST Node Implementation ---------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the Stmt class and statement subclasses.
12 //===----------------------------------------------------------------------===//
14 #include "clang/AST/Stmt.h"
15 #include "clang/AST/ExprCXX.h"
16 #include "clang/AST/ExprObjC.h"
17 #include "clang/AST/StmtCXX.h"
18 #include "clang/AST/StmtObjC.h"
19 #include "clang/AST/Type.h"
20 #include "clang/AST/ASTContext.h"
21 #include "clang/AST/ASTDiagnostic.h"
22 #include "clang/Basic/TargetInfo.h"
23 #include "llvm/Support/raw_ostream.h"
24 using namespace clang;
26 static struct StmtClassNameTable {
30 } StmtClassInfo[Stmt::lastStmtConstant+1];
32 static StmtClassNameTable &getStmtInfoTableEntry(Stmt::StmtClass E) {
33 static bool Initialized = false;
35 return StmtClassInfo[E];
37 // Intialize the table on the first use.
39 #define ABSTRACT_STMT(STMT)
40 #define STMT(CLASS, PARENT) \
41 StmtClassInfo[(unsigned)Stmt::CLASS##Class].Name = #CLASS; \
42 StmtClassInfo[(unsigned)Stmt::CLASS##Class].Size = sizeof(CLASS);
43 #include "clang/AST/StmtNodes.inc"
45 return StmtClassInfo[E];
48 const char *Stmt::getStmtClassName() const {
49 return getStmtInfoTableEntry((StmtClass) StmtBits.sClass).Name;
52 void Stmt::PrintStats() {
53 // Ensure the table is primed.
54 getStmtInfoTableEntry(Stmt::NullStmtClass);
57 llvm::errs() << "\n*** Stmt/Expr Stats:\n";
58 for (int i = 0; i != Stmt::lastStmtConstant+1; i++) {
59 if (StmtClassInfo[i].Name == 0) continue;
60 sum += StmtClassInfo[i].Counter;
62 llvm::errs() << " " << sum << " stmts/exprs total.\n";
64 for (int i = 0; i != Stmt::lastStmtConstant+1; i++) {
65 if (StmtClassInfo[i].Name == 0) continue;
66 if (StmtClassInfo[i].Counter == 0) continue;
67 llvm::errs() << " " << StmtClassInfo[i].Counter << " "
68 << StmtClassInfo[i].Name << ", " << StmtClassInfo[i].Size
69 << " each (" << StmtClassInfo[i].Counter*StmtClassInfo[i].Size
71 sum += StmtClassInfo[i].Counter*StmtClassInfo[i].Size;
74 llvm::errs() << "Total bytes = " << sum << "\n";
77 void Stmt::addStmtClass(StmtClass s) {
78 ++getStmtInfoTableEntry(s).Counter;
81 static bool StatSwitch = false;
83 bool Stmt::CollectingStats(bool Enable) {
84 if (Enable) StatSwitch = true;
88 Stmt *Stmt::IgnoreImplicit() {
91 if (ExprWithCleanups *ewc = dyn_cast<ExprWithCleanups>(s))
92 s = ewc->getSubExpr();
94 while (ImplicitCastExpr *ice = dyn_cast<ImplicitCastExpr>(s))
95 s = ice->getSubExpr();
104 // These silly little functions have to be static inline to suppress
105 // unused warnings, and they have to be defined to suppress other
107 static inline good is_good(good) { return good(); }
109 typedef Stmt::child_range children_t();
110 template <class T> good implements_children(children_t T::*) {
113 static inline bad implements_children(children_t Stmt::*) {
117 typedef SourceRange getSourceRange_t() const;
118 template <class T> good implements_getSourceRange(getSourceRange_t T::*) {
121 static inline bad implements_getSourceRange(getSourceRange_t Stmt::*) {
125 #define ASSERT_IMPLEMENTS_children(type) \
126 (void) sizeof(is_good(implements_children(&type::children)))
127 #define ASSERT_IMPLEMENTS_getSourceRange(type) \
128 (void) sizeof(is_good(implements_getSourceRange(&type::getSourceRange)))
131 /// Check whether the various Stmt classes implement their member
133 static inline void check_implementations() {
134 #define ABSTRACT_STMT(type)
135 #define STMT(type, base) \
136 ASSERT_IMPLEMENTS_children(type); \
137 ASSERT_IMPLEMENTS_getSourceRange(type);
138 #include "clang/AST/StmtNodes.inc"
141 Stmt::child_range Stmt::children() {
142 switch (getStmtClass()) {
143 case Stmt::NoStmtClass: llvm_unreachable("statement without class");
144 #define ABSTRACT_STMT(type)
145 #define STMT(type, base) \
146 case Stmt::type##Class: \
147 return static_cast<type*>(this)->children();
148 #include "clang/AST/StmtNodes.inc"
150 llvm_unreachable("unknown statement kind!");
151 return child_range();
154 SourceRange Stmt::getSourceRange() const {
155 switch (getStmtClass()) {
156 case Stmt::NoStmtClass: llvm_unreachable("statement without class");
157 #define ABSTRACT_STMT(type)
158 #define STMT(type, base) \
159 case Stmt::type##Class: \
160 return static_cast<const type*>(this)->getSourceRange();
161 #include "clang/AST/StmtNodes.inc"
163 llvm_unreachable("unknown statement kind!");
164 return SourceRange();
167 void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) {
170 this->CompoundStmtBits.NumStmts = NumStmts;
172 Body = new (C) Stmt*[NumStmts];
173 memcpy(Body, Stmts, sizeof(Stmt *) * NumStmts);
176 const char *LabelStmt::getName() const {
177 return getDecl()->getIdentifier()->getNameStart();
180 // This is defined here to avoid polluting Stmt.h with importing Expr.h
181 SourceRange ReturnStmt::getSourceRange() const {
183 return SourceRange(RetLoc, RetExpr->getLocEnd());
185 return SourceRange(RetLoc);
188 bool Stmt::hasImplicitControlFlow() const {
189 switch (StmtBits.sClass) {
194 case ConditionalOperatorClass:
195 case ChooseExprClass:
200 case Stmt::BinaryOperatorClass: {
201 const BinaryOperator* B = cast<BinaryOperator>(this);
202 if (B->isLogicalOp() || B->getOpcode() == BO_Comma)
210 Expr *AsmStmt::getOutputExpr(unsigned i) {
211 return cast<Expr>(Exprs[i]);
214 /// getOutputConstraint - Return the constraint string for the specified
215 /// output operand. All output constraints are known to be non-empty (either
217 llvm::StringRef AsmStmt::getOutputConstraint(unsigned i) const {
218 return getOutputConstraintLiteral(i)->getString();
221 /// getNumPlusOperands - Return the number of output operands that have a "+"
223 unsigned AsmStmt::getNumPlusOperands() const {
225 for (unsigned i = 0, e = getNumOutputs(); i != e; ++i)
226 if (isOutputPlusConstraint(i))
231 Expr *AsmStmt::getInputExpr(unsigned i) {
232 return cast<Expr>(Exprs[i + NumOutputs]);
234 void AsmStmt::setInputExpr(unsigned i, Expr *E) {
235 Exprs[i + NumOutputs] = E;
239 /// getInputConstraint - Return the specified input constraint. Unlike output
240 /// constraints, these can be empty.
241 llvm::StringRef AsmStmt::getInputConstraint(unsigned i) const {
242 return getInputConstraintLiteral(i)->getString();
246 void AsmStmt::setOutputsAndInputsAndClobbers(ASTContext &C,
247 IdentifierInfo **Names,
248 StringLiteral **Constraints,
252 StringLiteral **Clobbers,
253 unsigned NumClobbers) {
254 this->NumOutputs = NumOutputs;
255 this->NumInputs = NumInputs;
256 this->NumClobbers = NumClobbers;
258 unsigned NumExprs = NumOutputs + NumInputs;
260 C.Deallocate(this->Names);
261 this->Names = new (C) IdentifierInfo*[NumExprs];
262 std::copy(Names, Names + NumExprs, this->Names);
264 C.Deallocate(this->Exprs);
265 this->Exprs = new (C) Stmt*[NumExprs];
266 std::copy(Exprs, Exprs + NumExprs, this->Exprs);
268 C.Deallocate(this->Constraints);
269 this->Constraints = new (C) StringLiteral*[NumExprs];
270 std::copy(Constraints, Constraints + NumExprs, this->Constraints);
272 C.Deallocate(this->Clobbers);
273 this->Clobbers = new (C) StringLiteral*[NumClobbers];
274 std::copy(Clobbers, Clobbers + NumClobbers, this->Clobbers);
277 /// getNamedOperand - Given a symbolic operand reference like %[foo],
278 /// translate this into a numeric value needed to reference the same operand.
279 /// This returns -1 if the operand name is invalid.
280 int AsmStmt::getNamedOperand(llvm::StringRef SymbolicName) const {
281 unsigned NumPlusOperands = 0;
283 // Check if this is an output operand.
284 for (unsigned i = 0, e = getNumOutputs(); i != e; ++i) {
285 if (getOutputName(i) == SymbolicName)
289 for (unsigned i = 0, e = getNumInputs(); i != e; ++i)
290 if (getInputName(i) == SymbolicName)
291 return getNumOutputs() + NumPlusOperands + i;
297 /// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing
298 /// it into pieces. If the asm string is erroneous, emit errors and return
299 /// true, otherwise return false.
300 unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces,
301 ASTContext &C, unsigned &DiagOffs) const {
302 llvm::StringRef Str = getAsmString()->getString();
303 const char *StrStart = Str.begin();
304 const char *StrEnd = Str.end();
305 const char *CurPtr = StrStart;
307 // "Simple" inline asms have no constraints or operands, just convert the asm
308 // string to escape $'s.
311 for (; CurPtr != StrEnd; ++CurPtr) {
321 Pieces.push_back(AsmStringPiece(Result));
325 // CurStringPiece - The current string that we are building up as we scan the
327 std::string CurStringPiece;
329 bool HasVariants = !C.Target.hasNoAsmVariants();
332 // Done with the string?
333 if (CurPtr == StrEnd) {
334 if (!CurStringPiece.empty())
335 Pieces.push_back(AsmStringPiece(CurStringPiece));
339 char CurChar = *CurPtr++;
341 case '$': CurStringPiece += "$$"; continue;
342 case '{': CurStringPiece += (HasVariants ? "$(" : "{"); continue;
343 case '|': CurStringPiece += (HasVariants ? "$|" : "|"); continue;
344 case '}': CurStringPiece += (HasVariants ? "$)" : "}"); continue;
348 CurStringPiece += CurChar;
352 // Escaped "%" character in asm string.
353 if (CurPtr == StrEnd) {
354 // % at end of string is invalid (no escape).
355 DiagOffs = CurPtr-StrStart-1;
356 return diag::err_asm_invalid_escape;
359 char EscapedChar = *CurPtr++;
360 if (EscapedChar == '%') { // %% -> %
361 // Escaped percentage sign.
362 CurStringPiece += '%';
366 if (EscapedChar == '=') { // %= -> Generate an unique ID.
367 CurStringPiece += "${:uid}";
371 // Otherwise, we have an operand. If we have accumulated a string so far,
372 // add it to the Pieces list.
373 if (!CurStringPiece.empty()) {
374 Pieces.push_back(AsmStringPiece(CurStringPiece));
375 CurStringPiece.clear();
378 // Handle %x4 and %x[foo] by capturing x as the modifier character.
379 char Modifier = '\0';
380 if (isalpha(EscapedChar)) {
381 if (CurPtr == StrEnd) { // Premature end.
382 DiagOffs = CurPtr-StrStart-1;
383 return diag::err_asm_invalid_escape;
385 Modifier = EscapedChar;
386 EscapedChar = *CurPtr++;
389 if (isdigit(EscapedChar)) {
390 // %n - Assembler operand n
394 while (CurPtr != StrEnd && isdigit(*CurPtr))
395 N = N*10 + ((*CurPtr++)-'0');
397 unsigned NumOperands =
398 getNumOutputs() + getNumPlusOperands() + getNumInputs();
399 if (N >= NumOperands) {
400 DiagOffs = CurPtr-StrStart-1;
401 return diag::err_asm_invalid_operand_number;
404 Pieces.push_back(AsmStringPiece(N, Modifier));
408 // Handle %[foo], a symbolic operand reference.
409 if (EscapedChar == '[') {
410 DiagOffs = CurPtr-StrStart-1;
413 const char *NameEnd = (const char*)memchr(CurPtr, ']', StrEnd-CurPtr);
415 return diag::err_asm_unterminated_symbolic_operand_name;
416 if (NameEnd == CurPtr)
417 return diag::err_asm_empty_symbolic_operand_name;
419 llvm::StringRef SymbolicName(CurPtr, NameEnd - CurPtr);
421 int N = getNamedOperand(SymbolicName);
423 // Verify that an operand with that name exists.
424 DiagOffs = CurPtr-StrStart;
425 return diag::err_asm_unknown_symbolic_operand_name;
427 Pieces.push_back(AsmStringPiece(N, Modifier));
433 DiagOffs = CurPtr-StrStart-1;
434 return diag::err_asm_invalid_escape;
438 QualType CXXCatchStmt::getCaughtType() const {
440 return ExceptionDecl->getType();
444 //===----------------------------------------------------------------------===//
446 //===----------------------------------------------------------------------===//
448 AsmStmt::AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple,
449 bool isvolatile, bool msasm,
450 unsigned numoutputs, unsigned numinputs,
451 IdentifierInfo **names, StringLiteral **constraints,
452 Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
453 StringLiteral **clobbers, SourceLocation rparenloc)
454 : Stmt(AsmStmtClass), AsmLoc(asmloc), RParenLoc(rparenloc), AsmStr(asmstr)
455 , IsSimple(issimple), IsVolatile(isvolatile), MSAsm(msasm)
456 , NumOutputs(numoutputs), NumInputs(numinputs), NumClobbers(numclobbers) {
458 unsigned NumExprs = NumOutputs +NumInputs;
460 Names = new (C) IdentifierInfo*[NumExprs];
461 std::copy(names, names + NumExprs, Names);
463 Exprs = new (C) Stmt*[NumExprs];
464 std::copy(exprs, exprs + NumExprs, Exprs);
466 Constraints = new (C) StringLiteral*[NumExprs];
467 std::copy(constraints, constraints + NumExprs, Constraints);
469 Clobbers = new (C) StringLiteral*[NumClobbers];
470 std::copy(clobbers, clobbers + NumClobbers, Clobbers);
473 ObjCForCollectionStmt::ObjCForCollectionStmt(Stmt *Elem, Expr *Collect,
474 Stmt *Body, SourceLocation FCL,
476 : Stmt(ObjCForCollectionStmtClass) {
477 SubExprs[ELEM] = Elem;
478 SubExprs[COLLECTION] = reinterpret_cast<Stmt*>(Collect);
479 SubExprs[BODY] = Body;
484 ObjCAtTryStmt::ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt,
485 Stmt **CatchStmts, unsigned NumCatchStmts,
487 : Stmt(ObjCAtTryStmtClass), AtTryLoc(atTryLoc),
488 NumCatchStmts(NumCatchStmts), HasFinally(atFinallyStmt != 0)
490 Stmt **Stmts = getStmts();
491 Stmts[0] = atTryStmt;
492 for (unsigned I = 0; I != NumCatchStmts; ++I)
493 Stmts[I + 1] = CatchStmts[I];
496 Stmts[NumCatchStmts + 1] = atFinallyStmt;
499 ObjCAtTryStmt *ObjCAtTryStmt::Create(ASTContext &Context,
500 SourceLocation atTryLoc,
503 unsigned NumCatchStmts,
504 Stmt *atFinallyStmt) {
505 unsigned Size = sizeof(ObjCAtTryStmt) +
506 (1 + NumCatchStmts + (atFinallyStmt != 0)) * sizeof(Stmt *);
507 void *Mem = Context.Allocate(Size, llvm::alignOf<ObjCAtTryStmt>());
508 return new (Mem) ObjCAtTryStmt(atTryLoc, atTryStmt, CatchStmts, NumCatchStmts,
512 ObjCAtTryStmt *ObjCAtTryStmt::CreateEmpty(ASTContext &Context,
513 unsigned NumCatchStmts,
515 unsigned Size = sizeof(ObjCAtTryStmt) +
516 (1 + NumCatchStmts + HasFinally) * sizeof(Stmt *);
517 void *Mem = Context.Allocate(Size, llvm::alignOf<ObjCAtTryStmt>());
518 return new (Mem) ObjCAtTryStmt(EmptyShell(), NumCatchStmts, HasFinally);
521 SourceRange ObjCAtTryStmt::getSourceRange() const {
522 SourceLocation EndLoc;
524 EndLoc = getFinallyStmt()->getLocEnd();
525 else if (NumCatchStmts)
526 EndLoc = getCatchStmt(NumCatchStmts - 1)->getLocEnd();
528 EndLoc = getTryBody()->getLocEnd();
530 return SourceRange(AtTryLoc, EndLoc);
533 CXXTryStmt *CXXTryStmt::Create(ASTContext &C, SourceLocation tryLoc,
534 Stmt *tryBlock, Stmt **handlers,
535 unsigned numHandlers) {
536 std::size_t Size = sizeof(CXXTryStmt);
537 Size += ((numHandlers + 1) * sizeof(Stmt));
539 void *Mem = C.Allocate(Size, llvm::alignOf<CXXTryStmt>());
540 return new (Mem) CXXTryStmt(tryLoc, tryBlock, handlers, numHandlers);
543 CXXTryStmt *CXXTryStmt::Create(ASTContext &C, EmptyShell Empty,
544 unsigned numHandlers) {
545 std::size_t Size = sizeof(CXXTryStmt);
546 Size += ((numHandlers + 1) * sizeof(Stmt));
548 void *Mem = C.Allocate(Size, llvm::alignOf<CXXTryStmt>());
549 return new (Mem) CXXTryStmt(Empty, numHandlers);
552 CXXTryStmt::CXXTryStmt(SourceLocation tryLoc, Stmt *tryBlock,
553 Stmt **handlers, unsigned numHandlers)
554 : Stmt(CXXTryStmtClass), TryLoc(tryLoc), NumHandlers(numHandlers) {
555 Stmt **Stmts = reinterpret_cast<Stmt **>(this + 1);
557 std::copy(handlers, handlers + NumHandlers, Stmts + 1);
560 CXXForRangeStmt::CXXForRangeStmt(DeclStmt *Range, DeclStmt *BeginEndStmt,
561 Expr *Cond, Expr *Inc, DeclStmt *LoopVar,
562 Stmt *Body, SourceLocation FL,
563 SourceLocation CL, SourceLocation RPL)
564 : Stmt(CXXForRangeStmtClass), ForLoc(FL), ColonLoc(CL), RParenLoc(RPL) {
565 SubExprs[RANGE] = Range;
566 SubExprs[BEGINEND] = BeginEndStmt;
567 SubExprs[COND] = reinterpret_cast<Stmt*>(Cond);
568 SubExprs[INC] = reinterpret_cast<Stmt*>(Inc);
569 SubExprs[LOOPVAR] = LoopVar;
570 SubExprs[BODY] = Body;
573 Expr *CXXForRangeStmt::getRangeInit() {
574 DeclStmt *RangeStmt = getRangeStmt();
575 VarDecl *RangeDecl = dyn_cast_or_null<VarDecl>(RangeStmt->getSingleDecl());
576 assert(RangeDecl &&& "for-range should have a single var decl");
577 return RangeDecl->getInit();
580 const Expr *CXXForRangeStmt::getRangeInit() const {
581 return const_cast<CXXForRangeStmt*>(this)->getRangeInit();
584 VarDecl *CXXForRangeStmt::getLoopVariable() {
585 Decl *LV = cast<DeclStmt>(getLoopVarStmt())->getSingleDecl();
586 assert(LV && "No loop variable in CXXForRangeStmt");
587 return cast<VarDecl>(LV);
590 const VarDecl *CXXForRangeStmt::getLoopVariable() const {
591 return const_cast<CXXForRangeStmt*>(this)->getLoopVariable();
594 IfStmt::IfStmt(ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond,
595 Stmt *then, SourceLocation EL, Stmt *elsev)
596 : Stmt(IfStmtClass), IfLoc(IL), ElseLoc(EL)
598 setConditionVariable(C, var);
599 SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
600 SubExprs[THEN] = then;
601 SubExprs[ELSE] = elsev;
604 VarDecl *IfStmt::getConditionVariable() const {
608 DeclStmt *DS = cast<DeclStmt>(SubExprs[VAR]);
609 return cast<VarDecl>(DS->getSingleDecl());
612 void IfStmt::setConditionVariable(ASTContext &C, VarDecl *V) {
618 SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V),
619 V->getSourceRange().getBegin(),
620 V->getSourceRange().getEnd());
623 ForStmt::ForStmt(ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar,
624 Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP,
626 : Stmt(ForStmtClass), ForLoc(FL), LParenLoc(LP), RParenLoc(RP)
628 SubExprs[INIT] = Init;
629 setConditionVariable(C, condVar);
630 SubExprs[COND] = reinterpret_cast<Stmt*>(Cond);
631 SubExprs[INC] = reinterpret_cast<Stmt*>(Inc);
632 SubExprs[BODY] = Body;
635 VarDecl *ForStmt::getConditionVariable() const {
636 if (!SubExprs[CONDVAR])
639 DeclStmt *DS = cast<DeclStmt>(SubExprs[CONDVAR]);
640 return cast<VarDecl>(DS->getSingleDecl());
643 void ForStmt::setConditionVariable(ASTContext &C, VarDecl *V) {
645 SubExprs[CONDVAR] = 0;
649 SubExprs[CONDVAR] = new (C) DeclStmt(DeclGroupRef(V),
650 V->getSourceRange().getBegin(),
651 V->getSourceRange().getEnd());
654 SwitchStmt::SwitchStmt(ASTContext &C, VarDecl *Var, Expr *cond)
655 : Stmt(SwitchStmtClass), FirstCase(0), AllEnumCasesCovered(0)
657 setConditionVariable(C, Var);
658 SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
659 SubExprs[BODY] = NULL;
662 VarDecl *SwitchStmt::getConditionVariable() const {
666 DeclStmt *DS = cast<DeclStmt>(SubExprs[VAR]);
667 return cast<VarDecl>(DS->getSingleDecl());
670 void SwitchStmt::setConditionVariable(ASTContext &C, VarDecl *V) {
676 SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V),
677 V->getSourceRange().getBegin(),
678 V->getSourceRange().getEnd());
681 Stmt *SwitchCase::getSubStmt() {
682 if (isa<CaseStmt>(this))
683 return cast<CaseStmt>(this)->getSubStmt();
684 return cast<DefaultStmt>(this)->getSubStmt();
687 WhileStmt::WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,
689 : Stmt(WhileStmtClass) {
690 setConditionVariable(C, Var);
691 SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
692 SubExprs[BODY] = body;
696 VarDecl *WhileStmt::getConditionVariable() const {
700 DeclStmt *DS = cast<DeclStmt>(SubExprs[VAR]);
701 return cast<VarDecl>(DS->getSingleDecl());
704 void WhileStmt::setConditionVariable(ASTContext &C, VarDecl *V) {
710 SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V),
711 V->getSourceRange().getBegin(),
712 V->getSourceRange().getEnd());
716 LabelDecl *IndirectGotoStmt::getConstantTarget() {
717 if (AddrLabelExpr *E =
718 dyn_cast<AddrLabelExpr>(getTarget()->IgnoreParenImpCasts()))
719 return E->getLabel();
724 const Expr* ReturnStmt::getRetValue() const {
725 return cast_or_null<Expr>(RetExpr);
727 Expr* ReturnStmt::getRetValue() {
728 return cast_or_null<Expr>(RetExpr);
731 SEHTryStmt::SEHTryStmt(bool IsCXXTry,
732 SourceLocation TryLoc,
735 : Stmt(SEHTryStmtClass),
739 Children[TRY] = TryBlock;
740 Children[HANDLER] = Handler;
743 SEHTryStmt* SEHTryStmt::Create(ASTContext &C,
745 SourceLocation TryLoc,
748 return new(C) SEHTryStmt(IsCXXTry,TryLoc,TryBlock,Handler);
751 SEHExceptStmt* SEHTryStmt::getExceptHandler() const {
752 return dyn_cast<SEHExceptStmt>(getHandler());
755 SEHFinallyStmt* SEHTryStmt::getFinallyHandler() const {
756 return dyn_cast<SEHFinallyStmt>(getHandler());
759 SEHExceptStmt::SEHExceptStmt(SourceLocation Loc,
762 : Stmt(SEHExceptStmtClass),
765 Children[FILTER_EXPR] = reinterpret_cast<Stmt*>(FilterExpr);
766 Children[BLOCK] = Block;
769 SEHExceptStmt* SEHExceptStmt::Create(ASTContext &C,
773 return new(C) SEHExceptStmt(Loc,FilterExpr,Block);
776 SEHFinallyStmt::SEHFinallyStmt(SourceLocation Loc,
778 : Stmt(SEHFinallyStmtClass),
783 SEHFinallyStmt* SEHFinallyStmt::Create(ASTContext &C,
786 return new(C)SEHFinallyStmt(Loc,Block);