Stmt.h revision 95f6190acb664b345b1395abaea84ee451740c5b
1//===--- Stmt.h - Classes for representing statements -----------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10//  This file defines the Stmt interface and subclasses.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_AST_STMT_H
15#define LLVM_CLANG_AST_STMT_H
16
17#include "clang/Basic/LLVM.h"
18#include "clang/Basic/SourceLocation.h"
19#include "clang/AST/PrettyPrinter.h"
20#include "clang/AST/StmtIterator.h"
21#include "clang/AST/DeclGroup.h"
22#include "clang/AST/Attr.h"
23#include "clang/Lex/Token.h"
24#include "llvm/ADT/SmallVector.h"
25#include "llvm/Support/Compiler.h"
26#include "llvm/Support/raw_ostream.h"
27#include <string>
28
29namespace llvm {
30  class FoldingSetNodeID;
31}
32
33namespace clang {
34  class ASTContext;
35  class Expr;
36  class Decl;
37  class ParmVarDecl;
38  class QualType;
39  class IdentifierInfo;
40  class LabelDecl;
41  class SourceManager;
42  class StringLiteral;
43  class SwitchStmt;
44  class VarDecl;
45
46  //===--------------------------------------------------------------------===//
47  // ExprIterator - Iterators for iterating over Stmt* arrays that contain
48  //  only Expr*.  This is needed because AST nodes use Stmt* arrays to store
49  //  references to children (to be compatible with StmtIterator).
50  //===--------------------------------------------------------------------===//
51
52  class Stmt;
53  class Expr;
54
55  class ExprIterator {
56    Stmt** I;
57  public:
58    ExprIterator(Stmt** i) : I(i) {}
59    ExprIterator() : I(0) {}
60    ExprIterator& operator++() { ++I; return *this; }
61    ExprIterator operator-(size_t i) { return I-i; }
62    ExprIterator operator+(size_t i) { return I+i; }
63    Expr* operator[](size_t idx);
64    // FIXME: Verify that this will correctly return a signed distance.
65    signed operator-(const ExprIterator& R) const { return I - R.I; }
66    Expr* operator*() const;
67    Expr* operator->() const;
68    bool operator==(const ExprIterator& R) const { return I == R.I; }
69    bool operator!=(const ExprIterator& R) const { return I != R.I; }
70    bool operator>(const ExprIterator& R) const { return I > R.I; }
71    bool operator>=(const ExprIterator& R) const { return I >= R.I; }
72  };
73
74  class ConstExprIterator {
75    const Stmt * const *I;
76  public:
77    ConstExprIterator(const Stmt * const *i) : I(i) {}
78    ConstExprIterator() : I(0) {}
79    ConstExprIterator& operator++() { ++I; return *this; }
80    ConstExprIterator operator+(size_t i) const { return I+i; }
81    ConstExprIterator operator-(size_t i) const { return I-i; }
82    const Expr * operator[](size_t idx) const;
83    signed operator-(const ConstExprIterator& R) const { return I - R.I; }
84    const Expr * operator*() const;
85    const Expr * operator->() const;
86    bool operator==(const ConstExprIterator& R) const { return I == R.I; }
87    bool operator!=(const ConstExprIterator& R) const { return I != R.I; }
88    bool operator>(const ConstExprIterator& R) const { return I > R.I; }
89    bool operator>=(const ConstExprIterator& R) const { return I >= R.I; }
90  };
91
92//===----------------------------------------------------------------------===//
93// AST classes for statements.
94//===----------------------------------------------------------------------===//
95
96/// Stmt - This represents one statement.
97///
98class Stmt {
99public:
100  enum StmtClass {
101    NoStmtClass = 0,
102#define STMT(CLASS, PARENT) CLASS##Class,
103#define STMT_RANGE(BASE, FIRST, LAST) \
104        first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class,
105#define LAST_STMT_RANGE(BASE, FIRST, LAST) \
106        first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class
107#define ABSTRACT_STMT(STMT)
108#include "clang/AST/StmtNodes.inc"
109  };
110
111  // Make vanilla 'new' and 'delete' illegal for Stmts.
112protected:
113  void* operator new(size_t bytes) throw() {
114    llvm_unreachable("Stmts cannot be allocated with regular 'new'.");
115  }
116  void operator delete(void* data) throw() {
117    llvm_unreachable("Stmts cannot be released with regular 'delete'.");
118  }
119
120  class StmtBitfields {
121    friend class Stmt;
122
123    /// \brief The statement class.
124    unsigned sClass : 8;
125  };
126  enum { NumStmtBits = 8 };
127
128  class CompoundStmtBitfields {
129    friend class CompoundStmt;
130    unsigned : NumStmtBits;
131
132    unsigned NumStmts : 32 - NumStmtBits;
133  };
134
135  class ExprBitfields {
136    friend class Expr;
137    friend class DeclRefExpr; // computeDependence
138    friend class InitListExpr; // ctor
139    friend class DesignatedInitExpr; // ctor
140    friend class BlockDeclRefExpr; // ctor
141    friend class ASTStmtReader; // deserialization
142    friend class CXXNewExpr; // ctor
143    friend class DependentScopeDeclRefExpr; // ctor
144    friend class CXXConstructExpr; // ctor
145    friend class CallExpr; // ctor
146    friend class OffsetOfExpr; // ctor
147    friend class ObjCMessageExpr; // ctor
148    friend class ObjCArrayLiteral; // ctor
149    friend class ObjCDictionaryLiteral; // ctor
150    friend class ShuffleVectorExpr; // ctor
151    friend class ParenListExpr; // ctor
152    friend class CXXUnresolvedConstructExpr; // ctor
153    friend class CXXDependentScopeMemberExpr; // ctor
154    friend class OverloadExpr; // ctor
155    friend class PseudoObjectExpr; // ctor
156    friend class AtomicExpr; // ctor
157    unsigned : NumStmtBits;
158
159    unsigned ValueKind : 2;
160    unsigned ObjectKind : 2;
161    unsigned TypeDependent : 1;
162    unsigned ValueDependent : 1;
163    unsigned InstantiationDependent : 1;
164    unsigned ContainsUnexpandedParameterPack : 1;
165  };
166  enum { NumExprBits = 16 };
167
168  class CharacterLiteralBitfields {
169    friend class CharacterLiteral;
170    unsigned : NumExprBits;
171
172    unsigned Kind : 2;
173  };
174
175  class FloatingLiteralBitfields {
176    friend class FloatingLiteral;
177    unsigned : NumExprBits;
178
179    unsigned IsIEEE : 1; // Distinguishes between PPC128 and IEEE128.
180    unsigned IsExact : 1;
181  };
182
183  class UnaryExprOrTypeTraitExprBitfields {
184    friend class UnaryExprOrTypeTraitExpr;
185    unsigned : NumExprBits;
186
187    unsigned Kind : 2;
188    unsigned IsType : 1; // true if operand is a type, false if an expression.
189  };
190
191  class DeclRefExprBitfields {
192    friend class DeclRefExpr;
193    friend class ASTStmtReader; // deserialization
194    unsigned : NumExprBits;
195
196    unsigned HasQualifier : 1;
197    unsigned HasTemplateKWAndArgsInfo : 1;
198    unsigned HasFoundDecl : 1;
199    unsigned HadMultipleCandidates : 1;
200    unsigned RefersToEnclosingLocal : 1;
201  };
202
203  class CastExprBitfields {
204    friend class CastExpr;
205    unsigned : NumExprBits;
206
207    unsigned Kind : 6;
208    unsigned BasePathSize : 32 - 6 - NumExprBits;
209  };
210
211  class CallExprBitfields {
212    friend class CallExpr;
213    unsigned : NumExprBits;
214
215    unsigned NumPreArgs : 1;
216  };
217
218  class ExprWithCleanupsBitfields {
219    friend class ExprWithCleanups;
220    friend class ASTStmtReader; // deserialization
221
222    unsigned : NumExprBits;
223
224    unsigned NumObjects : 32 - NumExprBits;
225  };
226
227  class PseudoObjectExprBitfields {
228    friend class PseudoObjectExpr;
229    friend class ASTStmtReader; // deserialization
230
231    unsigned : NumExprBits;
232
233    // These don't need to be particularly wide, because they're
234    // strictly limited by the forms of expressions we permit.
235    unsigned NumSubExprs : 8;
236    unsigned ResultIndex : 32 - 8 - NumExprBits;
237  };
238
239  class ObjCIndirectCopyRestoreExprBitfields {
240    friend class ObjCIndirectCopyRestoreExpr;
241    unsigned : NumExprBits;
242
243    unsigned ShouldCopy : 1;
244  };
245
246  class InitListExprBitfields {
247    friend class InitListExpr;
248
249    unsigned : NumExprBits;
250
251    /// Whether this initializer list originally had a GNU array-range
252    /// designator in it. This is a temporary marker used by CodeGen.
253    unsigned HadArrayRangeDesignator : 1;
254
255    /// Whether this initializer list initializes a std::initializer_list
256    /// object.
257    unsigned InitializesStdInitializerList : 1;
258  };
259
260  class TypeTraitExprBitfields {
261    friend class TypeTraitExpr;
262    friend class ASTStmtReader;
263    friend class ASTStmtWriter;
264
265    unsigned : NumExprBits;
266
267    /// \brief The kind of type trait, which is a value of a TypeTrait enumerator.
268    unsigned Kind : 8;
269
270    /// \brief If this expression is not value-dependent, this indicates whether
271    /// the trait evaluated true or false.
272    unsigned Value : 1;
273
274    /// \brief The number of arguments to this type trait.
275    unsigned NumArgs : 32 - 8 - 1 - NumExprBits;
276  };
277
278  union {
279    // FIXME: this is wasteful on 64-bit platforms.
280    void *Aligner;
281
282    StmtBitfields StmtBits;
283    CompoundStmtBitfields CompoundStmtBits;
284    ExprBitfields ExprBits;
285    CharacterLiteralBitfields CharacterLiteralBits;
286    FloatingLiteralBitfields FloatingLiteralBits;
287    UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits;
288    DeclRefExprBitfields DeclRefExprBits;
289    CastExprBitfields CastExprBits;
290    CallExprBitfields CallExprBits;
291    ExprWithCleanupsBitfields ExprWithCleanupsBits;
292    PseudoObjectExprBitfields PseudoObjectExprBits;
293    ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits;
294    InitListExprBitfields InitListExprBits;
295    TypeTraitExprBitfields TypeTraitExprBits;
296  };
297
298  friend class ASTStmtReader;
299  friend class ASTStmtWriter;
300
301public:
302  // Only allow allocation of Stmts using the allocator in ASTContext
303  // or by doing a placement new.
304  void* operator new(size_t bytes, ASTContext& C,
305                     unsigned alignment = 8) throw() {
306    return ::operator new(bytes, C, alignment);
307  }
308
309  void* operator new(size_t bytes, ASTContext* C,
310                     unsigned alignment = 8) throw() {
311    return ::operator new(bytes, *C, alignment);
312  }
313
314  void* operator new(size_t bytes, void* mem) throw() {
315    return mem;
316  }
317
318  void operator delete(void*, ASTContext&, unsigned) throw() { }
319  void operator delete(void*, ASTContext*, unsigned) throw() { }
320  void operator delete(void*, std::size_t) throw() { }
321  void operator delete(void*, void*) throw() { }
322
323public:
324  /// \brief A placeholder type used to construct an empty shell of a
325  /// type, that will be filled in later (e.g., by some
326  /// de-serialization).
327  struct EmptyShell { };
328
329private:
330  /// \brief Whether statistic collection is enabled.
331  static bool StatisticsEnabled;
332
333protected:
334  /// \brief Construct an empty statement.
335  explicit Stmt(StmtClass SC, EmptyShell) {
336    StmtBits.sClass = SC;
337    if (StatisticsEnabled) Stmt::addStmtClass(SC);
338  }
339
340public:
341  Stmt(StmtClass SC) {
342    StmtBits.sClass = SC;
343    if (StatisticsEnabled) Stmt::addStmtClass(SC);
344  }
345
346  StmtClass getStmtClass() const {
347    return static_cast<StmtClass>(StmtBits.sClass);
348  }
349  const char *getStmtClassName() const;
350
351  /// SourceLocation tokens are not useful in isolation - they are low level
352  /// value objects created/interpreted by SourceManager. We assume AST
353  /// clients will have a pointer to the respective SourceManager.
354  SourceRange getSourceRange() const LLVM_READONLY;
355  SourceLocation getLocStart() const LLVM_READONLY;
356  SourceLocation getLocEnd() const LLVM_READONLY;
357
358  // global temp stats (until we have a per-module visitor)
359  static void addStmtClass(const StmtClass s);
360  static void EnableStatistics();
361  static void PrintStats();
362
363  /// \brief Dumps the specified AST fragment and all subtrees to
364  /// \c llvm::errs().
365  LLVM_ATTRIBUTE_USED void dump() const;
366  LLVM_ATTRIBUTE_USED void dump(SourceManager &SM) const;
367  void dump(raw_ostream &OS, SourceManager &SM) const;
368
369  /// dumpPretty/printPretty - These two methods do a "pretty print" of the AST
370  /// back to its original source language syntax.
371  void dumpPretty(ASTContext &Context) const;
372  void printPretty(raw_ostream &OS, PrinterHelper *Helper,
373                   const PrintingPolicy &Policy,
374                   unsigned Indentation = 0) const;
375
376  /// viewAST - Visualize an AST rooted at this Stmt* using GraphViz.  Only
377  ///   works on systems with GraphViz (Mac OS X) or dot+gv installed.
378  void viewAST() const;
379
380  /// Skip past any implicit AST nodes which might surround this
381  /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
382  Stmt *IgnoreImplicit();
383
384  const Stmt *stripLabelLikeStatements() const;
385  Stmt *stripLabelLikeStatements() {
386    return const_cast<Stmt*>(
387      const_cast<const Stmt*>(this)->stripLabelLikeStatements());
388  }
389
390  /// hasImplicitControlFlow - Some statements (e.g. short circuited operations)
391  ///  contain implicit control-flow in the order their subexpressions
392  ///  are evaluated.  This predicate returns true if this statement has
393  ///  such implicit control-flow.  Such statements are also specially handled
394  ///  within CFGs.
395  bool hasImplicitControlFlow() const;
396
397  /// Child Iterators: All subclasses must implement 'children'
398  /// to permit easy iteration over the substatements/subexpessions of an
399  /// AST node.  This permits easy iteration over all nodes in the AST.
400  typedef StmtIterator       child_iterator;
401  typedef ConstStmtIterator  const_child_iterator;
402
403  typedef StmtRange          child_range;
404  typedef ConstStmtRange     const_child_range;
405
406  child_range children();
407  const_child_range children() const {
408    return const_cast<Stmt*>(this)->children();
409  }
410
411  child_iterator child_begin() { return children().first; }
412  child_iterator child_end() { return children().second; }
413
414  const_child_iterator child_begin() const { return children().first; }
415  const_child_iterator child_end() const { return children().second; }
416
417  /// \brief Produce a unique representation of the given statement.
418  ///
419  /// \param ID once the profiling operation is complete, will contain
420  /// the unique representation of the given statement.
421  ///
422  /// \param Context the AST context in which the statement resides
423  ///
424  /// \param Canonical whether the profile should be based on the canonical
425  /// representation of this statement (e.g., where non-type template
426  /// parameters are identified by index/level rather than their
427  /// declaration pointers) or the exact representation of the statement as
428  /// written in the source.
429  void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
430               bool Canonical) const;
431};
432
433/// DeclStmt - Adaptor class for mixing declarations with statements and
434/// expressions. For example, CompoundStmt mixes statements, expressions
435/// and declarations (variables, types). Another example is ForStmt, where
436/// the first statement can be an expression or a declaration.
437///
438class DeclStmt : public Stmt {
439  DeclGroupRef DG;
440  SourceLocation StartLoc, EndLoc;
441
442public:
443  DeclStmt(DeclGroupRef dg, SourceLocation startLoc,
444           SourceLocation endLoc) : Stmt(DeclStmtClass), DG(dg),
445                                    StartLoc(startLoc), EndLoc(endLoc) {}
446
447  /// \brief Build an empty declaration statement.
448  explicit DeclStmt(EmptyShell Empty) : Stmt(DeclStmtClass, Empty) { }
449
450  /// isSingleDecl - This method returns true if this DeclStmt refers
451  /// to a single Decl.
452  bool isSingleDecl() const {
453    return DG.isSingleDecl();
454  }
455
456  const Decl *getSingleDecl() const { return DG.getSingleDecl(); }
457  Decl *getSingleDecl() { return DG.getSingleDecl(); }
458
459  const DeclGroupRef getDeclGroup() const { return DG; }
460  DeclGroupRef getDeclGroup() { return DG; }
461  void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
462
463  SourceLocation getStartLoc() const { return StartLoc; }
464  void setStartLoc(SourceLocation L) { StartLoc = L; }
465  SourceLocation getEndLoc() const { return EndLoc; }
466  void setEndLoc(SourceLocation L) { EndLoc = L; }
467
468  SourceRange getSourceRange() const LLVM_READONLY {
469    return SourceRange(StartLoc, EndLoc);
470  }
471
472  static bool classof(const Stmt *T) {
473    return T->getStmtClass() == DeclStmtClass;
474  }
475
476  // Iterators over subexpressions.
477  child_range children() {
478    return child_range(child_iterator(DG.begin(), DG.end()),
479                       child_iterator(DG.end(), DG.end()));
480  }
481
482  typedef DeclGroupRef::iterator decl_iterator;
483  typedef DeclGroupRef::const_iterator const_decl_iterator;
484
485  decl_iterator decl_begin() { return DG.begin(); }
486  decl_iterator decl_end() { return DG.end(); }
487  const_decl_iterator decl_begin() const { return DG.begin(); }
488  const_decl_iterator decl_end() const { return DG.end(); }
489
490  typedef std::reverse_iterator<decl_iterator> reverse_decl_iterator;
491  reverse_decl_iterator decl_rbegin() {
492    return reverse_decl_iterator(decl_end());
493  }
494  reverse_decl_iterator decl_rend() {
495    return reverse_decl_iterator(decl_begin());
496  }
497};
498
499/// NullStmt - This is the null statement ";": C99 6.8.3p3.
500///
501class NullStmt : public Stmt {
502  SourceLocation SemiLoc;
503
504  /// \brief True if the null statement was preceded by an empty macro, e.g:
505  /// @code
506  ///   #define CALL(x)
507  ///   CALL(0);
508  /// @endcode
509  bool HasLeadingEmptyMacro;
510public:
511  NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false)
512    : Stmt(NullStmtClass), SemiLoc(L),
513      HasLeadingEmptyMacro(hasLeadingEmptyMacro) {}
514
515  /// \brief Build an empty null statement.
516  explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty),
517      HasLeadingEmptyMacro(false) { }
518
519  SourceLocation getSemiLoc() const { return SemiLoc; }
520  void setSemiLoc(SourceLocation L) { SemiLoc = L; }
521
522  bool hasLeadingEmptyMacro() const { return HasLeadingEmptyMacro; }
523
524  SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(SemiLoc); }
525
526  static bool classof(const Stmt *T) {
527    return T->getStmtClass() == NullStmtClass;
528  }
529
530  child_range children() { return child_range(); }
531
532  friend class ASTStmtReader;
533  friend class ASTStmtWriter;
534};
535
536/// CompoundStmt - This represents a group of statements like { stmt stmt }.
537///
538class CompoundStmt : public Stmt {
539  Stmt** Body;
540  SourceLocation LBracLoc, RBracLoc;
541public:
542  CompoundStmt(ASTContext &C, Stmt **StmtStart, unsigned NumStmts,
543               SourceLocation LB, SourceLocation RB);
544
545  // \brief Build an empty compound statment with a location.
546  explicit CompoundStmt(SourceLocation Loc)
547    : Stmt(CompoundStmtClass), Body(0), LBracLoc(Loc), RBracLoc(Loc) {
548    CompoundStmtBits.NumStmts = 0;
549  }
550
551  // \brief Build an empty compound statement.
552  explicit CompoundStmt(EmptyShell Empty)
553    : Stmt(CompoundStmtClass, Empty), Body(0) {
554    CompoundStmtBits.NumStmts = 0;
555  }
556
557  void setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts);
558
559  bool body_empty() const { return CompoundStmtBits.NumStmts == 0; }
560  unsigned size() const { return CompoundStmtBits.NumStmts; }
561
562  typedef Stmt** body_iterator;
563  body_iterator body_begin() { return Body; }
564  body_iterator body_end() { return Body + size(); }
565  Stmt *body_back() { return !body_empty() ? Body[size()-1] : 0; }
566
567  void setLastStmt(Stmt *S) {
568    assert(!body_empty() && "setLastStmt");
569    Body[size()-1] = S;
570  }
571
572  typedef Stmt* const * const_body_iterator;
573  const_body_iterator body_begin() const { return Body; }
574  const_body_iterator body_end() const { return Body + size(); }
575  const Stmt *body_back() const { return !body_empty() ? Body[size()-1] : 0; }
576
577  typedef std::reverse_iterator<body_iterator> reverse_body_iterator;
578  reverse_body_iterator body_rbegin() {
579    return reverse_body_iterator(body_end());
580  }
581  reverse_body_iterator body_rend() {
582    return reverse_body_iterator(body_begin());
583  }
584
585  typedef std::reverse_iterator<const_body_iterator>
586          const_reverse_body_iterator;
587
588  const_reverse_body_iterator body_rbegin() const {
589    return const_reverse_body_iterator(body_end());
590  }
591
592  const_reverse_body_iterator body_rend() const {
593    return const_reverse_body_iterator(body_begin());
594  }
595
596  SourceRange getSourceRange() const LLVM_READONLY {
597    return SourceRange(LBracLoc, RBracLoc);
598  }
599
600  SourceLocation getLBracLoc() const { return LBracLoc; }
601  void setLBracLoc(SourceLocation L) { LBracLoc = L; }
602  SourceLocation getRBracLoc() const { return RBracLoc; }
603  void setRBracLoc(SourceLocation L) { RBracLoc = L; }
604
605  static bool classof(const Stmt *T) {
606    return T->getStmtClass() == CompoundStmtClass;
607  }
608
609  // Iterators
610  child_range children() {
611    return child_range(&Body[0], &Body[0]+CompoundStmtBits.NumStmts);
612  }
613
614  const_child_range children() const {
615    return child_range(&Body[0], &Body[0]+CompoundStmtBits.NumStmts);
616  }
617};
618
619// SwitchCase is the base class for CaseStmt and DefaultStmt,
620class SwitchCase : public Stmt {
621protected:
622  // A pointer to the following CaseStmt or DefaultStmt class,
623  // used by SwitchStmt.
624  SwitchCase *NextSwitchCase;
625
626  SwitchCase(StmtClass SC) : Stmt(SC), NextSwitchCase(0) {}
627
628public:
629  const SwitchCase *getNextSwitchCase() const { return NextSwitchCase; }
630
631  SwitchCase *getNextSwitchCase() { return NextSwitchCase; }
632
633  void setNextSwitchCase(SwitchCase *SC) { NextSwitchCase = SC; }
634
635  Stmt *getSubStmt();
636  const Stmt *getSubStmt() const {
637    return const_cast<SwitchCase*>(this)->getSubStmt();
638  }
639
640  SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(); }
641
642  static bool classof(const Stmt *T) {
643    return T->getStmtClass() == CaseStmtClass ||
644           T->getStmtClass() == DefaultStmtClass;
645  }
646};
647
648class CaseStmt : public SwitchCase {
649  enum { LHS, RHS, SUBSTMT, END_EXPR };
650  Stmt* SubExprs[END_EXPR];  // The expression for the RHS is Non-null for
651                             // GNU "case 1 ... 4" extension
652  SourceLocation CaseLoc;
653  SourceLocation EllipsisLoc;
654  SourceLocation ColonLoc;
655public:
656  CaseStmt(Expr *lhs, Expr *rhs, SourceLocation caseLoc,
657           SourceLocation ellipsisLoc, SourceLocation colonLoc)
658    : SwitchCase(CaseStmtClass) {
659    SubExprs[SUBSTMT] = 0;
660    SubExprs[LHS] = reinterpret_cast<Stmt*>(lhs);
661    SubExprs[RHS] = reinterpret_cast<Stmt*>(rhs);
662    CaseLoc = caseLoc;
663    EllipsisLoc = ellipsisLoc;
664    ColonLoc = colonLoc;
665  }
666
667  /// \brief Build an empty switch case statement.
668  explicit CaseStmt(EmptyShell Empty) : SwitchCase(CaseStmtClass) { }
669
670  SourceLocation getCaseLoc() const { return CaseLoc; }
671  void setCaseLoc(SourceLocation L) { CaseLoc = L; }
672  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
673  void setEllipsisLoc(SourceLocation L) { EllipsisLoc = L; }
674  SourceLocation getColonLoc() const { return ColonLoc; }
675  void setColonLoc(SourceLocation L) { ColonLoc = L; }
676
677  Expr *getLHS() { return reinterpret_cast<Expr*>(SubExprs[LHS]); }
678  Expr *getRHS() { return reinterpret_cast<Expr*>(SubExprs[RHS]); }
679  Stmt *getSubStmt() { return SubExprs[SUBSTMT]; }
680
681  const Expr *getLHS() const {
682    return reinterpret_cast<const Expr*>(SubExprs[LHS]);
683  }
684  const Expr *getRHS() const {
685    return reinterpret_cast<const Expr*>(SubExprs[RHS]);
686  }
687  const Stmt *getSubStmt() const { return SubExprs[SUBSTMT]; }
688
689  void setSubStmt(Stmt *S) { SubExprs[SUBSTMT] = S; }
690  void setLHS(Expr *Val) { SubExprs[LHS] = reinterpret_cast<Stmt*>(Val); }
691  void setRHS(Expr *Val) { SubExprs[RHS] = reinterpret_cast<Stmt*>(Val); }
692
693
694  SourceRange getSourceRange() const LLVM_READONLY {
695    // Handle deeply nested case statements with iteration instead of recursion.
696    const CaseStmt *CS = this;
697    while (const CaseStmt *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt()))
698      CS = CS2;
699
700    return SourceRange(CaseLoc, CS->getSubStmt()->getLocEnd());
701  }
702  static bool classof(const Stmt *T) {
703    return T->getStmtClass() == CaseStmtClass;
704  }
705
706  // Iterators
707  child_range children() {
708    return child_range(&SubExprs[0], &SubExprs[END_EXPR]);
709  }
710};
711
712class DefaultStmt : public SwitchCase {
713  Stmt* SubStmt;
714  SourceLocation DefaultLoc;
715  SourceLocation ColonLoc;
716public:
717  DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt) :
718    SwitchCase(DefaultStmtClass), SubStmt(substmt), DefaultLoc(DL),
719    ColonLoc(CL) {}
720
721  /// \brief Build an empty default statement.
722  explicit DefaultStmt(EmptyShell) : SwitchCase(DefaultStmtClass) { }
723
724  Stmt *getSubStmt() { return SubStmt; }
725  const Stmt *getSubStmt() const { return SubStmt; }
726  void setSubStmt(Stmt *S) { SubStmt = S; }
727
728  SourceLocation getDefaultLoc() const { return DefaultLoc; }
729  void setDefaultLoc(SourceLocation L) { DefaultLoc = L; }
730  SourceLocation getColonLoc() const { return ColonLoc; }
731  void setColonLoc(SourceLocation L) { ColonLoc = L; }
732
733  SourceRange getSourceRange() const LLVM_READONLY {
734    return SourceRange(DefaultLoc, SubStmt->getLocEnd());
735  }
736  static bool classof(const Stmt *T) {
737    return T->getStmtClass() == DefaultStmtClass;
738  }
739
740  // Iterators
741  child_range children() { return child_range(&SubStmt, &SubStmt+1); }
742};
743
744
745/// LabelStmt - Represents a label, which has a substatement.  For example:
746///    foo: return;
747///
748class LabelStmt : public Stmt {
749  LabelDecl *TheDecl;
750  Stmt *SubStmt;
751  SourceLocation IdentLoc;
752public:
753  LabelStmt(SourceLocation IL, LabelDecl *D, Stmt *substmt)
754    : Stmt(LabelStmtClass), TheDecl(D), SubStmt(substmt), IdentLoc(IL) {
755  }
756
757  // \brief Build an empty label statement.
758  explicit LabelStmt(EmptyShell Empty) : Stmt(LabelStmtClass, Empty) { }
759
760  SourceLocation getIdentLoc() const { return IdentLoc; }
761  LabelDecl *getDecl() const { return TheDecl; }
762  void setDecl(LabelDecl *D) { TheDecl = D; }
763  const char *getName() const;
764  Stmt *getSubStmt() { return SubStmt; }
765  const Stmt *getSubStmt() const { return SubStmt; }
766  void setIdentLoc(SourceLocation L) { IdentLoc = L; }
767  void setSubStmt(Stmt *SS) { SubStmt = SS; }
768
769  SourceRange getSourceRange() const LLVM_READONLY {
770    return SourceRange(IdentLoc, SubStmt->getLocEnd());
771  }
772  child_range children() { return child_range(&SubStmt, &SubStmt+1); }
773
774  static bool classof(const Stmt *T) {
775    return T->getStmtClass() == LabelStmtClass;
776  }
777};
778
779
780/// \brief Represents an attribute applied to a statement.
781///
782/// Represents an attribute applied to a statement. For example:
783///   [[omp::for(...)]] for (...) { ... }
784///
785class AttributedStmt : public Stmt {
786  Stmt *SubStmt;
787  SourceLocation AttrLoc;
788  unsigned NumAttrs;
789  const Attr *Attrs[1];
790
791  friend class ASTStmtReader;
792
793  AttributedStmt(SourceLocation Loc, ArrayRef<const Attr*> Attrs, Stmt *SubStmt)
794    : Stmt(AttributedStmtClass), SubStmt(SubStmt), AttrLoc(Loc),
795      NumAttrs(Attrs.size()) {
796    memcpy(this->Attrs, Attrs.data(), Attrs.size() * sizeof(Attr*));
797  }
798
799  explicit AttributedStmt(EmptyShell Empty, unsigned NumAttrs)
800    : Stmt(AttributedStmtClass, Empty), NumAttrs(NumAttrs) {
801    memset(Attrs, 0, NumAttrs * sizeof(Attr*));
802  }
803
804public:
805  static AttributedStmt *Create(ASTContext &C, SourceLocation Loc,
806                                ArrayRef<const Attr*> Attrs, Stmt *SubStmt);
807  // \brief Build an empty attributed statement.
808  static AttributedStmt *CreateEmpty(ASTContext &C, unsigned NumAttrs);
809
810  SourceLocation getAttrLoc() const { return AttrLoc; }
811  ArrayRef<const Attr*> getAttrs() const {
812    return ArrayRef<const Attr*>(Attrs, NumAttrs);
813  }
814  Stmt *getSubStmt() { return SubStmt; }
815  const Stmt *getSubStmt() const { return SubStmt; }
816
817  SourceRange getSourceRange() const LLVM_READONLY {
818    return SourceRange(AttrLoc, SubStmt->getLocEnd());
819  }
820  child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
821
822  static bool classof(const Stmt *T) {
823    return T->getStmtClass() == AttributedStmtClass;
824  }
825};
826
827
828/// IfStmt - This represents an if/then/else.
829///
830class IfStmt : public Stmt {
831  enum { VAR, COND, THEN, ELSE, END_EXPR };
832  Stmt* SubExprs[END_EXPR];
833
834  SourceLocation IfLoc;
835  SourceLocation ElseLoc;
836
837public:
838  IfStmt(ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond,
839         Stmt *then, SourceLocation EL = SourceLocation(), Stmt *elsev = 0);
840
841  /// \brief Build an empty if/then/else statement
842  explicit IfStmt(EmptyShell Empty) : Stmt(IfStmtClass, Empty) { }
843
844  /// \brief Retrieve the variable declared in this "if" statement, if any.
845  ///
846  /// In the following example, "x" is the condition variable.
847  /// \code
848  /// if (int x = foo()) {
849  ///   printf("x is %d", x);
850  /// }
851  /// \endcode
852  VarDecl *getConditionVariable() const;
853  void setConditionVariable(ASTContext &C, VarDecl *V);
854
855  /// If this IfStmt has a condition variable, return the faux DeclStmt
856  /// associated with the creation of that condition variable.
857  const DeclStmt *getConditionVariableDeclStmt() const {
858    return reinterpret_cast<DeclStmt*>(SubExprs[VAR]);
859  }
860
861  const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
862  void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); }
863  const Stmt *getThen() const { return SubExprs[THEN]; }
864  void setThen(Stmt *S) { SubExprs[THEN] = S; }
865  const Stmt *getElse() const { return SubExprs[ELSE]; }
866  void setElse(Stmt *S) { SubExprs[ELSE] = S; }
867
868  Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
869  Stmt *getThen() { return SubExprs[THEN]; }
870  Stmt *getElse() { return SubExprs[ELSE]; }
871
872  SourceLocation getIfLoc() const { return IfLoc; }
873  void setIfLoc(SourceLocation L) { IfLoc = L; }
874  SourceLocation getElseLoc() const { return ElseLoc; }
875  void setElseLoc(SourceLocation L) { ElseLoc = L; }
876
877  SourceRange getSourceRange() const LLVM_READONLY {
878    if (SubExprs[ELSE])
879      return SourceRange(IfLoc, SubExprs[ELSE]->getLocEnd());
880    else
881      return SourceRange(IfLoc, SubExprs[THEN]->getLocEnd());
882  }
883
884  // Iterators over subexpressions.  The iterators will include iterating
885  // over the initialization expression referenced by the condition variable.
886  child_range children() {
887    return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
888  }
889
890  static bool classof(const Stmt *T) {
891    return T->getStmtClass() == IfStmtClass;
892  }
893};
894
895/// SwitchStmt - This represents a 'switch' stmt.
896///
897class SwitchStmt : public Stmt {
898  enum { VAR, COND, BODY, END_EXPR };
899  Stmt* SubExprs[END_EXPR];
900  // This points to a linked list of case and default statements.
901  SwitchCase *FirstCase;
902  SourceLocation SwitchLoc;
903
904  /// If the SwitchStmt is a switch on an enum value, this records whether
905  /// all the enum values were covered by CaseStmts.  This value is meant to
906  /// be a hint for possible clients.
907  unsigned AllEnumCasesCovered : 1;
908
909public:
910  SwitchStmt(ASTContext &C, VarDecl *Var, Expr *cond);
911
912  /// \brief Build a empty switch statement.
913  explicit SwitchStmt(EmptyShell Empty) : Stmt(SwitchStmtClass, Empty) { }
914
915  /// \brief Retrieve the variable declared in this "switch" statement, if any.
916  ///
917  /// In the following example, "x" is the condition variable.
918  /// \code
919  /// switch (int x = foo()) {
920  ///   case 0: break;
921  ///   // ...
922  /// }
923  /// \endcode
924  VarDecl *getConditionVariable() const;
925  void setConditionVariable(ASTContext &C, VarDecl *V);
926
927  /// If this SwitchStmt has a condition variable, return the faux DeclStmt
928  /// associated with the creation of that condition variable.
929  const DeclStmt *getConditionVariableDeclStmt() const {
930    return reinterpret_cast<DeclStmt*>(SubExprs[VAR]);
931  }
932
933  const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
934  const Stmt *getBody() const { return SubExprs[BODY]; }
935  const SwitchCase *getSwitchCaseList() const { return FirstCase; }
936
937  Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]);}
938  void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); }
939  Stmt *getBody() { return SubExprs[BODY]; }
940  void setBody(Stmt *S) { SubExprs[BODY] = S; }
941  SwitchCase *getSwitchCaseList() { return FirstCase; }
942
943  /// \brief Set the case list for this switch statement.
944  ///
945  /// The caller is responsible for incrementing the retain counts on
946  /// all of the SwitchCase statements in this list.
947  void setSwitchCaseList(SwitchCase *SC) { FirstCase = SC; }
948
949  SourceLocation getSwitchLoc() const { return SwitchLoc; }
950  void setSwitchLoc(SourceLocation L) { SwitchLoc = L; }
951
952  void setBody(Stmt *S, SourceLocation SL) {
953    SubExprs[BODY] = S;
954    SwitchLoc = SL;
955  }
956  void addSwitchCase(SwitchCase *SC) {
957    assert(!SC->getNextSwitchCase()
958           && "case/default already added to a switch");
959    SC->setNextSwitchCase(FirstCase);
960    FirstCase = SC;
961  }
962
963  /// Set a flag in the SwitchStmt indicating that if the 'switch (X)' is a
964  /// switch over an enum value then all cases have been explicitly covered.
965  void setAllEnumCasesCovered() {
966    AllEnumCasesCovered = 1;
967  }
968
969  /// Returns true if the SwitchStmt is a switch of an enum value and all cases
970  /// have been explicitly covered.
971  bool isAllEnumCasesCovered() const {
972    return (bool) AllEnumCasesCovered;
973  }
974
975  SourceRange getSourceRange() const LLVM_READONLY {
976    return SourceRange(SwitchLoc, SubExprs[BODY]->getLocEnd());
977  }
978  // Iterators
979  child_range children() {
980    return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
981  }
982
983  static bool classof(const Stmt *T) {
984    return T->getStmtClass() == SwitchStmtClass;
985  }
986};
987
988
989/// WhileStmt - This represents a 'while' stmt.
990///
991class WhileStmt : public Stmt {
992  enum { VAR, COND, BODY, END_EXPR };
993  Stmt* SubExprs[END_EXPR];
994  SourceLocation WhileLoc;
995public:
996  WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,
997            SourceLocation WL);
998
999  /// \brief Build an empty while statement.
1000  explicit WhileStmt(EmptyShell Empty) : Stmt(WhileStmtClass, Empty) { }
1001
1002  /// \brief Retrieve the variable declared in this "while" statement, if any.
1003  ///
1004  /// In the following example, "x" is the condition variable.
1005  /// \code
1006  /// while (int x = random()) {
1007  ///   // ...
1008  /// }
1009  /// \endcode
1010  VarDecl *getConditionVariable() const;
1011  void setConditionVariable(ASTContext &C, VarDecl *V);
1012
1013  /// If this WhileStmt has a condition variable, return the faux DeclStmt
1014  /// associated with the creation of that condition variable.
1015  const DeclStmt *getConditionVariableDeclStmt() const {
1016    return reinterpret_cast<DeclStmt*>(SubExprs[VAR]);
1017  }
1018
1019  Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
1020  const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
1021  void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
1022  Stmt *getBody() { return SubExprs[BODY]; }
1023  const Stmt *getBody() const { return SubExprs[BODY]; }
1024  void setBody(Stmt *S) { SubExprs[BODY] = S; }
1025
1026  SourceLocation getWhileLoc() const { return WhileLoc; }
1027  void setWhileLoc(SourceLocation L) { WhileLoc = L; }
1028
1029  SourceRange getSourceRange() const LLVM_READONLY {
1030    return SourceRange(WhileLoc, SubExprs[BODY]->getLocEnd());
1031  }
1032  static bool classof(const Stmt *T) {
1033    return T->getStmtClass() == WhileStmtClass;
1034  }
1035
1036  // Iterators
1037  child_range children() {
1038    return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
1039  }
1040};
1041
1042/// DoStmt - This represents a 'do/while' stmt.
1043///
1044class DoStmt : public Stmt {
1045  enum { BODY, COND, END_EXPR };
1046  Stmt* SubExprs[END_EXPR];
1047  SourceLocation DoLoc;
1048  SourceLocation WhileLoc;
1049  SourceLocation RParenLoc;  // Location of final ')' in do stmt condition.
1050
1051public:
1052  DoStmt(Stmt *body, Expr *cond, SourceLocation DL, SourceLocation WL,
1053         SourceLocation RP)
1054    : Stmt(DoStmtClass), DoLoc(DL), WhileLoc(WL), RParenLoc(RP) {
1055    SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
1056    SubExprs[BODY] = body;
1057  }
1058
1059  /// \brief Build an empty do-while statement.
1060  explicit DoStmt(EmptyShell Empty) : Stmt(DoStmtClass, Empty) { }
1061
1062  Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
1063  const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
1064  void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
1065  Stmt *getBody() { return SubExprs[BODY]; }
1066  const Stmt *getBody() const { return SubExprs[BODY]; }
1067  void setBody(Stmt *S) { SubExprs[BODY] = S; }
1068
1069  SourceLocation getDoLoc() const { return DoLoc; }
1070  void setDoLoc(SourceLocation L) { DoLoc = L; }
1071  SourceLocation getWhileLoc() const { return WhileLoc; }
1072  void setWhileLoc(SourceLocation L) { WhileLoc = L; }
1073
1074  SourceLocation getRParenLoc() const { return RParenLoc; }
1075  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1076
1077  SourceRange getSourceRange() const LLVM_READONLY {
1078    return SourceRange(DoLoc, RParenLoc);
1079  }
1080  static bool classof(const Stmt *T) {
1081    return T->getStmtClass() == DoStmtClass;
1082  }
1083
1084  // Iterators
1085  child_range children() {
1086    return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
1087  }
1088};
1089
1090
1091/// ForStmt - This represents a 'for (init;cond;inc)' stmt.  Note that any of
1092/// the init/cond/inc parts of the ForStmt will be null if they were not
1093/// specified in the source.
1094///
1095class ForStmt : public Stmt {
1096  enum { INIT, CONDVAR, COND, INC, BODY, END_EXPR };
1097  Stmt* SubExprs[END_EXPR]; // SubExprs[INIT] is an expression or declstmt.
1098  SourceLocation ForLoc;
1099  SourceLocation LParenLoc, RParenLoc;
1100
1101public:
1102  ForStmt(ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc,
1103          Stmt *Body, SourceLocation FL, SourceLocation LP, SourceLocation RP);
1104
1105  /// \brief Build an empty for statement.
1106  explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) { }
1107
1108  Stmt *getInit() { return SubExprs[INIT]; }
1109
1110  /// \brief Retrieve the variable declared in this "for" statement, if any.
1111  ///
1112  /// In the following example, "y" is the condition variable.
1113  /// \code
1114  /// for (int x = random(); int y = mangle(x); ++x) {
1115  ///   // ...
1116  /// }
1117  /// \endcode
1118  VarDecl *getConditionVariable() const;
1119  void setConditionVariable(ASTContext &C, VarDecl *V);
1120
1121  /// If this ForStmt has a condition variable, return the faux DeclStmt
1122  /// associated with the creation of that condition variable.
1123  const DeclStmt *getConditionVariableDeclStmt() const {
1124    return reinterpret_cast<DeclStmt*>(SubExprs[CONDVAR]);
1125  }
1126
1127  Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
1128  Expr *getInc()  { return reinterpret_cast<Expr*>(SubExprs[INC]); }
1129  Stmt *getBody() { return SubExprs[BODY]; }
1130
1131  const Stmt *getInit() const { return SubExprs[INIT]; }
1132  const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
1133  const Expr *getInc()  const { return reinterpret_cast<Expr*>(SubExprs[INC]); }
1134  const Stmt *getBody() const { return SubExprs[BODY]; }
1135
1136  void setInit(Stmt *S) { SubExprs[INIT] = S; }
1137  void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
1138  void setInc(Expr *E) { SubExprs[INC] = reinterpret_cast<Stmt*>(E); }
1139  void setBody(Stmt *S) { SubExprs[BODY] = S; }
1140
1141  SourceLocation getForLoc() const { return ForLoc; }
1142  void setForLoc(SourceLocation L) { ForLoc = L; }
1143  SourceLocation getLParenLoc() const { return LParenLoc; }
1144  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1145  SourceLocation getRParenLoc() const { return RParenLoc; }
1146  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1147
1148  SourceRange getSourceRange() const LLVM_READONLY {
1149    return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
1150  }
1151  static bool classof(const Stmt *T) {
1152    return T->getStmtClass() == ForStmtClass;
1153  }
1154
1155  // Iterators
1156  child_range children() {
1157    return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
1158  }
1159};
1160
1161/// GotoStmt - This represents a direct goto.
1162///
1163class GotoStmt : public Stmt {
1164  LabelDecl *Label;
1165  SourceLocation GotoLoc;
1166  SourceLocation LabelLoc;
1167public:
1168  GotoStmt(LabelDecl *label, SourceLocation GL, SourceLocation LL)
1169    : Stmt(GotoStmtClass), Label(label), GotoLoc(GL), LabelLoc(LL) {}
1170
1171  /// \brief Build an empty goto statement.
1172  explicit GotoStmt(EmptyShell Empty) : Stmt(GotoStmtClass, Empty) { }
1173
1174  LabelDecl *getLabel() const { return Label; }
1175  void setLabel(LabelDecl *D) { Label = D; }
1176
1177  SourceLocation getGotoLoc() const { return GotoLoc; }
1178  void setGotoLoc(SourceLocation L) { GotoLoc = L; }
1179  SourceLocation getLabelLoc() const { return LabelLoc; }
1180  void setLabelLoc(SourceLocation L) { LabelLoc = L; }
1181
1182  SourceRange getSourceRange() const LLVM_READONLY {
1183    return SourceRange(GotoLoc, LabelLoc);
1184  }
1185  static bool classof(const Stmt *T) {
1186    return T->getStmtClass() == GotoStmtClass;
1187  }
1188
1189  // Iterators
1190  child_range children() { return child_range(); }
1191};
1192
1193/// IndirectGotoStmt - This represents an indirect goto.
1194///
1195class IndirectGotoStmt : public Stmt {
1196  SourceLocation GotoLoc;
1197  SourceLocation StarLoc;
1198  Stmt *Target;
1199public:
1200  IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc,
1201                   Expr *target)
1202    : Stmt(IndirectGotoStmtClass), GotoLoc(gotoLoc), StarLoc(starLoc),
1203      Target((Stmt*)target) {}
1204
1205  /// \brief Build an empty indirect goto statement.
1206  explicit IndirectGotoStmt(EmptyShell Empty)
1207    : Stmt(IndirectGotoStmtClass, Empty) { }
1208
1209  void setGotoLoc(SourceLocation L) { GotoLoc = L; }
1210  SourceLocation getGotoLoc() const { return GotoLoc; }
1211  void setStarLoc(SourceLocation L) { StarLoc = L; }
1212  SourceLocation getStarLoc() const { return StarLoc; }
1213
1214  Expr *getTarget() { return reinterpret_cast<Expr*>(Target); }
1215  const Expr *getTarget() const {return reinterpret_cast<const Expr*>(Target);}
1216  void setTarget(Expr *E) { Target = reinterpret_cast<Stmt*>(E); }
1217
1218  /// getConstantTarget - Returns the fixed target of this indirect
1219  /// goto, if one exists.
1220  LabelDecl *getConstantTarget();
1221  const LabelDecl *getConstantTarget() const {
1222    return const_cast<IndirectGotoStmt*>(this)->getConstantTarget();
1223  }
1224
1225  SourceRange getSourceRange() const LLVM_READONLY {
1226    return SourceRange(GotoLoc, Target->getLocEnd());
1227  }
1228
1229  static bool classof(const Stmt *T) {
1230    return T->getStmtClass() == IndirectGotoStmtClass;
1231  }
1232
1233  // Iterators
1234  child_range children() { return child_range(&Target, &Target+1); }
1235};
1236
1237
1238/// ContinueStmt - This represents a continue.
1239///
1240class ContinueStmt : public Stmt {
1241  SourceLocation ContinueLoc;
1242public:
1243  ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass), ContinueLoc(CL) {}
1244
1245  /// \brief Build an empty continue statement.
1246  explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) { }
1247
1248  SourceLocation getContinueLoc() const { return ContinueLoc; }
1249  void setContinueLoc(SourceLocation L) { ContinueLoc = L; }
1250
1251  SourceRange getSourceRange() const LLVM_READONLY {
1252    return SourceRange(ContinueLoc);
1253  }
1254
1255  static bool classof(const Stmt *T) {
1256    return T->getStmtClass() == ContinueStmtClass;
1257  }
1258
1259  // Iterators
1260  child_range children() { return child_range(); }
1261};
1262
1263/// BreakStmt - This represents a break.
1264///
1265class BreakStmt : public Stmt {
1266  SourceLocation BreakLoc;
1267public:
1268  BreakStmt(SourceLocation BL) : Stmt(BreakStmtClass), BreakLoc(BL) {}
1269
1270  /// \brief Build an empty break statement.
1271  explicit BreakStmt(EmptyShell Empty) : Stmt(BreakStmtClass, Empty) { }
1272
1273  SourceLocation getBreakLoc() const { return BreakLoc; }
1274  void setBreakLoc(SourceLocation L) { BreakLoc = L; }
1275
1276  SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(BreakLoc); }
1277
1278  static bool classof(const Stmt *T) {
1279    return T->getStmtClass() == BreakStmtClass;
1280  }
1281
1282  // Iterators
1283  child_range children() { return child_range(); }
1284};
1285
1286
1287/// ReturnStmt - This represents a return, optionally of an expression:
1288///   return;
1289///   return 4;
1290///
1291/// Note that GCC allows return with no argument in a function declared to
1292/// return a value, and it allows returning a value in functions declared to
1293/// return void.  We explicitly model this in the AST, which means you can't
1294/// depend on the return type of the function and the presence of an argument.
1295///
1296class ReturnStmt : public Stmt {
1297  Stmt *RetExpr;
1298  SourceLocation RetLoc;
1299  const VarDecl *NRVOCandidate;
1300
1301public:
1302  ReturnStmt(SourceLocation RL)
1303    : Stmt(ReturnStmtClass), RetExpr(0), RetLoc(RL), NRVOCandidate(0) { }
1304
1305  ReturnStmt(SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
1306    : Stmt(ReturnStmtClass), RetExpr((Stmt*) E), RetLoc(RL),
1307      NRVOCandidate(NRVOCandidate) {}
1308
1309  /// \brief Build an empty return expression.
1310  explicit ReturnStmt(EmptyShell Empty) : Stmt(ReturnStmtClass, Empty) { }
1311
1312  const Expr *getRetValue() const;
1313  Expr *getRetValue();
1314  void setRetValue(Expr *E) { RetExpr = reinterpret_cast<Stmt*>(E); }
1315
1316  SourceLocation getReturnLoc() const { return RetLoc; }
1317  void setReturnLoc(SourceLocation L) { RetLoc = L; }
1318
1319  /// \brief Retrieve the variable that might be used for the named return
1320  /// value optimization.
1321  ///
1322  /// The optimization itself can only be performed if the variable is
1323  /// also marked as an NRVO object.
1324  const VarDecl *getNRVOCandidate() const { return NRVOCandidate; }
1325  void setNRVOCandidate(const VarDecl *Var) { NRVOCandidate = Var; }
1326
1327  SourceRange getSourceRange() const LLVM_READONLY;
1328
1329  static bool classof(const Stmt *T) {
1330    return T->getStmtClass() == ReturnStmtClass;
1331  }
1332
1333  // Iterators
1334  child_range children() {
1335    if (RetExpr) return child_range(&RetExpr, &RetExpr+1);
1336    return child_range();
1337  }
1338};
1339
1340/// AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
1341///
1342class AsmStmt : public Stmt {
1343protected:
1344  SourceLocation AsmLoc;
1345  /// \brief True if the assembly statement does not have any input or output
1346  /// operands.
1347  bool IsSimple;
1348
1349  /// \brief If true, treat this inline assembly as having side effects.
1350  /// This assembly statement should not be optimized, deleted or moved.
1351  bool IsVolatile;
1352
1353  unsigned NumOutputs;
1354  unsigned NumInputs;
1355  unsigned NumClobbers;
1356
1357  IdentifierInfo **Names;
1358  Stmt **Exprs;
1359
1360  AsmStmt(StmtClass SC, SourceLocation asmloc, bool issimple, bool isvolatile,
1361          unsigned numoutputs, unsigned numinputs, unsigned numclobbers) :
1362    Stmt (SC), AsmLoc(asmloc), IsSimple(issimple), IsVolatile(isvolatile),
1363    NumOutputs(numoutputs), NumInputs(numinputs), NumClobbers(numclobbers) { }
1364
1365public:
1366  /// \brief Build an empty inline-assembly statement.
1367  explicit AsmStmt(StmtClass SC, EmptyShell Empty) :
1368    Stmt(SC, Empty), Names(0), Exprs(0) { }
1369
1370  SourceLocation getAsmLoc() const { return AsmLoc; }
1371  void setAsmLoc(SourceLocation L) { AsmLoc = L; }
1372
1373  bool isSimple() const { return IsSimple; }
1374  void setSimple(bool V) { IsSimple = V; }
1375
1376  bool isVolatile() const { return IsVolatile; }
1377  void setVolatile(bool V) { IsVolatile = V; }
1378
1379  SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(); }
1380
1381  //===--- Asm String Analysis ---===//
1382
1383  /// Assemble final IR asm string.
1384  std::string generateAsmString(ASTContext &C) const;
1385
1386  //===--- Output operands ---===//
1387
1388  unsigned getNumOutputs() const { return NumOutputs; }
1389
1390  IdentifierInfo *getOutputIdentifier(unsigned i) const {
1391    return Names[i];
1392  }
1393
1394  StringRef getOutputName(unsigned i) const {
1395    if (IdentifierInfo *II = getOutputIdentifier(i))
1396      return II->getName();
1397
1398    return StringRef();
1399  }
1400
1401  /// getOutputConstraint - Return the constraint string for the specified
1402  /// output operand.  All output constraints are known to be non-empty (either
1403  /// '=' or '+').
1404  StringRef getOutputConstraint(unsigned i) const;
1405
1406  /// isOutputPlusConstraint - Return true if the specified output constraint
1407  /// is a "+" constraint (which is both an input and an output) or false if it
1408  /// is an "=" constraint (just an output).
1409  bool isOutputPlusConstraint(unsigned i) const {
1410    return getOutputConstraint(i)[0] == '+';
1411  }
1412
1413  const Expr *getOutputExpr(unsigned i) const;
1414
1415  /// getNumPlusOperands - Return the number of output operands that have a "+"
1416  /// constraint.
1417  unsigned getNumPlusOperands() const;
1418
1419  //===--- Input operands ---===//
1420
1421  unsigned getNumInputs() const { return NumInputs; }
1422
1423  IdentifierInfo *getInputIdentifier(unsigned i) const {
1424    return Names[i + NumOutputs];
1425  }
1426
1427  StringRef getInputName(unsigned i) const {
1428    if (IdentifierInfo *II = getInputIdentifier(i))
1429      return II->getName();
1430
1431    return StringRef();
1432  }
1433
1434  /// getInputConstraint - Return the specified input constraint.  Unlike output
1435  /// constraints, these can be empty.
1436  StringRef getInputConstraint(unsigned i) const;
1437
1438  const Expr *getInputExpr(unsigned i) const;
1439
1440  //===--- Other ---===//
1441
1442  unsigned getNumClobbers() const { return NumClobbers; }
1443  StringRef getClobber(unsigned i) const;
1444
1445  static bool classof(const Stmt *T) {
1446    return T->getStmtClass() == GCCAsmStmtClass ||
1447      T->getStmtClass() == MSAsmStmtClass;
1448  }
1449
1450  // Input expr iterators.
1451
1452  typedef ExprIterator inputs_iterator;
1453  typedef ConstExprIterator const_inputs_iterator;
1454
1455  inputs_iterator begin_inputs() {
1456    return &Exprs[0] + NumOutputs;
1457  }
1458
1459  inputs_iterator end_inputs() {
1460    return &Exprs[0] + NumOutputs + NumInputs;
1461  }
1462
1463  const_inputs_iterator begin_inputs() const {
1464    return &Exprs[0] + NumOutputs;
1465  }
1466
1467  const_inputs_iterator end_inputs() const {
1468    return &Exprs[0] + NumOutputs + NumInputs;
1469  }
1470
1471  // Output expr iterators.
1472
1473  typedef ExprIterator outputs_iterator;
1474  typedef ConstExprIterator const_outputs_iterator;
1475
1476  outputs_iterator begin_outputs() {
1477    return &Exprs[0];
1478  }
1479  outputs_iterator end_outputs() {
1480    return &Exprs[0] + NumOutputs;
1481  }
1482
1483  const_outputs_iterator begin_outputs() const {
1484    return &Exprs[0];
1485  }
1486  const_outputs_iterator end_outputs() const {
1487    return &Exprs[0] + NumOutputs;
1488  }
1489
1490  child_range children() {
1491    return child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs);
1492  }
1493};
1494
1495/// This represents a GCC inline-assembly statement extension.
1496///
1497class GCCAsmStmt : public AsmStmt {
1498  SourceLocation RParenLoc;
1499  StringLiteral *AsmStr;
1500
1501  // FIXME: If we wanted to, we could allocate all of these in one big array.
1502  StringLiteral **Constraints;
1503  StringLiteral **Clobbers;
1504
1505public:
1506  GCCAsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple,
1507             bool isvolatile, unsigned numoutputs, unsigned numinputs,
1508             IdentifierInfo **names, StringLiteral **constraints, Expr **exprs,
1509             StringLiteral *asmstr, unsigned numclobbers,
1510             StringLiteral **clobbers, SourceLocation rparenloc);
1511
1512  /// \brief Build an empty inline-assembly statement.
1513  explicit GCCAsmStmt(EmptyShell Empty) : AsmStmt(GCCAsmStmtClass, Empty),
1514    Constraints(0), Clobbers(0) { }
1515
1516  SourceLocation getRParenLoc() const { return RParenLoc; }
1517  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1518
1519  //===--- Asm String Analysis ---===//
1520
1521  const StringLiteral *getAsmString() const { return AsmStr; }
1522  StringLiteral *getAsmString() { return AsmStr; }
1523  void setAsmString(StringLiteral *E) { AsmStr = E; }
1524
1525  /// AsmStringPiece - this is part of a decomposed asm string specification
1526  /// (for use with the AnalyzeAsmString function below).  An asm string is
1527  /// considered to be a concatenation of these parts.
1528  class AsmStringPiece {
1529  public:
1530    enum Kind {
1531      String,  // String in .ll asm string form, "$" -> "$$" and "%%" -> "%".
1532      Operand  // Operand reference, with optional modifier %c4.
1533    };
1534  private:
1535    Kind MyKind;
1536    std::string Str;
1537    unsigned OperandNo;
1538  public:
1539    AsmStringPiece(const std::string &S) : MyKind(String), Str(S) {}
1540    AsmStringPiece(unsigned OpNo, char Modifier)
1541      : MyKind(Operand), Str(), OperandNo(OpNo) {
1542      Str += Modifier;
1543    }
1544
1545    bool isString() const { return MyKind == String; }
1546    bool isOperand() const { return MyKind == Operand; }
1547
1548    const std::string &getString() const {
1549      assert(isString());
1550      return Str;
1551    }
1552
1553    unsigned getOperandNo() const {
1554      assert(isOperand());
1555      return OperandNo;
1556    }
1557
1558    /// getModifier - Get the modifier for this operand, if present.  This
1559    /// returns '\0' if there was no modifier.
1560    char getModifier() const {
1561      assert(isOperand());
1562      return Str[0];
1563    }
1564  };
1565
1566  /// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing
1567  /// it into pieces.  If the asm string is erroneous, emit errors and return
1568  /// true, otherwise return false.  This handles canonicalization and
1569  /// translation of strings from GCC syntax to LLVM IR syntax, and handles
1570  //// flattening of named references like %[foo] to Operand AsmStringPiece's.
1571  unsigned AnalyzeAsmString(SmallVectorImpl<AsmStringPiece> &Pieces,
1572                            ASTContext &C, unsigned &DiagOffs) const;
1573
1574  /// Assemble final IR asm string.
1575  std::string generateAsmString(ASTContext &C) const;
1576
1577  //===--- Output operands ---===//
1578
1579  StringRef getOutputConstraint(unsigned i) const;
1580
1581  const StringLiteral *getOutputConstraintLiteral(unsigned i) const {
1582    return Constraints[i];
1583  }
1584  StringLiteral *getOutputConstraintLiteral(unsigned i) {
1585    return Constraints[i];
1586  }
1587
1588  Expr *getOutputExpr(unsigned i);
1589
1590  const Expr *getOutputExpr(unsigned i) const {
1591    return const_cast<GCCAsmStmt*>(this)->getOutputExpr(i);
1592  }
1593
1594  //===--- Input operands ---===//
1595
1596  StringRef getInputConstraint(unsigned i) const;
1597
1598  const StringLiteral *getInputConstraintLiteral(unsigned i) const {
1599    return Constraints[i + NumOutputs];
1600  }
1601  StringLiteral *getInputConstraintLiteral(unsigned i) {
1602    return Constraints[i + NumOutputs];
1603  }
1604
1605  Expr *getInputExpr(unsigned i);
1606  void setInputExpr(unsigned i, Expr *E);
1607
1608  const Expr *getInputExpr(unsigned i) const {
1609    return const_cast<GCCAsmStmt*>(this)->getInputExpr(i);
1610  }
1611
1612  void setOutputsAndInputsAndClobbers(ASTContext &C,
1613                                      IdentifierInfo **Names,
1614                                      StringLiteral **Constraints,
1615                                      Stmt **Exprs,
1616                                      unsigned NumOutputs,
1617                                      unsigned NumInputs,
1618                                      StringLiteral **Clobbers,
1619                                      unsigned NumClobbers);
1620
1621  //===--- Other ---===//
1622
1623  /// getNamedOperand - Given a symbolic operand reference like %[foo],
1624  /// translate this into a numeric value needed to reference the same operand.
1625  /// This returns -1 if the operand name is invalid.
1626  int getNamedOperand(StringRef SymbolicName) const;
1627
1628  StringRef getClobber(unsigned i) const;
1629  StringLiteral *getClobberStringLiteral(unsigned i) { return Clobbers[i]; }
1630  const StringLiteral *getClobberStringLiteral(unsigned i) const {
1631    return Clobbers[i];
1632  }
1633
1634  SourceRange getSourceRange() const LLVM_READONLY {
1635    return SourceRange(AsmLoc, RParenLoc);
1636  }
1637
1638  static bool classof(const Stmt *T) {
1639    return T->getStmtClass() == GCCAsmStmtClass;
1640  }
1641};
1642
1643/// This represents a Microsoft inline-assembly statement extension.
1644///
1645class MSAsmStmt : public AsmStmt {
1646  SourceLocation AsmLoc, LBraceLoc, EndLoc;
1647  std::string AsmStr;
1648
1649  unsigned NumAsmToks;
1650
1651  Token *AsmToks;
1652  StringRef *Constraints;
1653  StringRef *Clobbers;
1654
1655public:
1656  MSAsmStmt(ASTContext &C, SourceLocation asmloc, SourceLocation lbraceloc,
1657            bool issimple, bool isvolatile, ArrayRef<Token> asmtoks,
1658            unsigned numoutputs, unsigned numinputs,
1659            ArrayRef<IdentifierInfo*> names, ArrayRef<StringRef> constraints,
1660            ArrayRef<Expr*> exprs, StringRef asmstr,
1661            ArrayRef<StringRef> clobbers, SourceLocation endloc);
1662
1663  /// \brief Build an empty MS-style inline-assembly statement.
1664  explicit MSAsmStmt(EmptyShell Empty) : AsmStmt(MSAsmStmtClass, Empty),
1665    NumAsmToks(0), AsmToks(0), Constraints(0), Clobbers(0) { }
1666
1667  SourceLocation getLBraceLoc() const { return LBraceLoc; }
1668  void setLBraceLoc(SourceLocation L) { LBraceLoc = L; }
1669  SourceLocation getEndLoc() const { return EndLoc; }
1670  void setEndLoc(SourceLocation L) { EndLoc = L; }
1671
1672  bool hasBraces() const { return LBraceLoc.isValid(); }
1673
1674  unsigned getNumAsmToks() { return NumAsmToks; }
1675  Token *getAsmToks() { return AsmToks; }
1676
1677  //===--- Asm String Analysis ---===//
1678
1679  const std::string *getAsmString() const { return &AsmStr; }
1680  std::string *getAsmString() { return &AsmStr; }
1681  void setAsmString(StringRef &E) { AsmStr = E.str(); }
1682
1683  /// Assemble final IR asm string.
1684  std::string generateAsmString(ASTContext &C) const;
1685
1686  //===--- Output operands ---===//
1687
1688  StringRef getOutputConstraint(unsigned i) const {
1689    return Constraints[i];
1690  }
1691
1692  Expr *getOutputExpr(unsigned i);
1693
1694  const Expr *getOutputExpr(unsigned i) const {
1695    return const_cast<MSAsmStmt*>(this)->getOutputExpr(i);
1696  }
1697
1698  //===--- Input operands ---===//
1699
1700  StringRef getInputConstraint(unsigned i) const {
1701    return Constraints[i + NumOutputs];
1702  }
1703
1704  Expr *getInputExpr(unsigned i);
1705  void setInputExpr(unsigned i, Expr *E);
1706
1707  const Expr *getInputExpr(unsigned i) const {
1708    return const_cast<MSAsmStmt*>(this)->getInputExpr(i);
1709  }
1710
1711  //===--- Other ---===//
1712
1713  StringRef getClobber(unsigned i) const { return Clobbers[i]; }
1714
1715  SourceRange getSourceRange() const LLVM_READONLY {
1716    return SourceRange(AsmLoc, EndLoc);
1717  }
1718  static bool classof(const Stmt *T) {
1719    return T->getStmtClass() == MSAsmStmtClass;
1720  }
1721
1722  child_range children() {
1723    return child_range(&Exprs[0], &Exprs[0]);
1724  }
1725};
1726
1727class SEHExceptStmt : public Stmt {
1728  SourceLocation  Loc;
1729  Stmt           *Children[2];
1730
1731  enum { FILTER_EXPR, BLOCK };
1732
1733  SEHExceptStmt(SourceLocation Loc,
1734                Expr *FilterExpr,
1735                Stmt *Block);
1736
1737  friend class ASTReader;
1738  friend class ASTStmtReader;
1739  explicit SEHExceptStmt(EmptyShell E) : Stmt(SEHExceptStmtClass, E) { }
1740
1741public:
1742  static SEHExceptStmt* Create(ASTContext &C,
1743                               SourceLocation ExceptLoc,
1744                               Expr *FilterExpr,
1745                               Stmt *Block);
1746  SourceRange getSourceRange() const LLVM_READONLY {
1747    return SourceRange(getExceptLoc(), getEndLoc());
1748  }
1749
1750  SourceLocation getExceptLoc() const { return Loc; }
1751  SourceLocation getEndLoc() const { return getBlock()->getLocEnd(); }
1752
1753  Expr *getFilterExpr() const {
1754    return reinterpret_cast<Expr*>(Children[FILTER_EXPR]);
1755  }
1756
1757  CompoundStmt *getBlock() const {
1758    return llvm::cast<CompoundStmt>(Children[BLOCK]);
1759  }
1760
1761  child_range children() {
1762    return child_range(Children,Children+2);
1763  }
1764
1765  static bool classof(const Stmt *T) {
1766    return T->getStmtClass() == SEHExceptStmtClass;
1767  }
1768
1769};
1770
1771class SEHFinallyStmt : public Stmt {
1772  SourceLocation  Loc;
1773  Stmt           *Block;
1774
1775  SEHFinallyStmt(SourceLocation Loc,
1776                 Stmt *Block);
1777
1778  friend class ASTReader;
1779  friend class ASTStmtReader;
1780  explicit SEHFinallyStmt(EmptyShell E) : Stmt(SEHFinallyStmtClass, E) { }
1781
1782public:
1783  static SEHFinallyStmt* Create(ASTContext &C,
1784                                SourceLocation FinallyLoc,
1785                                Stmt *Block);
1786
1787  SourceRange getSourceRange() const LLVM_READONLY {
1788    return SourceRange(getFinallyLoc(), getEndLoc());
1789  }
1790
1791  SourceLocation getFinallyLoc() const { return Loc; }
1792  SourceLocation getEndLoc() const { return Block->getLocEnd(); }
1793
1794  CompoundStmt *getBlock() const { return llvm::cast<CompoundStmt>(Block); }
1795
1796  child_range children() {
1797    return child_range(&Block,&Block+1);
1798  }
1799
1800  static bool classof(const Stmt *T) {
1801    return T->getStmtClass() == SEHFinallyStmtClass;
1802  }
1803
1804};
1805
1806class SEHTryStmt : public Stmt {
1807  bool            IsCXXTry;
1808  SourceLocation  TryLoc;
1809  Stmt           *Children[2];
1810
1811  enum { TRY = 0, HANDLER = 1 };
1812
1813  SEHTryStmt(bool isCXXTry, // true if 'try' otherwise '__try'
1814             SourceLocation TryLoc,
1815             Stmt *TryBlock,
1816             Stmt *Handler);
1817
1818  friend class ASTReader;
1819  friend class ASTStmtReader;
1820  explicit SEHTryStmt(EmptyShell E) : Stmt(SEHTryStmtClass, E) { }
1821
1822public:
1823  static SEHTryStmt* Create(ASTContext &C,
1824                            bool isCXXTry,
1825                            SourceLocation TryLoc,
1826                            Stmt *TryBlock,
1827                            Stmt *Handler);
1828
1829  SourceRange getSourceRange() const LLVM_READONLY {
1830    return SourceRange(getTryLoc(), getEndLoc());
1831  }
1832
1833  SourceLocation getTryLoc() const { return TryLoc; }
1834  SourceLocation getEndLoc() const { return Children[HANDLER]->getLocEnd(); }
1835
1836  bool getIsCXXTry() const { return IsCXXTry; }
1837
1838  CompoundStmt* getTryBlock() const {
1839    return llvm::cast<CompoundStmt>(Children[TRY]);
1840  }
1841
1842  Stmt *getHandler() const { return Children[HANDLER]; }
1843
1844  /// Returns 0 if not defined
1845  SEHExceptStmt  *getExceptHandler() const;
1846  SEHFinallyStmt *getFinallyHandler() const;
1847
1848  child_range children() {
1849    return child_range(Children,Children+2);
1850  }
1851
1852  static bool classof(const Stmt *T) {
1853    return T->getStmtClass() == SEHTryStmtClass;
1854  }
1855};
1856
1857}  // end namespace clang
1858
1859#endif
1860