1 //===--- Stmt.h - Classes for representing statements -----------*- C++ -*-===//
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 defines the Stmt interface and subclasses.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_AST_STMT_H
15 #define LLVM_CLANG_AST_STMT_H
17 #include "llvm/Support/Casting.h"
18 #include "llvm/Support/raw_ostream.h"
19 #include "clang/Basic/SourceLocation.h"
20 #include "clang/AST/PrettyPrinter.h"
21 #include "clang/AST/StmtIterator.h"
22 #include "clang/AST/DeclGroup.h"
23 #include "llvm/ADT/SmallVector.h"
24 #include "clang/AST/ASTContext.h"
26 using llvm::dyn_cast_or_null;
29 class FoldingSetNodeID;
43 //===----------------------------------------------------------------------===//
44 // ExprIterator - Iterators for iterating over Stmt* arrays that contain
45 // only Expr*. This is needed because AST nodes use Stmt* arrays to store
46 // references to children (to be compatible with StmtIterator).
47 //===----------------------------------------------------------------------===//
55 ExprIterator(Stmt** i) : I(i) {}
56 ExprIterator() : I(0) {}
57 ExprIterator& operator++() { ++I; return *this; }
58 ExprIterator operator-(size_t i) { return I-i; }
59 ExprIterator operator+(size_t i) { return I+i; }
60 Expr* operator[](size_t idx);
61 // FIXME: Verify that this will correctly return a signed distance.
62 signed operator-(const ExprIterator& R) const { return I - R.I; }
63 Expr* operator*() const;
64 Expr* operator->() const;
65 bool operator==(const ExprIterator& R) const { return I == R.I; }
66 bool operator!=(const ExprIterator& R) const { return I != R.I; }
67 bool operator>(const ExprIterator& R) const { return I > R.I; }
68 bool operator>=(const ExprIterator& R) const { return I >= R.I; }
71 class ConstExprIterator {
72 const Stmt * const *I;
74 ConstExprIterator(const Stmt * const *i) : I(i) {}
75 ConstExprIterator() : I(0) {}
76 ConstExprIterator& operator++() { ++I; return *this; }
77 ConstExprIterator operator+(size_t i) const { return I+i; }
78 ConstExprIterator operator-(size_t i) const { return I-i; }
79 const Expr * operator[](size_t idx) const;
80 signed operator-(const ConstExprIterator& R) const { return I - R.I; }
81 const Expr * operator*() const;
82 const Expr * operator->() const;
83 bool operator==(const ConstExprIterator& R) const { return I == R.I; }
84 bool operator!=(const ConstExprIterator& R) const { return I != R.I; }
85 bool operator>(const ConstExprIterator& R) const { return I > R.I; }
86 bool operator>=(const ConstExprIterator& R) const { return I >= R.I; }
89 //===----------------------------------------------------------------------===//
90 // AST classes for statements.
91 //===----------------------------------------------------------------------===//
93 /// Stmt - This represents one statement.
99 #define STMT(CLASS, PARENT) CLASS##Class,
100 #define STMT_RANGE(BASE, FIRST, LAST) \
101 first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class,
102 #define LAST_STMT_RANGE(BASE, FIRST, LAST) \
103 first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class
104 #define ABSTRACT_STMT(STMT)
105 #include "clang/AST/StmtNodes.inc"
108 // Make vanilla 'new' and 'delete' illegal for Stmts.
110 void* operator new(size_t bytes) throw() {
111 assert(0 && "Stmts cannot be allocated with regular 'new'.");
114 void operator delete(void* data) throw() {
115 assert(0 && "Stmts cannot be released with regular 'delete'.");
118 class StmtBitfields {
121 /// \brief The statement class.
124 enum { NumStmtBits = 8 };
126 class CompoundStmtBitfields {
127 friend class CompoundStmt;
128 unsigned : NumStmtBits;
130 unsigned NumStmts : 32 - NumStmtBits;
133 class ExprBitfields {
135 friend class DeclRefExpr; // computeDependence
136 friend class InitListExpr; // ctor
137 friend class DesignatedInitExpr; // ctor
138 friend class BlockDeclRefExpr; // ctor
139 friend class ASTStmtReader; // deserialization
140 friend class CXXNewExpr; // ctor
141 friend class DependentScopeDeclRefExpr; // ctor
142 friend class CXXConstructExpr; // ctor
143 friend class CallExpr; // ctor
144 friend class OffsetOfExpr; // ctor
145 friend class ObjCMessageExpr; // ctor
146 friend class ShuffleVectorExpr; // ctor
147 friend class ParenListExpr; // ctor
148 friend class CXXUnresolvedConstructExpr; // ctor
149 friend class CXXDependentScopeMemberExpr; // ctor
150 friend class OverloadExpr; // ctor
151 unsigned : NumStmtBits;
153 unsigned ValueKind : 2;
154 unsigned ObjectKind : 2;
155 unsigned TypeDependent : 1;
156 unsigned ValueDependent : 1;
157 unsigned ContainsUnexpandedParameterPack : 1;
159 enum { NumExprBits = 15 };
161 class CastExprBitfields {
162 friend class CastExpr;
163 unsigned : NumExprBits;
166 unsigned BasePathSize : 32 - 6 - NumExprBits;
169 class CallExprBitfields {
170 friend class CallExpr;
171 unsigned : NumExprBits;
173 unsigned NumPreArgs : 1;
177 // FIXME: this is wasteful on 64-bit platforms.
180 StmtBitfields StmtBits;
181 CompoundStmtBitfields CompoundStmtBits;
182 ExprBitfields ExprBits;
183 CastExprBitfields CastExprBits;
184 CallExprBitfields CallExprBits;
187 friend class ASTStmtReader;
190 // Only allow allocation of Stmts using the allocator in ASTContext
191 // or by doing a placement new.
192 void* operator new(size_t bytes, ASTContext& C,
193 unsigned alignment = 8) throw() {
194 return ::operator new(bytes, C, alignment);
197 void* operator new(size_t bytes, ASTContext* C,
198 unsigned alignment = 8) throw() {
199 return ::operator new(bytes, *C, alignment);
202 void* operator new(size_t bytes, void* mem) throw() {
206 void operator delete(void*, ASTContext&, unsigned) throw() { }
207 void operator delete(void*, ASTContext*, unsigned) throw() { }
208 void operator delete(void*, std::size_t) throw() { }
209 void operator delete(void*, void*) throw() { }
212 /// \brief A placeholder type used to construct an empty shell of a
213 /// type, that will be filled in later (e.g., by some
214 /// de-serialization).
215 struct EmptyShell { };
218 /// \brief Construct an empty statement.
219 explicit Stmt(StmtClass SC, EmptyShell) {
220 StmtBits.sClass = SC;
221 if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
226 StmtBits.sClass = SC;
227 if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
230 StmtClass getStmtClass() const {
231 return static_cast<StmtClass>(StmtBits.sClass);
233 const char *getStmtClassName() const;
235 /// SourceLocation tokens are not useful in isolation - they are low level
236 /// value objects created/interpreted by SourceManager. We assume AST
237 /// clients will have a pointer to the respective SourceManager.
238 SourceRange getSourceRange() const;
240 SourceLocation getLocStart() const { return getSourceRange().getBegin(); }
241 SourceLocation getLocEnd() const { return getSourceRange().getEnd(); }
243 // global temp stats (until we have a per-module visitor)
244 static void addStmtClass(const StmtClass s);
245 static bool CollectingStats(bool Enable = false);
246 static void PrintStats();
248 /// dump - This does a local dump of the specified AST fragment. It dumps the
249 /// specified node and a few nodes underneath it, but not the whole subtree.
250 /// This is useful in a debugger.
252 void dump(SourceManager &SM) const;
253 void dump(llvm::raw_ostream &OS, SourceManager &SM) const;
255 /// dumpAll - This does a dump of the specified AST fragment and all subtrees.
256 void dumpAll() const;
257 void dumpAll(SourceManager &SM) const;
259 /// dumpPretty/printPretty - These two methods do a "pretty print" of the AST
260 /// back to its original source language syntax.
261 void dumpPretty(ASTContext& Context) const;
262 void printPretty(llvm::raw_ostream &OS, PrinterHelper *Helper,
263 const PrintingPolicy &Policy,
264 unsigned Indentation = 0) const {
265 printPretty(OS, *(ASTContext*)0, Helper, Policy, Indentation);
267 void printPretty(llvm::raw_ostream &OS, ASTContext &Context,
268 PrinterHelper *Helper,
269 const PrintingPolicy &Policy,
270 unsigned Indentation = 0) const;
272 /// viewAST - Visualize an AST rooted at this Stmt* using GraphViz. Only
273 /// works on systems with GraphViz (Mac OS X) or dot+gv installed.
274 void viewAST() const;
276 // Implement isa<T> support.
277 static bool classof(const Stmt *) { return true; }
279 /// hasImplicitControlFlow - Some statements (e.g. short circuited operations)
280 /// contain implicit control-flow in the order their subexpressions
281 /// are evaluated. This predicate returns true if this statement has
282 /// such implicit control-flow. Such statements are also specially handled
284 bool hasImplicitControlFlow() const;
286 /// Child Iterators: All subclasses must implement 'children'
287 /// to permit easy iteration over the substatements/subexpessions of an
288 /// AST node. This permits easy iteration over all nodes in the AST.
289 typedef StmtIterator child_iterator;
290 typedef ConstStmtIterator const_child_iterator;
292 typedef StmtRange child_range;
293 typedef ConstStmtRange const_child_range;
295 child_range children();
296 const_child_range children() const {
297 return const_cast<Stmt*>(this)->children();
300 child_iterator child_begin() { return children().first; }
301 child_iterator child_end() { return children().second; }
303 const_child_iterator child_begin() const { return children().first; }
304 const_child_iterator child_end() const { return children().second; }
306 /// \brief Produce a unique representation of the given statement.
308 /// \brief ID once the profiling operation is complete, will contain
309 /// the unique representation of the given statement.
311 /// \brief Context the AST context in which the statement resides
313 /// \brief Canonical whether the profile should be based on the canonical
314 /// representation of this statement (e.g., where non-type template
315 /// parameters are identified by index/level rather than their
316 /// declaration pointers) or the exact representation of the statement as
317 /// written in the source.
318 void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
322 /// DeclStmt - Adaptor class for mixing declarations with statements and
323 /// expressions. For example, CompoundStmt mixes statements, expressions
324 /// and declarations (variables, types). Another example is ForStmt, where
325 /// the first statement can be an expression or a declaration.
327 class DeclStmt : public Stmt {
329 SourceLocation StartLoc, EndLoc;
332 DeclStmt(DeclGroupRef dg, SourceLocation startLoc,
333 SourceLocation endLoc) : Stmt(DeclStmtClass), DG(dg),
334 StartLoc(startLoc), EndLoc(endLoc) {}
336 /// \brief Build an empty declaration statement.
337 explicit DeclStmt(EmptyShell Empty) : Stmt(DeclStmtClass, Empty) { }
339 /// isSingleDecl - This method returns true if this DeclStmt refers
340 /// to a single Decl.
341 bool isSingleDecl() const {
342 return DG.isSingleDecl();
345 const Decl *getSingleDecl() const { return DG.getSingleDecl(); }
346 Decl *getSingleDecl() { return DG.getSingleDecl(); }
348 const DeclGroupRef getDeclGroup() const { return DG; }
349 DeclGroupRef getDeclGroup() { return DG; }
350 void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
352 SourceLocation getStartLoc() const { return StartLoc; }
353 void setStartLoc(SourceLocation L) { StartLoc = L; }
354 SourceLocation getEndLoc() const { return EndLoc; }
355 void setEndLoc(SourceLocation L) { EndLoc = L; }
357 SourceRange getSourceRange() const {
358 return SourceRange(StartLoc, EndLoc);
361 static bool classof(const Stmt *T) {
362 return T->getStmtClass() == DeclStmtClass;
364 static bool classof(const DeclStmt *) { return true; }
366 // Iterators over subexpressions.
367 child_range children() {
368 return child_range(child_iterator(DG.begin(), DG.end()),
369 child_iterator(DG.end(), DG.end()));
372 typedef DeclGroupRef::iterator decl_iterator;
373 typedef DeclGroupRef::const_iterator const_decl_iterator;
375 decl_iterator decl_begin() { return DG.begin(); }
376 decl_iterator decl_end() { return DG.end(); }
377 const_decl_iterator decl_begin() const { return DG.begin(); }
378 const_decl_iterator decl_end() const { return DG.end(); }
381 /// NullStmt - This is the null statement ";": C99 6.8.3p3.
383 class NullStmt : public Stmt {
384 SourceLocation SemiLoc;
386 /// \brief Whether the null statement was preceded by an empty macro, e.g:
391 bool LeadingEmptyMacro;
393 NullStmt(SourceLocation L, bool LeadingEmptyMacro = false)
394 : Stmt(NullStmtClass), SemiLoc(L), LeadingEmptyMacro(LeadingEmptyMacro) {}
396 /// \brief Build an empty null statement.
397 explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty) { }
399 SourceLocation getSemiLoc() const { return SemiLoc; }
400 void setSemiLoc(SourceLocation L) { SemiLoc = L; }
402 bool hasLeadingEmptyMacro() const { return LeadingEmptyMacro; }
404 SourceRange getSourceRange() const { return SourceRange(SemiLoc); }
406 static bool classof(const Stmt *T) {
407 return T->getStmtClass() == NullStmtClass;
409 static bool classof(const NullStmt *) { return true; }
411 child_range children() { return child_range(); }
413 friend class ASTStmtReader;
414 friend class ASTStmtWriter;
417 /// CompoundStmt - This represents a group of statements like { stmt stmt }.
419 class CompoundStmt : public Stmt {
421 SourceLocation LBracLoc, RBracLoc;
423 CompoundStmt(ASTContext& C, Stmt **StmtStart, unsigned NumStmts,
424 SourceLocation LB, SourceLocation RB)
425 : Stmt(CompoundStmtClass), LBracLoc(LB), RBracLoc(RB) {
426 CompoundStmtBits.NumStmts = NumStmts;
433 Body = new (C) Stmt*[NumStmts];
434 memcpy(Body, StmtStart, NumStmts * sizeof(*Body));
437 // \brief Build an empty compound statement.
438 explicit CompoundStmt(EmptyShell Empty)
439 : Stmt(CompoundStmtClass, Empty), Body(0) {
440 CompoundStmtBits.NumStmts = 0;
443 void setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts);
445 bool body_empty() const { return CompoundStmtBits.NumStmts == 0; }
446 unsigned size() const { return CompoundStmtBits.NumStmts; }
448 typedef Stmt** body_iterator;
449 body_iterator body_begin() { return Body; }
450 body_iterator body_end() { return Body + size(); }
451 Stmt *body_back() { return !body_empty() ? Body[size()-1] : 0; }
453 void setLastStmt(Stmt *S) {
454 assert(!body_empty() && "setLastStmt");
458 typedef Stmt* const * const_body_iterator;
459 const_body_iterator body_begin() const { return Body; }
460 const_body_iterator body_end() const { return Body + size(); }
461 const Stmt *body_back() const { return !body_empty() ? Body[size()-1] : 0; }
463 typedef std::reverse_iterator<body_iterator> reverse_body_iterator;
464 reverse_body_iterator body_rbegin() {
465 return reverse_body_iterator(body_end());
467 reverse_body_iterator body_rend() {
468 return reverse_body_iterator(body_begin());
471 typedef std::reverse_iterator<const_body_iterator>
472 const_reverse_body_iterator;
474 const_reverse_body_iterator body_rbegin() const {
475 return const_reverse_body_iterator(body_end());
478 const_reverse_body_iterator body_rend() const {
479 return const_reverse_body_iterator(body_begin());
482 SourceRange getSourceRange() const {
483 return SourceRange(LBracLoc, RBracLoc);
486 SourceLocation getLBracLoc() const { return LBracLoc; }
487 void setLBracLoc(SourceLocation L) { LBracLoc = L; }
488 SourceLocation getRBracLoc() const { return RBracLoc; }
489 void setRBracLoc(SourceLocation L) { RBracLoc = L; }
491 static bool classof(const Stmt *T) {
492 return T->getStmtClass() == CompoundStmtClass;
494 static bool classof(const CompoundStmt *) { return true; }
497 child_range children() {
498 return child_range(&Body[0], &Body[0]+CompoundStmtBits.NumStmts);
502 // SwitchCase is the base class for CaseStmt and DefaultStmt,
503 class SwitchCase : public Stmt {
505 // A pointer to the following CaseStmt or DefaultStmt class,
506 // used by SwitchStmt.
507 SwitchCase *NextSwitchCase;
509 SwitchCase(StmtClass SC) : Stmt(SC), NextSwitchCase(0) {}
512 const SwitchCase *getNextSwitchCase() const { return NextSwitchCase; }
514 SwitchCase *getNextSwitchCase() { return NextSwitchCase; }
516 void setNextSwitchCase(SwitchCase *SC) { NextSwitchCase = SC; }
520 SourceRange getSourceRange() const { return SourceRange(); }
522 static bool classof(const Stmt *T) {
523 return T->getStmtClass() == CaseStmtClass ||
524 T->getStmtClass() == DefaultStmtClass;
526 static bool classof(const SwitchCase *) { return true; }
529 class CaseStmt : public SwitchCase {
530 enum { SUBSTMT, LHS, RHS, END_EXPR };
531 Stmt* SubExprs[END_EXPR]; // The expression for the RHS is Non-null for
532 // GNU "case 1 ... 4" extension
533 SourceLocation CaseLoc;
534 SourceLocation EllipsisLoc;
535 SourceLocation ColonLoc;
537 CaseStmt(Expr *lhs, Expr *rhs, SourceLocation caseLoc,
538 SourceLocation ellipsisLoc, SourceLocation colonLoc)
539 : SwitchCase(CaseStmtClass) {
540 SubExprs[SUBSTMT] = 0;
541 SubExprs[LHS] = reinterpret_cast<Stmt*>(lhs);
542 SubExprs[RHS] = reinterpret_cast<Stmt*>(rhs);
544 EllipsisLoc = ellipsisLoc;
548 /// \brief Build an empty switch case statement.
549 explicit CaseStmt(EmptyShell Empty) : SwitchCase(CaseStmtClass) { }
551 SourceLocation getCaseLoc() const { return CaseLoc; }
552 void setCaseLoc(SourceLocation L) { CaseLoc = L; }
553 SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
554 void setEllipsisLoc(SourceLocation L) { EllipsisLoc = L; }
555 SourceLocation getColonLoc() const { return ColonLoc; }
556 void setColonLoc(SourceLocation L) { ColonLoc = L; }
558 Expr *getLHS() { return reinterpret_cast<Expr*>(SubExprs[LHS]); }
559 Expr *getRHS() { return reinterpret_cast<Expr*>(SubExprs[RHS]); }
560 Stmt *getSubStmt() { return SubExprs[SUBSTMT]; }
562 const Expr *getLHS() const {
563 return reinterpret_cast<const Expr*>(SubExprs[LHS]);
565 const Expr *getRHS() const {
566 return reinterpret_cast<const Expr*>(SubExprs[RHS]);
568 const Stmt *getSubStmt() const { return SubExprs[SUBSTMT]; }
570 void setSubStmt(Stmt *S) { SubExprs[SUBSTMT] = S; }
571 void setLHS(Expr *Val) { SubExprs[LHS] = reinterpret_cast<Stmt*>(Val); }
572 void setRHS(Expr *Val) { SubExprs[RHS] = reinterpret_cast<Stmt*>(Val); }
575 SourceRange getSourceRange() const {
576 // Handle deeply nested case statements with iteration instead of recursion.
577 const CaseStmt *CS = this;
578 while (const CaseStmt *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt()))
581 return SourceRange(CaseLoc, CS->getSubStmt()->getLocEnd());
583 static bool classof(const Stmt *T) {
584 return T->getStmtClass() == CaseStmtClass;
586 static bool classof(const CaseStmt *) { return true; }
589 child_range children() {
590 return child_range(&SubExprs[0], &SubExprs[END_EXPR]);
594 class DefaultStmt : public SwitchCase {
596 SourceLocation DefaultLoc;
597 SourceLocation ColonLoc;
599 DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt) :
600 SwitchCase(DefaultStmtClass), SubStmt(substmt), DefaultLoc(DL),
603 /// \brief Build an empty default statement.
604 explicit DefaultStmt(EmptyShell) : SwitchCase(DefaultStmtClass) { }
606 Stmt *getSubStmt() { return SubStmt; }
607 const Stmt *getSubStmt() const { return SubStmt; }
608 void setSubStmt(Stmt *S) { SubStmt = S; }
610 SourceLocation getDefaultLoc() const { return DefaultLoc; }
611 void setDefaultLoc(SourceLocation L) { DefaultLoc = L; }
612 SourceLocation getColonLoc() const { return ColonLoc; }
613 void setColonLoc(SourceLocation L) { ColonLoc = L; }
615 SourceRange getSourceRange() const {
616 return SourceRange(DefaultLoc, SubStmt->getLocEnd());
618 static bool classof(const Stmt *T) {
619 return T->getStmtClass() == DefaultStmtClass;
621 static bool classof(const DefaultStmt *) { return true; }
624 child_range children() { return child_range(&SubStmt, &SubStmt+1); }
628 /// LabelStmt - Represents a label, which has a substatement. For example:
631 class LabelStmt : public Stmt {
634 SourceLocation IdentLoc;
636 LabelStmt(SourceLocation IL, LabelDecl *D, Stmt *substmt)
637 : Stmt(LabelStmtClass), TheDecl(D), SubStmt(substmt), IdentLoc(IL) {
640 // \brief Build an empty label statement.
641 explicit LabelStmt(EmptyShell Empty) : Stmt(LabelStmtClass, Empty) { }
643 SourceLocation getIdentLoc() const { return IdentLoc; }
644 LabelDecl *getDecl() const { return TheDecl; }
645 void setDecl(LabelDecl *D) { TheDecl = D; }
646 const char *getName() const;
647 Stmt *getSubStmt() { return SubStmt; }
648 const Stmt *getSubStmt() const { return SubStmt; }
649 void setIdentLoc(SourceLocation L) { IdentLoc = L; }
650 void setSubStmt(Stmt *SS) { SubStmt = SS; }
652 SourceRange getSourceRange() const {
653 return SourceRange(IdentLoc, SubStmt->getLocEnd());
655 child_range children() { return child_range(&SubStmt, &SubStmt+1); }
657 static bool classof(const Stmt *T) {
658 return T->getStmtClass() == LabelStmtClass;
660 static bool classof(const LabelStmt *) { return true; }
664 /// IfStmt - This represents an if/then/else.
666 class IfStmt : public Stmt {
667 enum { VAR, COND, THEN, ELSE, END_EXPR };
668 Stmt* SubExprs[END_EXPR];
670 SourceLocation IfLoc;
671 SourceLocation ElseLoc;
674 IfStmt(ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond,
675 Stmt *then, SourceLocation EL = SourceLocation(), Stmt *elsev = 0);
677 /// \brief Build an empty if/then/else statement
678 explicit IfStmt(EmptyShell Empty) : Stmt(IfStmtClass, Empty) { }
680 /// \brief Retrieve the variable declared in this "if" statement, if any.
682 /// In the following example, "x" is the condition variable.
684 /// if (int x = foo()) {
685 /// printf("x is %d", x);
688 VarDecl *getConditionVariable() const;
689 void setConditionVariable(ASTContext &C, VarDecl *V);
691 const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
692 void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); }
693 const Stmt *getThen() const { return SubExprs[THEN]; }
694 void setThen(Stmt *S) { SubExprs[THEN] = S; }
695 const Stmt *getElse() const { return SubExprs[ELSE]; }
696 void setElse(Stmt *S) { SubExprs[ELSE] = S; }
698 Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
699 Stmt *getThen() { return SubExprs[THEN]; }
700 Stmt *getElse() { return SubExprs[ELSE]; }
702 SourceLocation getIfLoc() const { return IfLoc; }
703 void setIfLoc(SourceLocation L) { IfLoc = L; }
704 SourceLocation getElseLoc() const { return ElseLoc; }
705 void setElseLoc(SourceLocation L) { ElseLoc = L; }
707 SourceRange getSourceRange() const {
709 return SourceRange(IfLoc, SubExprs[ELSE]->getLocEnd());
711 return SourceRange(IfLoc, SubExprs[THEN]->getLocEnd());
714 // Iterators over subexpressions. The iterators will include iterating
715 // over the initialization expression referenced by the condition variable.
716 child_range children() {
717 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
720 static bool classof(const Stmt *T) {
721 return T->getStmtClass() == IfStmtClass;
723 static bool classof(const IfStmt *) { return true; }
726 /// SwitchStmt - This represents a 'switch' stmt.
728 class SwitchStmt : public Stmt {
729 enum { VAR, COND, BODY, END_EXPR };
730 Stmt* SubExprs[END_EXPR];
731 // This points to a linked list of case and default statements.
732 SwitchCase *FirstCase;
733 SourceLocation SwitchLoc;
735 /// If the SwitchStmt is a switch on an enum value, this records whether
736 /// all the enum values were covered by CaseStmts. This value is meant to
737 /// be a hint for possible clients.
738 unsigned AllEnumCasesCovered : 1;
741 SwitchStmt(ASTContext &C, VarDecl *Var, Expr *cond);
743 /// \brief Build a empty switch statement.
744 explicit SwitchStmt(EmptyShell Empty) : Stmt(SwitchStmtClass, Empty) { }
746 /// \brief Retrieve the variable declared in this "switch" statement, if any.
748 /// In the following example, "x" is the condition variable.
750 /// switch (int x = foo()) {
755 VarDecl *getConditionVariable() const;
756 void setConditionVariable(ASTContext &C, VarDecl *V);
758 const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
759 const Stmt *getBody() const { return SubExprs[BODY]; }
760 const SwitchCase *getSwitchCaseList() const { return FirstCase; }
762 Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]);}
763 void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); }
764 Stmt *getBody() { return SubExprs[BODY]; }
765 void setBody(Stmt *S) { SubExprs[BODY] = S; }
766 SwitchCase *getSwitchCaseList() { return FirstCase; }
768 /// \brief Set the case list for this switch statement.
770 /// The caller is responsible for incrementing the retain counts on
771 /// all of the SwitchCase statements in this list.
772 void setSwitchCaseList(SwitchCase *SC) { FirstCase = SC; }
774 SourceLocation getSwitchLoc() const { return SwitchLoc; }
775 void setSwitchLoc(SourceLocation L) { SwitchLoc = L; }
777 void setBody(Stmt *S, SourceLocation SL) {
781 void addSwitchCase(SwitchCase *SC) {
782 assert(!SC->getNextSwitchCase() && "case/default already added to a switch");
783 SC->setNextSwitchCase(FirstCase);
787 /// Set a flag in the SwitchStmt indicating that if the 'switch (X)' is a
788 /// switch over an enum value then all cases have been explicitly covered.
789 void setAllEnumCasesCovered() {
790 AllEnumCasesCovered = 1;
793 /// Returns true if the SwitchStmt is a switch of an enum value and all cases
794 /// have been explicitly covered.
795 bool isAllEnumCasesCovered() const {
796 return (bool) AllEnumCasesCovered;
799 SourceRange getSourceRange() const {
800 return SourceRange(SwitchLoc, SubExprs[BODY]->getLocEnd());
803 child_range children() {
804 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
807 static bool classof(const Stmt *T) {
808 return T->getStmtClass() == SwitchStmtClass;
810 static bool classof(const SwitchStmt *) { return true; }
814 /// WhileStmt - This represents a 'while' stmt.
816 class WhileStmt : public Stmt {
817 enum { VAR, COND, BODY, END_EXPR };
818 Stmt* SubExprs[END_EXPR];
819 SourceLocation WhileLoc;
821 WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,
824 /// \brief Build an empty while statement.
825 explicit WhileStmt(EmptyShell Empty) : Stmt(WhileStmtClass, Empty) { }
827 /// \brief Retrieve the variable declared in this "while" statement, if any.
829 /// In the following example, "x" is the condition variable.
831 /// while (int x = random()) {
835 VarDecl *getConditionVariable() const;
836 void setConditionVariable(ASTContext &C, VarDecl *V);
838 Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
839 const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
840 void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
841 Stmt *getBody() { return SubExprs[BODY]; }
842 const Stmt *getBody() const { return SubExprs[BODY]; }
843 void setBody(Stmt *S) { SubExprs[BODY] = S; }
845 SourceLocation getWhileLoc() const { return WhileLoc; }
846 void setWhileLoc(SourceLocation L) { WhileLoc = L; }
848 SourceRange getSourceRange() const {
849 return SourceRange(WhileLoc, SubExprs[BODY]->getLocEnd());
851 static bool classof(const Stmt *T) {
852 return T->getStmtClass() == WhileStmtClass;
854 static bool classof(const WhileStmt *) { return true; }
857 child_range children() {
858 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
862 /// DoStmt - This represents a 'do/while' stmt.
864 class DoStmt : public Stmt {
865 enum { BODY, COND, END_EXPR };
866 Stmt* SubExprs[END_EXPR];
867 SourceLocation DoLoc;
868 SourceLocation WhileLoc;
869 SourceLocation RParenLoc; // Location of final ')' in do stmt condition.
872 DoStmt(Stmt *body, Expr *cond, SourceLocation DL, SourceLocation WL,
874 : Stmt(DoStmtClass), DoLoc(DL), WhileLoc(WL), RParenLoc(RP) {
875 SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
876 SubExprs[BODY] = body;
879 /// \brief Build an empty do-while statement.
880 explicit DoStmt(EmptyShell Empty) : Stmt(DoStmtClass, Empty) { }
882 Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
883 const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
884 void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
885 Stmt *getBody() { return SubExprs[BODY]; }
886 const Stmt *getBody() const { return SubExprs[BODY]; }
887 void setBody(Stmt *S) { SubExprs[BODY] = S; }
889 SourceLocation getDoLoc() const { return DoLoc; }
890 void setDoLoc(SourceLocation L) { DoLoc = L; }
891 SourceLocation getWhileLoc() const { return WhileLoc; }
892 void setWhileLoc(SourceLocation L) { WhileLoc = L; }
894 SourceLocation getRParenLoc() const { return RParenLoc; }
895 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
897 SourceRange getSourceRange() const {
898 return SourceRange(DoLoc, RParenLoc);
900 static bool classof(const Stmt *T) {
901 return T->getStmtClass() == DoStmtClass;
903 static bool classof(const DoStmt *) { return true; }
906 child_range children() {
907 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
912 /// ForStmt - This represents a 'for (init;cond;inc)' stmt. Note that any of
913 /// the init/cond/inc parts of the ForStmt will be null if they were not
914 /// specified in the source.
916 class ForStmt : public Stmt {
917 enum { INIT, CONDVAR, COND, INC, BODY, END_EXPR };
918 Stmt* SubExprs[END_EXPR]; // SubExprs[INIT] is an expression or declstmt.
919 SourceLocation ForLoc;
920 SourceLocation LParenLoc, RParenLoc;
923 ForStmt(ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc,
924 Stmt *Body, SourceLocation FL, SourceLocation LP, SourceLocation RP);
926 /// \brief Build an empty for statement.
927 explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) { }
929 Stmt *getInit() { return SubExprs[INIT]; }
931 /// \brief Retrieve the variable declared in this "for" statement, if any.
933 /// In the following example, "y" is the condition variable.
935 /// for (int x = random(); int y = mangle(x); ++x) {
939 VarDecl *getConditionVariable() const;
940 void setConditionVariable(ASTContext &C, VarDecl *V);
942 Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
943 Expr *getInc() { return reinterpret_cast<Expr*>(SubExprs[INC]); }
944 Stmt *getBody() { return SubExprs[BODY]; }
946 const Stmt *getInit() const { return SubExprs[INIT]; }
947 const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
948 const Expr *getInc() const { return reinterpret_cast<Expr*>(SubExprs[INC]); }
949 const Stmt *getBody() const { return SubExprs[BODY]; }
951 void setInit(Stmt *S) { SubExprs[INIT] = S; }
952 void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
953 void setInc(Expr *E) { SubExprs[INC] = reinterpret_cast<Stmt*>(E); }
954 void setBody(Stmt *S) { SubExprs[BODY] = S; }
956 SourceLocation getForLoc() const { return ForLoc; }
957 void setForLoc(SourceLocation L) { ForLoc = L; }
958 SourceLocation getLParenLoc() const { return LParenLoc; }
959 void setLParenLoc(SourceLocation L) { LParenLoc = L; }
960 SourceLocation getRParenLoc() const { return RParenLoc; }
961 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
963 SourceRange getSourceRange() const {
964 return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
966 static bool classof(const Stmt *T) {
967 return T->getStmtClass() == ForStmtClass;
969 static bool classof(const ForStmt *) { return true; }
972 child_range children() {
973 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
977 /// GotoStmt - This represents a direct goto.
979 class GotoStmt : public Stmt {
981 SourceLocation GotoLoc;
982 SourceLocation LabelLoc;
984 GotoStmt(LabelDecl *label, SourceLocation GL, SourceLocation LL)
985 : Stmt(GotoStmtClass), Label(label), GotoLoc(GL), LabelLoc(LL) {}
987 /// \brief Build an empty goto statement.
988 explicit GotoStmt(EmptyShell Empty) : Stmt(GotoStmtClass, Empty) { }
990 LabelDecl *getLabel() const { return Label; }
991 void setLabel(LabelDecl *D) { Label = D; }
993 SourceLocation getGotoLoc() const { return GotoLoc; }
994 void setGotoLoc(SourceLocation L) { GotoLoc = L; }
995 SourceLocation getLabelLoc() const { return LabelLoc; }
996 void setLabelLoc(SourceLocation L) { LabelLoc = L; }
998 SourceRange getSourceRange() const {
999 return SourceRange(GotoLoc, LabelLoc);
1001 static bool classof(const Stmt *T) {
1002 return T->getStmtClass() == GotoStmtClass;
1004 static bool classof(const GotoStmt *) { return true; }
1007 child_range children() { return child_range(); }
1010 /// IndirectGotoStmt - This represents an indirect goto.
1012 class IndirectGotoStmt : public Stmt {
1013 SourceLocation GotoLoc;
1014 SourceLocation StarLoc;
1017 IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc,
1019 : Stmt(IndirectGotoStmtClass), GotoLoc(gotoLoc), StarLoc(starLoc),
1020 Target((Stmt*)target) {}
1022 /// \brief Build an empty indirect goto statement.
1023 explicit IndirectGotoStmt(EmptyShell Empty)
1024 : Stmt(IndirectGotoStmtClass, Empty) { }
1026 void setGotoLoc(SourceLocation L) { GotoLoc = L; }
1027 SourceLocation getGotoLoc() const { return GotoLoc; }
1028 void setStarLoc(SourceLocation L) { StarLoc = L; }
1029 SourceLocation getStarLoc() const { return StarLoc; }
1031 Expr *getTarget() { return reinterpret_cast<Expr*>(Target); }
1032 const Expr *getTarget() const {return reinterpret_cast<const Expr*>(Target);}
1033 void setTarget(Expr *E) { Target = reinterpret_cast<Stmt*>(E); }
1035 /// getConstantTarget - Returns the fixed target of this indirect
1036 /// goto, if one exists.
1037 LabelDecl *getConstantTarget();
1038 const LabelDecl *getConstantTarget() const {
1039 return const_cast<IndirectGotoStmt*>(this)->getConstantTarget();
1042 SourceRange getSourceRange() const {
1043 return SourceRange(GotoLoc, Target->getLocEnd());
1046 static bool classof(const Stmt *T) {
1047 return T->getStmtClass() == IndirectGotoStmtClass;
1049 static bool classof(const IndirectGotoStmt *) { return true; }
1052 child_range children() { return child_range(&Target, &Target+1); }
1056 /// ContinueStmt - This represents a continue.
1058 class ContinueStmt : public Stmt {
1059 SourceLocation ContinueLoc;
1061 ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass), ContinueLoc(CL) {}
1063 /// \brief Build an empty continue statement.
1064 explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) { }
1066 SourceLocation getContinueLoc() const { return ContinueLoc; }
1067 void setContinueLoc(SourceLocation L) { ContinueLoc = L; }
1069 SourceRange getSourceRange() const {
1070 return SourceRange(ContinueLoc);
1073 static bool classof(const Stmt *T) {
1074 return T->getStmtClass() == ContinueStmtClass;
1076 static bool classof(const ContinueStmt *) { return true; }
1079 child_range children() { return child_range(); }
1082 /// BreakStmt - This represents a break.
1084 class BreakStmt : public Stmt {
1085 SourceLocation BreakLoc;
1087 BreakStmt(SourceLocation BL) : Stmt(BreakStmtClass), BreakLoc(BL) {}
1089 /// \brief Build an empty break statement.
1090 explicit BreakStmt(EmptyShell Empty) : Stmt(BreakStmtClass, Empty) { }
1092 SourceLocation getBreakLoc() const { return BreakLoc; }
1093 void setBreakLoc(SourceLocation L) { BreakLoc = L; }
1095 SourceRange getSourceRange() const { return SourceRange(BreakLoc); }
1097 static bool classof(const Stmt *T) {
1098 return T->getStmtClass() == BreakStmtClass;
1100 static bool classof(const BreakStmt *) { return true; }
1103 child_range children() { return child_range(); }
1107 /// ReturnStmt - This represents a return, optionally of an expression:
1111 /// Note that GCC allows return with no argument in a function declared to
1112 /// return a value, and it allows returning a value in functions declared to
1113 /// return void. We explicitly model this in the AST, which means you can't
1114 /// depend on the return type of the function and the presence of an argument.
1116 class ReturnStmt : public Stmt {
1118 SourceLocation RetLoc;
1119 const VarDecl *NRVOCandidate;
1122 ReturnStmt(SourceLocation RL)
1123 : Stmt(ReturnStmtClass), RetExpr(0), RetLoc(RL), NRVOCandidate(0) { }
1125 ReturnStmt(SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
1126 : Stmt(ReturnStmtClass), RetExpr((Stmt*) E), RetLoc(RL),
1127 NRVOCandidate(NRVOCandidate) {}
1129 /// \brief Build an empty return expression.
1130 explicit ReturnStmt(EmptyShell Empty) : Stmt(ReturnStmtClass, Empty) { }
1132 const Expr *getRetValue() const;
1133 Expr *getRetValue();
1134 void setRetValue(Expr *E) { RetExpr = reinterpret_cast<Stmt*>(E); }
1136 SourceLocation getReturnLoc() const { return RetLoc; }
1137 void setReturnLoc(SourceLocation L) { RetLoc = L; }
1139 /// \brief Retrieve the variable that might be used for the named return
1140 /// value optimization.
1142 /// The optimization itself can only be performed if the variable is
1143 /// also marked as an NRVO object.
1144 const VarDecl *getNRVOCandidate() const { return NRVOCandidate; }
1145 void setNRVOCandidate(const VarDecl *Var) { NRVOCandidate = Var; }
1147 SourceRange getSourceRange() const;
1149 static bool classof(const Stmt *T) {
1150 return T->getStmtClass() == ReturnStmtClass;
1152 static bool classof(const ReturnStmt *) { return true; }
1155 child_range children() {
1156 if (RetExpr) return child_range(&RetExpr, &RetExpr+1);
1157 return child_range();
1161 /// AsmStmt - This represents a GNU inline-assembly statement extension.
1163 class AsmStmt : public Stmt {
1164 SourceLocation AsmLoc, RParenLoc;
1165 StringLiteral *AsmStr;
1171 unsigned NumOutputs;
1173 unsigned NumClobbers;
1175 // FIXME: If we wanted to, we could allocate all of these in one big array.
1176 IdentifierInfo **Names;
1177 StringLiteral **Constraints;
1179 StringLiteral **Clobbers;
1182 AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, bool isvolatile,
1183 bool msasm, unsigned numoutputs, unsigned numinputs,
1184 IdentifierInfo **names, StringLiteral **constraints,
1185 Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
1186 StringLiteral **clobbers, SourceLocation rparenloc);
1188 /// \brief Build an empty inline-assembly statement.
1189 explicit AsmStmt(EmptyShell Empty) : Stmt(AsmStmtClass, Empty),
1190 Names(0), Constraints(0), Exprs(0), Clobbers(0) { }
1192 SourceLocation getAsmLoc() const { return AsmLoc; }
1193 void setAsmLoc(SourceLocation L) { AsmLoc = L; }
1194 SourceLocation getRParenLoc() const { return RParenLoc; }
1195 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1197 bool isVolatile() const { return IsVolatile; }
1198 void setVolatile(bool V) { IsVolatile = V; }
1199 bool isSimple() const { return IsSimple; }
1200 void setSimple(bool V) { IsSimple = V; }
1201 bool isMSAsm() const { return MSAsm; }
1202 void setMSAsm(bool V) { MSAsm = V; }
1204 //===--- Asm String Analysis ---===//
1206 const StringLiteral *getAsmString() const { return AsmStr; }
1207 StringLiteral *getAsmString() { return AsmStr; }
1208 void setAsmString(StringLiteral *E) { AsmStr = E; }
1210 /// AsmStringPiece - this is part of a decomposed asm string specification
1211 /// (for use with the AnalyzeAsmString function below). An asm string is
1212 /// considered to be a concatenation of these parts.
1213 class AsmStringPiece {
1216 String, // String in .ll asm string form, "$" -> "$$" and "%%" -> "%".
1217 Operand // Operand reference, with optional modifier %c4.
1224 AsmStringPiece(const std::string &S) : MyKind(String), Str(S) {}
1225 AsmStringPiece(unsigned OpNo, char Modifier)
1226 : MyKind(Operand), Str(), OperandNo(OpNo) {
1230 bool isString() const { return MyKind == String; }
1231 bool isOperand() const { return MyKind == Operand; }
1233 const std::string &getString() const {
1238 unsigned getOperandNo() const {
1239 assert(isOperand());
1243 /// getModifier - Get the modifier for this operand, if present. This
1244 /// returns '\0' if there was no modifier.
1245 char getModifier() const {
1246 assert(isOperand());
1251 /// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing
1252 /// it into pieces. If the asm string is erroneous, emit errors and return
1253 /// true, otherwise return false. This handles canonicalization and
1254 /// translation of strings from GCC syntax to LLVM IR syntax, and handles
1255 //// flattening of named references like %[foo] to Operand AsmStringPiece's.
1256 unsigned AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece> &Pieces,
1257 ASTContext &C, unsigned &DiagOffs) const;
1260 //===--- Output operands ---===//
1262 unsigned getNumOutputs() const { return NumOutputs; }
1264 IdentifierInfo *getOutputIdentifier(unsigned i) const {
1268 llvm::StringRef getOutputName(unsigned i) const {
1269 if (IdentifierInfo *II = getOutputIdentifier(i))
1270 return II->getName();
1272 return llvm::StringRef();
1275 /// getOutputConstraint - Return the constraint string for the specified
1276 /// output operand. All output constraints are known to be non-empty (either
1278 llvm::StringRef getOutputConstraint(unsigned i) const;
1280 const StringLiteral *getOutputConstraintLiteral(unsigned i) const {
1281 return Constraints[i];
1283 StringLiteral *getOutputConstraintLiteral(unsigned i) {
1284 return Constraints[i];
1287 Expr *getOutputExpr(unsigned i);
1289 const Expr *getOutputExpr(unsigned i) const {
1290 return const_cast<AsmStmt*>(this)->getOutputExpr(i);
1293 /// isOutputPlusConstraint - Return true if the specified output constraint
1294 /// is a "+" constraint (which is both an input and an output) or false if it
1295 /// is an "=" constraint (just an output).
1296 bool isOutputPlusConstraint(unsigned i) const {
1297 return getOutputConstraint(i)[0] == '+';
1300 /// getNumPlusOperands - Return the number of output operands that have a "+"
1302 unsigned getNumPlusOperands() const;
1304 //===--- Input operands ---===//
1306 unsigned getNumInputs() const { return NumInputs; }
1308 IdentifierInfo *getInputIdentifier(unsigned i) const {
1309 return Names[i + NumOutputs];
1312 llvm::StringRef getInputName(unsigned i) const {
1313 if (IdentifierInfo *II = getInputIdentifier(i))
1314 return II->getName();
1316 return llvm::StringRef();
1319 /// getInputConstraint - Return the specified input constraint. Unlike output
1320 /// constraints, these can be empty.
1321 llvm::StringRef getInputConstraint(unsigned i) const;
1323 const StringLiteral *getInputConstraintLiteral(unsigned i) const {
1324 return Constraints[i + NumOutputs];
1326 StringLiteral *getInputConstraintLiteral(unsigned i) {
1327 return Constraints[i + NumOutputs];
1330 Expr *getInputExpr(unsigned i);
1331 void setInputExpr(unsigned i, Expr *E);
1333 const Expr *getInputExpr(unsigned i) const {
1334 return const_cast<AsmStmt*>(this)->getInputExpr(i);
1337 void setOutputsAndInputsAndClobbers(ASTContext &C,
1338 IdentifierInfo **Names,
1339 StringLiteral **Constraints,
1341 unsigned NumOutputs,
1343 StringLiteral **Clobbers,
1344 unsigned NumClobbers);
1346 //===--- Other ---===//
1348 /// getNamedOperand - Given a symbolic operand reference like %[foo],
1349 /// translate this into a numeric value needed to reference the same operand.
1350 /// This returns -1 if the operand name is invalid.
1351 int getNamedOperand(llvm::StringRef SymbolicName) const;
1353 unsigned getNumClobbers() const { return NumClobbers; }
1354 StringLiteral *getClobber(unsigned i) { return Clobbers[i]; }
1355 const StringLiteral *getClobber(unsigned i) const { return Clobbers[i]; }
1357 SourceRange getSourceRange() const {
1358 return SourceRange(AsmLoc, RParenLoc);
1361 static bool classof(const Stmt *T) {return T->getStmtClass() == AsmStmtClass;}
1362 static bool classof(const AsmStmt *) { return true; }
1364 // Input expr iterators.
1366 typedef ExprIterator inputs_iterator;
1367 typedef ConstExprIterator const_inputs_iterator;
1369 inputs_iterator begin_inputs() {
1370 return &Exprs[0] + NumOutputs;
1373 inputs_iterator end_inputs() {
1374 return &Exprs[0] + NumOutputs + NumInputs;
1377 const_inputs_iterator begin_inputs() const {
1378 return &Exprs[0] + NumOutputs;
1381 const_inputs_iterator end_inputs() const {
1382 return &Exprs[0] + NumOutputs + NumInputs;
1385 // Output expr iterators.
1387 typedef ExprIterator outputs_iterator;
1388 typedef ConstExprIterator const_outputs_iterator;
1390 outputs_iterator begin_outputs() {
1393 outputs_iterator end_outputs() {
1394 return &Exprs[0] + NumOutputs;
1397 const_outputs_iterator begin_outputs() const {
1400 const_outputs_iterator end_outputs() const {
1401 return &Exprs[0] + NumOutputs;
1404 child_range children() {
1405 return child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs);
1409 } // end namespace clang