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"
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 fprintf(stderr, "*** 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 fprintf(stderr, " %d stmts/exprs total.\n", sum);
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 fprintf(stderr, " %d %s, %d each (%d bytes)\n",
68 StmtClassInfo[i].Counter, StmtClassInfo[i].Name,
69 StmtClassInfo[i].Size,
70 StmtClassInfo[i].Counter*StmtClassInfo[i].Size);
71 sum += StmtClassInfo[i].Counter*StmtClassInfo[i].Size;
73 fprintf(stderr, "Total bytes = %d\n", sum);
76 void Stmt::addStmtClass(StmtClass s) {
77 ++getStmtInfoTableEntry(s).Counter;
80 static bool StatSwitch = false;
82 bool Stmt::CollectingStats(bool Enable) {
83 if (Enable) StatSwitch = true;
91 // These silly little functions have to be static inline to suppress
92 // unused warnings, and they have to be defined to suppress other
94 static inline good is_good(good) { return good(); }
96 typedef Stmt::child_range children_t();
97 template <class T> good implements_children(children_t T::*) {
100 static inline bad implements_children(children_t Stmt::*) {
104 typedef SourceRange getSourceRange_t() const;
105 template <class T> good implements_getSourceRange(getSourceRange_t T::*) {
108 static inline bad implements_getSourceRange(getSourceRange_t Stmt::*) {
112 #define ASSERT_IMPLEMENTS_children(type) \
113 (void) sizeof(is_good(implements_children(&type::children)))
114 #define ASSERT_IMPLEMENTS_getSourceRange(type) \
115 (void) sizeof(is_good(implements_getSourceRange(&type::getSourceRange)))
118 /// Check whether the various Stmt classes implement their member
120 static inline void check_implementations() {
121 #define ABSTRACT_STMT(type)
122 #define STMT(type, base) \
123 ASSERT_IMPLEMENTS_children(type); \
124 ASSERT_IMPLEMENTS_getSourceRange(type);
125 #include "clang/AST/StmtNodes.inc"
128 Stmt::child_range Stmt::children() {
129 switch (getStmtClass()) {
130 case Stmt::NoStmtClass: llvm_unreachable("statement without class");
131 #define ABSTRACT_STMT(type)
132 #define STMT(type, base) \
133 case Stmt::type##Class: \
134 return static_cast<type*>(this)->children();
135 #include "clang/AST/StmtNodes.inc"
137 llvm_unreachable("unknown statement kind!");
138 return child_range();
141 SourceRange Stmt::getSourceRange() const {
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<const type*>(this)->getSourceRange();
148 #include "clang/AST/StmtNodes.inc"
150 llvm_unreachable("unknown statement kind!");
151 return SourceRange();
154 void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) {
157 this->CompoundStmtBits.NumStmts = NumStmts;
159 Body = new (C) Stmt*[NumStmts];
160 memcpy(Body, Stmts, sizeof(Stmt *) * NumStmts);
163 const char *LabelStmt::getName() const {
164 return getDecl()->getIdentifier()->getNameStart();
167 // This is defined here to avoid polluting Stmt.h with importing Expr.h
168 SourceRange ReturnStmt::getSourceRange() const {
170 return SourceRange(RetLoc, RetExpr->getLocEnd());
172 return SourceRange(RetLoc);
175 bool Stmt::hasImplicitControlFlow() const {
176 switch (StmtBits.sClass) {
181 case ConditionalOperatorClass:
182 case ChooseExprClass:
187 case Stmt::BinaryOperatorClass: {
188 const BinaryOperator* B = cast<BinaryOperator>(this);
189 if (B->isLogicalOp() || B->getOpcode() == BO_Comma)
197 Expr *AsmStmt::getOutputExpr(unsigned i) {
198 return cast<Expr>(Exprs[i]);
201 /// getOutputConstraint - Return the constraint string for the specified
202 /// output operand. All output constraints are known to be non-empty (either
204 llvm::StringRef AsmStmt::getOutputConstraint(unsigned i) const {
205 return getOutputConstraintLiteral(i)->getString();
208 /// getNumPlusOperands - Return the number of output operands that have a "+"
210 unsigned AsmStmt::getNumPlusOperands() const {
212 for (unsigned i = 0, e = getNumOutputs(); i != e; ++i)
213 if (isOutputPlusConstraint(i))
218 Expr *AsmStmt::getInputExpr(unsigned i) {
219 return cast<Expr>(Exprs[i + NumOutputs]);
221 void AsmStmt::setInputExpr(unsigned i, Expr *E) {
222 Exprs[i + NumOutputs] = E;
226 /// getInputConstraint - Return the specified input constraint. Unlike output
227 /// constraints, these can be empty.
228 llvm::StringRef AsmStmt::getInputConstraint(unsigned i) const {
229 return getInputConstraintLiteral(i)->getString();
233 void AsmStmt::setOutputsAndInputsAndClobbers(ASTContext &C,
234 IdentifierInfo **Names,
235 StringLiteral **Constraints,
239 StringLiteral **Clobbers,
240 unsigned NumClobbers) {
241 this->NumOutputs = NumOutputs;
242 this->NumInputs = NumInputs;
243 this->NumClobbers = NumClobbers;
245 unsigned NumExprs = NumOutputs + NumInputs;
247 C.Deallocate(this->Names);
248 this->Names = new (C) IdentifierInfo*[NumExprs];
249 std::copy(Names, Names + NumExprs, this->Names);
251 C.Deallocate(this->Exprs);
252 this->Exprs = new (C) Stmt*[NumExprs];
253 std::copy(Exprs, Exprs + NumExprs, this->Exprs);
255 C.Deallocate(this->Constraints);
256 this->Constraints = new (C) StringLiteral*[NumExprs];
257 std::copy(Constraints, Constraints + NumExprs, this->Constraints);
259 C.Deallocate(this->Clobbers);
260 this->Clobbers = new (C) StringLiteral*[NumClobbers];
261 std::copy(Clobbers, Clobbers + NumClobbers, this->Clobbers);
264 /// getNamedOperand - Given a symbolic operand reference like %[foo],
265 /// translate this into a numeric value needed to reference the same operand.
266 /// This returns -1 if the operand name is invalid.
267 int AsmStmt::getNamedOperand(llvm::StringRef SymbolicName) const {
268 unsigned NumPlusOperands = 0;
270 // Check if this is an output operand.
271 for (unsigned i = 0, e = getNumOutputs(); i != e; ++i) {
272 if (getOutputName(i) == SymbolicName)
276 for (unsigned i = 0, e = getNumInputs(); i != e; ++i)
277 if (getInputName(i) == SymbolicName)
278 return getNumOutputs() + NumPlusOperands + i;
284 /// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing
285 /// it into pieces. If the asm string is erroneous, emit errors and return
286 /// true, otherwise return false.
287 unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces,
288 ASTContext &C, unsigned &DiagOffs) const {
289 llvm::StringRef Str = getAsmString()->getString();
290 const char *StrStart = Str.begin();
291 const char *StrEnd = Str.end();
292 const char *CurPtr = StrStart;
294 // "Simple" inline asms have no constraints or operands, just convert the asm
295 // string to escape $'s.
298 for (; CurPtr != StrEnd; ++CurPtr) {
308 Pieces.push_back(AsmStringPiece(Result));
312 // CurStringPiece - The current string that we are building up as we scan the
314 std::string CurStringPiece;
316 bool HasVariants = !C.Target.hasNoAsmVariants();
319 // Done with the string?
320 if (CurPtr == StrEnd) {
321 if (!CurStringPiece.empty())
322 Pieces.push_back(AsmStringPiece(CurStringPiece));
326 char CurChar = *CurPtr++;
328 case '$': CurStringPiece += "$$"; continue;
329 case '{': CurStringPiece += (HasVariants ? "$(" : "{"); continue;
330 case '|': CurStringPiece += (HasVariants ? "$|" : "|"); continue;
331 case '}': CurStringPiece += (HasVariants ? "$)" : "}"); continue;
335 CurStringPiece += CurChar;
339 // Escaped "%" character in asm string.
340 if (CurPtr == StrEnd) {
341 // % at end of string is invalid (no escape).
342 DiagOffs = CurPtr-StrStart-1;
343 return diag::err_asm_invalid_escape;
346 char EscapedChar = *CurPtr++;
347 if (EscapedChar == '%') { // %% -> %
348 // Escaped percentage sign.
349 CurStringPiece += '%';
353 if (EscapedChar == '=') { // %= -> Generate an unique ID.
354 CurStringPiece += "${:uid}";
358 // Otherwise, we have an operand. If we have accumulated a string so far,
359 // add it to the Pieces list.
360 if (!CurStringPiece.empty()) {
361 Pieces.push_back(AsmStringPiece(CurStringPiece));
362 CurStringPiece.clear();
365 // Handle %x4 and %x[foo] by capturing x as the modifier character.
366 char Modifier = '\0';
367 if (isalpha(EscapedChar)) {
368 Modifier = EscapedChar;
369 EscapedChar = *CurPtr++;
372 if (isdigit(EscapedChar)) {
373 // %n - Assembler operand n
377 while (CurPtr != StrEnd && isdigit(*CurPtr))
378 N = N*10 + ((*CurPtr++)-'0');
380 unsigned NumOperands =
381 getNumOutputs() + getNumPlusOperands() + getNumInputs();
382 if (N >= NumOperands) {
383 DiagOffs = CurPtr-StrStart-1;
384 return diag::err_asm_invalid_operand_number;
387 Pieces.push_back(AsmStringPiece(N, Modifier));
391 // Handle %[foo], a symbolic operand reference.
392 if (EscapedChar == '[') {
393 DiagOffs = CurPtr-StrStart-1;
396 const char *NameEnd = (const char*)memchr(CurPtr, ']', StrEnd-CurPtr);
398 return diag::err_asm_unterminated_symbolic_operand_name;
399 if (NameEnd == CurPtr)
400 return diag::err_asm_empty_symbolic_operand_name;
402 llvm::StringRef SymbolicName(CurPtr, NameEnd - CurPtr);
404 int N = getNamedOperand(SymbolicName);
406 // Verify that an operand with that name exists.
407 DiagOffs = CurPtr-StrStart;
408 return diag::err_asm_unknown_symbolic_operand_name;
410 Pieces.push_back(AsmStringPiece(N, Modifier));
416 DiagOffs = CurPtr-StrStart-1;
417 return diag::err_asm_invalid_escape;
421 QualType CXXCatchStmt::getCaughtType() const {
423 return ExceptionDecl->getType();
427 //===----------------------------------------------------------------------===//
429 //===----------------------------------------------------------------------===//
431 AsmStmt::AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple,
432 bool isvolatile, bool msasm,
433 unsigned numoutputs, unsigned numinputs,
434 IdentifierInfo **names, StringLiteral **constraints,
435 Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
436 StringLiteral **clobbers, SourceLocation rparenloc)
437 : Stmt(AsmStmtClass), AsmLoc(asmloc), RParenLoc(rparenloc), AsmStr(asmstr)
438 , IsSimple(issimple), IsVolatile(isvolatile), MSAsm(msasm)
439 , NumOutputs(numoutputs), NumInputs(numinputs), NumClobbers(numclobbers) {
441 unsigned NumExprs = NumOutputs +NumInputs;
443 Names = new (C) IdentifierInfo*[NumExprs];
444 std::copy(names, names + NumExprs, Names);
446 Exprs = new (C) Stmt*[NumExprs];
447 std::copy(exprs, exprs + NumExprs, Exprs);
449 Constraints = new (C) StringLiteral*[NumExprs];
450 std::copy(constraints, constraints + NumExprs, Constraints);
452 Clobbers = new (C) StringLiteral*[NumClobbers];
453 std::copy(clobbers, clobbers + NumClobbers, Clobbers);
456 ObjCForCollectionStmt::ObjCForCollectionStmt(Stmt *Elem, Expr *Collect,
457 Stmt *Body, SourceLocation FCL,
459 : Stmt(ObjCForCollectionStmtClass) {
460 SubExprs[ELEM] = Elem;
461 SubExprs[COLLECTION] = reinterpret_cast<Stmt*>(Collect);
462 SubExprs[BODY] = Body;
467 ObjCAtTryStmt::ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt,
468 Stmt **CatchStmts, unsigned NumCatchStmts,
470 : Stmt(ObjCAtTryStmtClass), AtTryLoc(atTryLoc),
471 NumCatchStmts(NumCatchStmts), HasFinally(atFinallyStmt != 0)
473 Stmt **Stmts = getStmts();
474 Stmts[0] = atTryStmt;
475 for (unsigned I = 0; I != NumCatchStmts; ++I)
476 Stmts[I + 1] = CatchStmts[I];
479 Stmts[NumCatchStmts + 1] = atFinallyStmt;
482 ObjCAtTryStmt *ObjCAtTryStmt::Create(ASTContext &Context,
483 SourceLocation atTryLoc,
486 unsigned NumCatchStmts,
487 Stmt *atFinallyStmt) {
488 unsigned Size = sizeof(ObjCAtTryStmt) +
489 (1 + NumCatchStmts + (atFinallyStmt != 0)) * sizeof(Stmt *);
490 void *Mem = Context.Allocate(Size, llvm::alignOf<ObjCAtTryStmt>());
491 return new (Mem) ObjCAtTryStmt(atTryLoc, atTryStmt, CatchStmts, NumCatchStmts,
495 ObjCAtTryStmt *ObjCAtTryStmt::CreateEmpty(ASTContext &Context,
496 unsigned NumCatchStmts,
498 unsigned Size = sizeof(ObjCAtTryStmt) +
499 (1 + NumCatchStmts + HasFinally) * sizeof(Stmt *);
500 void *Mem = Context.Allocate(Size, llvm::alignOf<ObjCAtTryStmt>());
501 return new (Mem) ObjCAtTryStmt(EmptyShell(), NumCatchStmts, HasFinally);
504 SourceRange ObjCAtTryStmt::getSourceRange() const {
505 SourceLocation EndLoc;
507 EndLoc = getFinallyStmt()->getLocEnd();
508 else if (NumCatchStmts)
509 EndLoc = getCatchStmt(NumCatchStmts - 1)->getLocEnd();
511 EndLoc = getTryBody()->getLocEnd();
513 return SourceRange(AtTryLoc, EndLoc);
516 CXXTryStmt *CXXTryStmt::Create(ASTContext &C, SourceLocation tryLoc,
517 Stmt *tryBlock, Stmt **handlers,
518 unsigned numHandlers) {
519 std::size_t Size = sizeof(CXXTryStmt);
520 Size += ((numHandlers + 1) * sizeof(Stmt));
522 void *Mem = C.Allocate(Size, llvm::alignOf<CXXTryStmt>());
523 return new (Mem) CXXTryStmt(tryLoc, tryBlock, handlers, numHandlers);
526 CXXTryStmt *CXXTryStmt::Create(ASTContext &C, EmptyShell Empty,
527 unsigned numHandlers) {
528 std::size_t Size = sizeof(CXXTryStmt);
529 Size += ((numHandlers + 1) * sizeof(Stmt));
531 void *Mem = C.Allocate(Size, llvm::alignOf<CXXTryStmt>());
532 return new (Mem) CXXTryStmt(Empty, numHandlers);
535 CXXTryStmt::CXXTryStmt(SourceLocation tryLoc, Stmt *tryBlock,
536 Stmt **handlers, unsigned numHandlers)
537 : Stmt(CXXTryStmtClass), TryLoc(tryLoc), NumHandlers(numHandlers) {
538 Stmt **Stmts = reinterpret_cast<Stmt **>(this + 1);
540 std::copy(handlers, handlers + NumHandlers, Stmts + 1);
543 CXXForRangeStmt::CXXForRangeStmt(DeclStmt *Range, DeclStmt *BeginEndStmt,
544 Expr *Cond, Expr *Inc, DeclStmt *LoopVar,
545 Stmt *Body, SourceLocation FL,
546 SourceLocation CL, SourceLocation RPL)
547 : Stmt(CXXForRangeStmtClass), ForLoc(FL), ColonLoc(CL), RParenLoc(RPL) {
548 SubExprs[RANGE] = Range;
549 SubExprs[BEGINEND] = BeginEndStmt;
550 SubExprs[COND] = reinterpret_cast<Stmt*>(Cond);
551 SubExprs[INC] = reinterpret_cast<Stmt*>(Inc);
552 SubExprs[LOOPVAR] = LoopVar;
553 SubExprs[BODY] = Body;
556 Expr *CXXForRangeStmt::getRangeInit() {
557 DeclStmt *RangeStmt = getRangeStmt();
558 VarDecl *RangeDecl = dyn_cast_or_null<VarDecl>(RangeStmt->getSingleDecl());
559 assert(RangeDecl &&& "for-range should have a single var decl");
560 return RangeDecl->getInit();
563 const Expr *CXXForRangeStmt::getRangeInit() const {
564 return const_cast<CXXForRangeStmt*>(this)->getRangeInit();
567 VarDecl *CXXForRangeStmt::getLoopVariable() {
568 Decl *LV = cast<DeclStmt>(getLoopVarStmt())->getSingleDecl();
569 assert(LV && "No loop variable in CXXForRangeStmt");
570 return cast<VarDecl>(LV);
573 const VarDecl *CXXForRangeStmt::getLoopVariable() const {
574 return const_cast<CXXForRangeStmt*>(this)->getLoopVariable();
577 IfStmt::IfStmt(ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond,
578 Stmt *then, SourceLocation EL, Stmt *elsev)
579 : Stmt(IfStmtClass), IfLoc(IL), ElseLoc(EL)
581 setConditionVariable(C, var);
582 SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
583 SubExprs[THEN] = then;
584 SubExprs[ELSE] = elsev;
587 VarDecl *IfStmt::getConditionVariable() const {
591 DeclStmt *DS = cast<DeclStmt>(SubExprs[VAR]);
592 return cast<VarDecl>(DS->getSingleDecl());
595 void IfStmt::setConditionVariable(ASTContext &C, VarDecl *V) {
601 SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V),
602 V->getSourceRange().getBegin(),
603 V->getSourceRange().getEnd());
606 ForStmt::ForStmt(ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar,
607 Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP,
609 : Stmt(ForStmtClass), ForLoc(FL), LParenLoc(LP), RParenLoc(RP)
611 SubExprs[INIT] = Init;
612 setConditionVariable(C, condVar);
613 SubExprs[COND] = reinterpret_cast<Stmt*>(Cond);
614 SubExprs[INC] = reinterpret_cast<Stmt*>(Inc);
615 SubExprs[BODY] = Body;
618 VarDecl *ForStmt::getConditionVariable() const {
619 if (!SubExprs[CONDVAR])
622 DeclStmt *DS = cast<DeclStmt>(SubExprs[CONDVAR]);
623 return cast<VarDecl>(DS->getSingleDecl());
626 void ForStmt::setConditionVariable(ASTContext &C, VarDecl *V) {
628 SubExprs[CONDVAR] = 0;
632 SubExprs[CONDVAR] = new (C) DeclStmt(DeclGroupRef(V),
633 V->getSourceRange().getBegin(),
634 V->getSourceRange().getEnd());
637 SwitchStmt::SwitchStmt(ASTContext &C, VarDecl *Var, Expr *cond)
638 : Stmt(SwitchStmtClass), FirstCase(0), AllEnumCasesCovered(0)
640 setConditionVariable(C, Var);
641 SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
642 SubExprs[BODY] = NULL;
645 VarDecl *SwitchStmt::getConditionVariable() const {
649 DeclStmt *DS = cast<DeclStmt>(SubExprs[VAR]);
650 return cast<VarDecl>(DS->getSingleDecl());
653 void SwitchStmt::setConditionVariable(ASTContext &C, VarDecl *V) {
659 SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V),
660 V->getSourceRange().getBegin(),
661 V->getSourceRange().getEnd());
664 Stmt *SwitchCase::getSubStmt() {
665 if (isa<CaseStmt>(this))
666 return cast<CaseStmt>(this)->getSubStmt();
667 return cast<DefaultStmt>(this)->getSubStmt();
670 WhileStmt::WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,
672 : Stmt(WhileStmtClass) {
673 setConditionVariable(C, Var);
674 SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
675 SubExprs[BODY] = body;
679 VarDecl *WhileStmt::getConditionVariable() const {
683 DeclStmt *DS = cast<DeclStmt>(SubExprs[VAR]);
684 return cast<VarDecl>(DS->getSingleDecl());
687 void WhileStmt::setConditionVariable(ASTContext &C, VarDecl *V) {
693 SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V),
694 V->getSourceRange().getBegin(),
695 V->getSourceRange().getEnd());
699 LabelDecl *IndirectGotoStmt::getConstantTarget() {
700 if (AddrLabelExpr *E =
701 dyn_cast<AddrLabelExpr>(getTarget()->IgnoreParenImpCasts()))
702 return E->getLabel();
707 const Expr* ReturnStmt::getRetValue() const {
708 return cast_or_null<Expr>(RetExpr);
710 Expr* ReturnStmt::getRetValue() {
711 return cast_or_null<Expr>(RetExpr);
714 SEHTryStmt::SEHTryStmt(bool IsCXXTry,
715 SourceLocation TryLoc,
718 : Stmt(SEHTryStmtClass),
722 Children[TRY] = TryBlock;
723 Children[HANDLER] = Handler;
726 SEHTryStmt* SEHTryStmt::Create(ASTContext &C,
728 SourceLocation TryLoc,
731 return new(C) SEHTryStmt(IsCXXTry,TryLoc,TryBlock,Handler);
734 SEHExceptStmt* SEHTryStmt::getExceptHandler() const {
735 return dyn_cast<SEHExceptStmt>(getHandler());
738 SEHFinallyStmt* SEHTryStmt::getFinallyHandler() const {
739 return dyn_cast<SEHFinallyStmt>(getHandler());
742 SEHExceptStmt::SEHExceptStmt(SourceLocation Loc,
745 : Stmt(SEHExceptStmtClass),
748 Children[FILTER_EXPR] = reinterpret_cast<Stmt*>(FilterExpr);
749 Children[BLOCK] = Block;
752 SEHExceptStmt* SEHExceptStmt::Create(ASTContext &C,
756 return new(C) SEHExceptStmt(Loc,FilterExpr,Block);
759 SEHFinallyStmt::SEHFinallyStmt(SourceLocation Loc,
761 : Stmt(SEHFinallyStmtClass),
766 SEHFinallyStmt* SEHFinallyStmt::Create(ASTContext &C,
769 return new(C)SEHFinallyStmt(Loc,Block);