aboutsummaryrefslogtreecommitdiff
path: root/include/clang/AST/Stmt.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/AST/Stmt.h')
-rw-r--r--include/clang/AST/Stmt.h430
1 files changed, 215 insertions, 215 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index f34776373b..125279c1ed 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -39,21 +39,21 @@ namespace clang {
class SourceManager;
class StringLiteral;
class SwitchStmt;
-
+
//===----------------------------------------------------------------------===//
// ExprIterator - Iterators for iterating over Stmt* arrays that contain
// only Expr*. This is needed because AST nodes use Stmt* arrays to store
// references to children (to be compatible with StmtIterator).
//===----------------------------------------------------------------------===//
-
+
class Stmt;
class Expr;
-
+
class ExprIterator {
Stmt** I;
public:
ExprIterator(Stmt** i) : I(i) {}
- ExprIterator() : I(0) {}
+ ExprIterator() : I(0) {}
ExprIterator& operator++() { ++I; return *this; }
ExprIterator operator-(size_t i) { return I-i; }
ExprIterator operator+(size_t i) { return I+i; }
@@ -67,12 +67,12 @@ namespace clang {
bool operator>(const ExprIterator& R) const { return I > R.I; }
bool operator>=(const ExprIterator& R) const { return I >= R.I; }
};
-
+
class ConstExprIterator {
Stmt* const * I;
public:
ConstExprIterator(Stmt* const* i) : I(i) {}
- ConstExprIterator() : I(0) {}
+ ConstExprIterator() : I(0) {}
ConstExprIterator& operator++() { ++I; return *this; }
ConstExprIterator operator+(size_t i) { return I+i; }
ConstExprIterator operator-(size_t i) { return I-i; }
@@ -84,12 +84,12 @@ namespace clang {
bool operator!=(const ConstExprIterator& R) const { return I != R.I; }
bool operator>(const ConstExprIterator& R) const { return I > R.I; }
bool operator>=(const ConstExprIterator& R) const { return I >= R.I; }
- };
-
+ };
+
//===----------------------------------------------------------------------===//
// AST classes for statements.
//===----------------------------------------------------------------------===//
-
+
/// Stmt - This represents one statement.
///
class Stmt {
@@ -106,7 +106,7 @@ public:
private:
/// \brief The statement class.
const unsigned sClass : 8;
-
+
/// \brief The reference count for this statement.
unsigned RefCount : 24;
@@ -119,20 +119,20 @@ protected:
void operator delete(void* data) throw() {
assert(0 && "Stmts cannot be released with regular 'delete'.");
}
-
+
public:
// Only allow allocation of Stmts using the allocator in ASTContext
- // or by doing a placement new.
+ // or by doing a placement new.
void* operator new(size_t bytes, ASTContext& C,
unsigned alignment = 16) throw() {
return ::operator new(bytes, C, alignment);
}
-
+
void* operator new(size_t bytes, ASTContext* C,
unsigned alignment = 16) throw() {
return ::operator new(bytes, *C, alignment);
}
-
+
void* operator new(size_t bytes, void* mem) throw() {
return mem;
}
@@ -152,9 +152,9 @@ protected:
/// DestroyChildren - Invoked by destructors of subclasses of Stmt to
/// recursively release child AST nodes.
void DestroyChildren(ASTContext& Ctx);
-
+
/// \brief Construct an empty statement.
- explicit Stmt(StmtClass SC, EmptyShell) : sClass(SC), RefCount(1) {
+ explicit Stmt(StmtClass SC, EmptyShell) : sClass(SC), RefCount(1) {
if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
}
@@ -164,18 +164,18 @@ protected:
/// Subclasses should override this method (not Destroy()) to
/// provide class-specific destruction.
virtual void DoDestroy(ASTContext &Ctx);
-
+
public:
- Stmt(StmtClass SC) : sClass(SC), RefCount(1) {
+ Stmt(StmtClass SC) : sClass(SC), RefCount(1) {
if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
}
virtual ~Stmt() {}
-
+
/// \brief Destroy the current statement and its children.
- void Destroy(ASTContext &Ctx) {
+ void Destroy(ASTContext &Ctx) {
assert(RefCount >= 1);
if (--RefCount == 0)
- DoDestroy(Ctx);
+ DoDestroy(Ctx);
}
/// \brief Increases the reference count for this statement.
@@ -187,10 +187,10 @@ public:
++RefCount;
return this;
}
-
+
StmtClass getStmtClass() const { return (StmtClass)sClass; }
const char *getStmtClassName() const;
-
+
/// SourceLocation tokens are not useful in isolation - they are low level
/// value objects created/interpreted by SourceManager. We assume AST
/// clients will have a pointer to the respective SourceManager.
@@ -216,23 +216,23 @@ public:
/// dumpPretty/printPretty - These two methods do a "pretty print" of the AST
/// back to its original source language syntax.
void dumpPretty(ASTContext& Context) const;
- void printPretty(llvm::raw_ostream &OS, PrinterHelper *Helper,
+ void printPretty(llvm::raw_ostream &OS, PrinterHelper *Helper,
const PrintingPolicy &Policy,
unsigned Indentation = 0) const {
printPretty(OS, *(ASTContext*)0, Helper, Policy, Indentation);
}
void printPretty(llvm::raw_ostream &OS, ASTContext &Context,
- PrinterHelper *Helper,
+ PrinterHelper *Helper,
const PrintingPolicy &Policy,
unsigned Indentation = 0) const;
-
+
/// viewAST - Visualize an AST rooted at this Stmt* using GraphViz. Only
/// works on systems with GraphViz (Mac OS X) or dot+gv installed.
void viewAST() const;
-
+
// Implement isa<T> support.
- static bool classof(const Stmt *) { return true; }
-
+ static bool classof(const Stmt *) { return true; }
+
/// hasImplicitControlFlow - Some statements (e.g. short circuited operations)
/// contain implicit control-flow in the order their subexpressions
/// are evaluated. This predicate returns true if this statement has
@@ -245,14 +245,14 @@ public:
/// AST node. This permits easy iteration over all nodes in the AST.
typedef StmtIterator child_iterator;
typedef ConstStmtIterator const_child_iterator;
-
+
virtual child_iterator child_begin() = 0;
virtual child_iterator child_end() = 0;
-
+
const_child_iterator child_begin() const {
return const_child_iterator(const_cast<Stmt*>(this)->child_begin());
}
-
+
const_child_iterator child_end() const {
return const_child_iterator(const_cast<Stmt*>(this)->child_end());
}
@@ -266,7 +266,7 @@ public:
///
/// \brief Canonical whether the profile should be based on the canonical
/// representation of this statement (e.g., where non-type template
- /// parameters are identified by index/level rather than their
+ /// parameters are identified by index/level rather than their
/// declaration pointers) or the exact representation of the statement as
/// written in the source.
void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,
@@ -275,18 +275,18 @@ public:
/// DeclStmt - Adaptor class for mixing declarations with statements and
/// expressions. For example, CompoundStmt mixes statements, expressions
-/// and declarations (variables, types). Another example is ForStmt, where
+/// and declarations (variables, types). Another example is ForStmt, where
/// the first statement can be an expression or a declaration.
///
class DeclStmt : public Stmt {
DeclGroupRef DG;
SourceLocation StartLoc, EndLoc;
-
+
public:
- DeclStmt(DeclGroupRef dg, SourceLocation startLoc,
+ DeclStmt(DeclGroupRef dg, SourceLocation startLoc,
SourceLocation endLoc) : Stmt(DeclStmtClass), DG(dg),
StartLoc(startLoc), EndLoc(endLoc) {}
-
+
/// \brief Build an empty declaration statement.
explicit DeclStmt(EmptyShell Empty) : Stmt(DeclStmtClass, Empty) { }
@@ -295,10 +295,10 @@ public:
bool isSingleDecl() const {
return DG.isSingleDecl();
}
-
+
const Decl *getSingleDecl() const { return DG.getSingleDecl(); }
- Decl *getSingleDecl() { return DG.getSingleDecl(); }
-
+ Decl *getSingleDecl() { return DG.getSingleDecl(); }
+
const DeclGroupRef getDeclGroup() const { return DG; }
DeclGroupRef getDeclGroup() { return DG; }
void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
@@ -311,19 +311,19 @@ public:
SourceRange getSourceRange() const {
return SourceRange(StartLoc, EndLoc);
}
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == DeclStmtClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == DeclStmtClass;
}
static bool classof(const DeclStmt *) { return true; }
-
+
// Iterators over subexpressions.
virtual child_iterator child_begin();
virtual child_iterator child_end();
-
+
typedef DeclGroupRef::iterator decl_iterator;
typedef DeclGroupRef::const_iterator const_decl_iterator;
-
+
decl_iterator decl_begin() { return DG.begin(); }
decl_iterator decl_end() { return DG.end(); }
const_decl_iterator decl_begin() const { return DG.begin(); }
@@ -344,12 +344,12 @@ public:
void setSemiLoc(SourceLocation L) { SemiLoc = L; }
virtual SourceRange getSourceRange() const { return SourceRange(SemiLoc); }
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == NullStmtClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == NullStmtClass;
}
static bool classof(const NullStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -362,24 +362,24 @@ class CompoundStmt : public Stmt {
unsigned NumStmts;
SourceLocation LBracLoc, RBracLoc;
public:
- CompoundStmt(ASTContext& C, Stmt **StmtStart, unsigned numStmts,
+ CompoundStmt(ASTContext& C, Stmt **StmtStart, unsigned numStmts,
SourceLocation LB, SourceLocation RB)
: Stmt(CompoundStmtClass), NumStmts(numStmts), LBracLoc(LB), RBracLoc(RB) {
if (NumStmts == 0) {
Body = 0;
return;
}
-
+
Body = new (C) Stmt*[NumStmts];
memcpy(Body, StmtStart, numStmts * sizeof(*Body));
- }
+ }
// \brief Build an empty compound statement.
explicit CompoundStmt(EmptyShell Empty)
: Stmt(CompoundStmtClass, Empty), Body(0), NumStmts(0) { }
void setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts);
-
+
bool body_empty() const { return NumStmts == 0; }
unsigned size() const { return NumStmts; }
@@ -407,25 +407,25 @@ public:
const_reverse_body_iterator body_rbegin() const {
return const_reverse_body_iterator(body_end());
}
-
+
const_reverse_body_iterator body_rend() const {
return const_reverse_body_iterator(body_begin());
}
-
- virtual SourceRange getSourceRange() const {
- return SourceRange(LBracLoc, RBracLoc);
+
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(LBracLoc, RBracLoc);
}
-
+
SourceLocation getLBracLoc() const { return LBracLoc; }
void setLBracLoc(SourceLocation L) { LBracLoc = L; }
SourceLocation getRBracLoc() const { return RBracLoc; }
void setRBracLoc(SourceLocation L) { RBracLoc = L; }
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == CompoundStmtClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == CompoundStmtClass;
}
static bool classof(const CompoundStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -439,7 +439,7 @@ protected:
SwitchCase *NextSwitchCase;
SwitchCase(StmtClass SC) : Stmt(SC), NextSwitchCase(0) {}
-
+
public:
const SwitchCase *getNextSwitchCase() const { return NextSwitchCase; }
@@ -450,19 +450,19 @@ public:
Stmt *getSubStmt() { return v_getSubStmt(); }
virtual SourceRange getSourceRange() const { return SourceRange(); }
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == CaseStmtClass ||
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == CaseStmtClass ||
T->getStmtClass() == DefaultStmtClass;
}
static bool classof(const SwitchCase *) { return true; }
protected:
- virtual Stmt* v_getSubStmt() = 0;
+ virtual Stmt* v_getSubStmt() = 0;
};
class CaseStmt : public SwitchCase {
enum { SUBSTMT, LHS, RHS, END_EXPR };
- Stmt* SubExprs[END_EXPR]; // The expression for the RHS is Non-null for
+ Stmt* SubExprs[END_EXPR]; // The expression for the RHS is Non-null for
// GNU "case 1 ... 4" extension
SourceLocation CaseLoc;
SourceLocation EllipsisLoc;
@@ -471,7 +471,7 @@ class CaseStmt : public SwitchCase {
virtual Stmt* v_getSubStmt() { return getSubStmt(); }
public:
CaseStmt(Expr *lhs, Expr *rhs, SourceLocation caseLoc,
- SourceLocation ellipsisLoc, SourceLocation colonLoc)
+ SourceLocation ellipsisLoc, SourceLocation colonLoc)
: SwitchCase(CaseStmtClass) {
SubExprs[SUBSTMT] = 0;
SubExprs[LHS] = reinterpret_cast<Stmt*>(lhs);
@@ -495,32 +495,32 @@ public:
Expr *getRHS() { return reinterpret_cast<Expr*>(SubExprs[RHS]); }
Stmt *getSubStmt() { return SubExprs[SUBSTMT]; }
- const Expr *getLHS() const {
- return reinterpret_cast<const Expr*>(SubExprs[LHS]);
+ const Expr *getLHS() const {
+ return reinterpret_cast<const Expr*>(SubExprs[LHS]);
}
- const Expr *getRHS() const {
- return reinterpret_cast<const Expr*>(SubExprs[RHS]);
+ const Expr *getRHS() const {
+ return reinterpret_cast<const Expr*>(SubExprs[RHS]);
}
const Stmt *getSubStmt() const { return SubExprs[SUBSTMT]; }
void setSubStmt(Stmt *S) { SubExprs[SUBSTMT] = S; }
void setLHS(Expr *Val) { SubExprs[LHS] = reinterpret_cast<Stmt*>(Val); }
void setRHS(Expr *Val) { SubExprs[RHS] = reinterpret_cast<Stmt*>(Val); }
-
-
+
+
virtual SourceRange getSourceRange() const {
// Handle deeply nested case statements with iteration instead of recursion.
const CaseStmt *CS = this;
while (const CaseStmt *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt()))
CS = CS2;
-
- return SourceRange(CaseLoc, CS->getSubStmt()->getLocEnd());
+
+ return SourceRange(CaseLoc, CS->getSubStmt()->getLocEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == CaseStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == CaseStmtClass;
}
static bool classof(const CaseStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -532,7 +532,7 @@ class DefaultStmt : public SwitchCase {
SourceLocation ColonLoc;
virtual Stmt* v_getSubStmt() { return getSubStmt(); }
public:
- DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt) :
+ DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt) :
SwitchCase(DefaultStmtClass), SubStmt(substmt), DefaultLoc(DL),
ColonLoc(CL) {}
@@ -548,14 +548,14 @@ public:
SourceLocation getColonLoc() const { return ColonLoc; }
void setColonLoc(SourceLocation L) { ColonLoc = L; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(DefaultLoc, SubStmt->getLocEnd());
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(DefaultLoc, SubStmt->getLocEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == DefaultStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == DefaultStmtClass;
}
static bool classof(const DefaultStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -566,13 +566,13 @@ class LabelStmt : public Stmt {
Stmt *SubStmt;
SourceLocation IdentLoc;
public:
- LabelStmt(SourceLocation IL, IdentifierInfo *label, Stmt *substmt)
- : Stmt(LabelStmtClass), Label(label),
+ LabelStmt(SourceLocation IL, IdentifierInfo *label, Stmt *substmt)
+ : Stmt(LabelStmtClass), Label(label),
SubStmt(substmt), IdentLoc(IL) {}
// \brief Build an empty label statement.
explicit LabelStmt(EmptyShell Empty) : Stmt(LabelStmtClass, Empty) { }
-
+
SourceLocation getIdentLoc() const { return IdentLoc; }
IdentifierInfo *getID() const { return Label; }
void setID(IdentifierInfo *II) { Label = II; }
@@ -582,14 +582,14 @@ public:
void setIdentLoc(SourceLocation L) { IdentLoc = L; }
void setSubStmt(Stmt *SS) { SubStmt = SS; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(IdentLoc, SubStmt->getLocEnd());
- }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == LabelStmtClass;
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(IdentLoc, SubStmt->getLocEnd());
+ }
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == LabelStmtClass;
}
static bool classof(const LabelStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -604,8 +604,8 @@ class IfStmt : public Stmt {
SourceLocation IfLoc;
SourceLocation ElseLoc;
public:
- IfStmt(SourceLocation IL, Expr *cond, Stmt *then,
- SourceLocation EL = SourceLocation(), Stmt *elsev = 0)
+ IfStmt(SourceLocation IL, Expr *cond, Stmt *then,
+ SourceLocation EL = SourceLocation(), Stmt *elsev = 0)
: Stmt(IfStmtClass) {
SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
SubExprs[THEN] = then;
@@ -613,14 +613,14 @@ public:
IfLoc = IL;
ElseLoc = EL;
}
-
+
/// \brief Build an empty if/then/else statement
explicit IfStmt(EmptyShell Empty) : Stmt(IfStmtClass, Empty) { }
const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); }
const Stmt *getThen() const { return SubExprs[THEN]; }
- void setThen(Stmt *S) { SubExprs[THEN] = S; }
+ void setThen(Stmt *S) { SubExprs[THEN] = S; }
const Stmt *getElse() const { return SubExprs[ELSE]; }
void setElse(Stmt *S) { SubExprs[ELSE] = S; }
@@ -633,18 +633,18 @@ public:
SourceLocation getElseLoc() const { return ElseLoc; }
void setElseLoc(SourceLocation L) { ElseLoc = L; }
- virtual SourceRange getSourceRange() const {
+ virtual SourceRange getSourceRange() const {
if (SubExprs[ELSE])
return SourceRange(IfLoc, SubExprs[ELSE]->getLocEnd());
else
return SourceRange(IfLoc, SubExprs[THEN]->getLocEnd());
}
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == IfStmtClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == IfStmtClass;
}
static bool classof(const IfStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -654,20 +654,20 @@ public:
///
class SwitchStmt : public Stmt {
enum { COND, BODY, END_EXPR };
- Stmt* SubExprs[END_EXPR];
+ Stmt* SubExprs[END_EXPR];
// This points to a linked list of case and default statements.
SwitchCase *FirstCase;
SourceLocation SwitchLoc;
-
+
protected:
virtual void DoDestroy(ASTContext &Ctx);
-
+
public:
SwitchStmt(Expr *cond) : Stmt(SwitchStmtClass), FirstCase(0) {
SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
SubExprs[BODY] = NULL;
}
-
+
/// \brief Build a empty switch statement.
explicit SwitchStmt(EmptyShell Empty) : Stmt(SwitchStmtClass, Empty) { }
@@ -680,7 +680,7 @@ public:
Stmt *getBody() { return SubExprs[BODY]; }
void setBody(Stmt *S) { SubExprs[BODY] = S; }
SwitchCase *getSwitchCaseList() { return FirstCase; }
-
+
/// \brief Set the case list for this switch statement.
///
/// The caller is responsible for incrementing the retain counts on
@@ -690,24 +690,24 @@ public:
SourceLocation getSwitchLoc() const { return SwitchLoc; }
void setSwitchLoc(SourceLocation L) { SwitchLoc = L; }
- void setBody(Stmt *S, SourceLocation SL) {
- SubExprs[BODY] = S;
+ void setBody(Stmt *S, SourceLocation SL) {
+ SubExprs[BODY] = S;
SwitchLoc = SL;
- }
+ }
void addSwitchCase(SwitchCase *SC) {
assert(!SC->getNextSwitchCase() && "case/default already added to a switch");
SC->Retain();
SC->setNextSwitchCase(FirstCase);
FirstCase = SC;
}
- virtual SourceRange getSourceRange() const {
- return SourceRange(SwitchLoc, SubExprs[BODY]->getLocEnd());
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(SwitchLoc, SubExprs[BODY]->getLocEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == SwitchStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == SwitchStmtClass;
}
static bool classof(const SwitchStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -726,7 +726,7 @@ public:
SubExprs[BODY] = body;
WhileLoc = WL;
}
-
+
/// \brief Build an empty while statement.
explicit WhileStmt(EmptyShell Empty) : Stmt(WhileStmtClass, Empty) { }
@@ -740,14 +740,14 @@ public:
SourceLocation getWhileLoc() const { return WhileLoc; }
void setWhileLoc(SourceLocation L) { WhileLoc = L; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(WhileLoc, SubExprs[BODY]->getLocEnd());
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(WhileLoc, SubExprs[BODY]->getLocEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == WhileStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == WhileStmtClass;
}
static bool classof(const WhileStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -768,16 +768,16 @@ public:
: Stmt(DoStmtClass), DoLoc(DL), WhileLoc(WL), RParenLoc(RP) {
SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
SubExprs[BODY] = body;
- }
+ }
/// \brief Build an empty do-while statement.
explicit DoStmt(EmptyShell Empty) : Stmt(DoStmtClass, Empty) { }
-
+
Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
Stmt *getBody() { return SubExprs[BODY]; }
- const Stmt *getBody() const { return SubExprs[BODY]; }
+ const Stmt *getBody() const { return SubExprs[BODY]; }
void setBody(Stmt *S) { SubExprs[BODY] = S; }
SourceLocation getDoLoc() const { return DoLoc; }
@@ -788,11 +788,11 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(DoLoc, RParenLoc);
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(DoLoc, RParenLoc);
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == DoStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == DoStmtClass;
}
static bool classof(const DoStmt *) { return true; }
@@ -814,7 +814,7 @@ class ForStmt : public Stmt {
public:
ForStmt(Stmt *Init, Expr *Cond, Expr *Inc, Stmt *Body, SourceLocation FL,
- SourceLocation LP, SourceLocation RP)
+ SourceLocation LP, SourceLocation RP)
: Stmt(ForStmtClass) {
SubExprs[INIT] = Init;
SubExprs[COND] = reinterpret_cast<Stmt*>(Cond);
@@ -824,7 +824,7 @@ public:
LParenLoc = LP;
RParenLoc = RP;
}
-
+
/// \brief Build an empty for statement.
explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) { }
@@ -850,19 +850,19 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ForStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ForStmtClass;
}
static bool classof(const ForStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
-
+
/// GotoStmt - This represents a direct goto.
///
class GotoStmt : public Stmt {
@@ -870,9 +870,9 @@ class GotoStmt : public Stmt {
SourceLocation GotoLoc;
SourceLocation LabelLoc;
public:
- GotoStmt(LabelStmt *label, SourceLocation GL, SourceLocation LL)
+ GotoStmt(LabelStmt *label, SourceLocation GL, SourceLocation LL)
: Stmt(GotoStmtClass), Label(label), GotoLoc(GL), LabelLoc(LL) {}
-
+
/// \brief Build an empty goto statement.
explicit GotoStmt(EmptyShell Empty) : Stmt(GotoStmtClass, Empty) { }
@@ -884,14 +884,14 @@ public:
SourceLocation getLabelLoc() const { return LabelLoc; }
void setLabelLoc(SourceLocation L) { LabelLoc = L; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(GotoLoc, LabelLoc);
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(GotoLoc, LabelLoc);
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == GotoStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == GotoStmtClass;
}
static bool classof(const GotoStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -904,20 +904,20 @@ class IndirectGotoStmt : public Stmt {
SourceLocation StarLoc;
Stmt *Target;
public:
- IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc,
+ IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc,
Expr *target)
: Stmt(IndirectGotoStmtClass), GotoLoc(gotoLoc), StarLoc(starLoc),
Target((Stmt*)target) {}
/// \brief Build an empty indirect goto statement.
- explicit IndirectGotoStmt(EmptyShell Empty)
+ explicit IndirectGotoStmt(EmptyShell Empty)
: Stmt(IndirectGotoStmtClass, Empty) { }
-
+
void setGotoLoc(SourceLocation L) { GotoLoc = L; }
SourceLocation getGotoLoc() const { return GotoLoc; }
void setStarLoc(SourceLocation L) { StarLoc = L; }
SourceLocation getStarLoc() const { return StarLoc; }
-
+
Expr *getTarget();
const Expr *getTarget() const;
void setTarget(Expr *E) { Target = reinterpret_cast<Stmt*>(E); }
@@ -925,12 +925,12 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(GotoLoc, Target->getLocEnd());
}
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == IndirectGotoStmtClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == IndirectGotoStmtClass;
}
static bool classof(const IndirectGotoStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -943,22 +943,22 @@ class ContinueStmt : public Stmt {
SourceLocation ContinueLoc;
public:
ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass), ContinueLoc(CL) {}
-
+
/// \brief Build an empty continue statement.
explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) { }
SourceLocation getContinueLoc() const { return ContinueLoc; }
void setContinueLoc(SourceLocation L) { ContinueLoc = L; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(ContinueLoc);
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(ContinueLoc);
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ContinueStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ContinueStmtClass;
}
static bool classof(const ContinueStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -970,7 +970,7 @@ class BreakStmt : public Stmt {
SourceLocation BreakLoc;
public:
BreakStmt(SourceLocation BL) : Stmt(BreakStmtClass), BreakLoc(BL) {}
-
+
/// \brief Build an empty break statement.
explicit BreakStmt(EmptyShell Empty) : Stmt(BreakStmtClass, Empty) { }
@@ -979,11 +979,11 @@ public:
virtual SourceRange getSourceRange() const { return SourceRange(BreakLoc); }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == BreakStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == BreakStmtClass;
}
static bool classof(const BreakStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -1003,7 +1003,7 @@ class ReturnStmt : public Stmt {
Stmt *RetExpr;
SourceLocation RetLoc;
public:
- ReturnStmt(SourceLocation RL, Expr *E = 0) : Stmt(ReturnStmtClass),
+ ReturnStmt(SourceLocation RL, Expr *E = 0) : Stmt(ReturnStmtClass),
RetExpr((Stmt*) E), RetLoc(RL) {}
/// \brief Build an empty return expression.
@@ -1017,12 +1017,12 @@ public:
void setReturnLoc(SourceLocation L) { RetLoc = L; }
virtual SourceRange getSourceRange() const;
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ReturnStmtClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ReturnStmtClass;
}
static bool classof(const ReturnStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -1036,18 +1036,18 @@ class AsmStmt : public Stmt {
bool IsSimple;
bool IsVolatile;
-
+
unsigned NumOutputs;
unsigned NumInputs;
-
+
llvm::SmallVector<std::string, 4> Names;
llvm::SmallVector<StringLiteral*, 4> Constraints;
llvm::SmallVector<Stmt*, 4> Exprs;
llvm::SmallVector<StringLiteral*, 4> Clobbers;
public:
- AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile,
- unsigned numoutputs, unsigned numinputs,
+ AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile,
+ unsigned numoutputs, unsigned numinputs,
std::string *names, StringLiteral **constraints,
Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
StringLiteral **clobbers, SourceLocation rparenloc);
@@ -1090,10 +1090,10 @@ public:
: MyKind(Operand), Str(), OperandNo(OpNo) {
Str += Modifier;
}
-
+
bool isString() const { return MyKind == String; }
bool isOperand() const { return MyKind == Operand; }
-
+
const std::string &getString() const {
assert(isString());
return Str;
@@ -1103,7 +1103,7 @@ public:
assert(isOperand());
return OperandNo;
}
-
+
/// getModifier - Get the modifier for this operand, if present. This
/// returns '\0' if there was no modifier.
char getModifier() const {
@@ -1111,16 +1111,16 @@ public:
return Str[0];
}
};
-
+
/// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing
/// it into pieces. If the asm string is erroneous, emit errors and return
/// true, otherwise return false. This handles canonicalization and
/// translation of strings from GCC syntax to LLVM IR syntax, and handles
- //// flattening of named references like %[foo] to Operand AsmStringPiece's.
+ //// flattening of named references like %[foo] to Operand AsmStringPiece's.
unsigned AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece> &Pieces,
ASTContext &C, unsigned &DiagOffs) const;
-
-
+
+
//===--- Output operands ---===//
unsigned getNumOutputs() const { return NumOutputs; }
@@ -1133,72 +1133,72 @@ public:
/// output operand. All output constraints are known to be non-empty (either
/// '=' or '+').
std::string getOutputConstraint(unsigned i) const;
-
+
const StringLiteral *getOutputConstraintLiteral(unsigned i) const {
return Constraints[i];
}
StringLiteral *getOutputConstraintLiteral(unsigned i) {
return Constraints[i];
}
-
-
+
+
Expr *getOutputExpr(unsigned i);
-
+
const Expr *getOutputExpr(unsigned i) const {
return const_cast<AsmStmt*>(this)->getOutputExpr(i);
}
-
+
/// isOutputPlusConstraint - Return true if the specified output constraint
/// is a "+" constraint (which is both an input and an output) or false if it
/// is an "=" constraint (just an output).
bool isOutputPlusConstraint(unsigned i) const {
return getOutputConstraint(i)[0] == '+';
}
-
+
/// getNumPlusOperands - Return the number of output operands that have a "+"
/// constraint.
unsigned getNumPlusOperands() const;
-
+
//===--- Input operands ---===//
-
- unsigned getNumInputs() const { return NumInputs; }
-
+
+ unsigned getNumInputs() const { return NumInputs; }
+
const std::string &getInputName(unsigned i) const {
return Names[i + NumOutputs];
}
-
+
/// getInputConstraint - Return the specified input constraint. Unlike output
/// constraints, these can be empty.
std::string getInputConstraint(unsigned i) const;
-
+
const StringLiteral *getInputConstraintLiteral(unsigned i) const {
return Constraints[i + NumOutputs];
}
StringLiteral *getInputConstraintLiteral(unsigned i) {
return Constraints[i + NumOutputs];
}
-
-
+
+
Expr *getInputExpr(unsigned i);
-
+
const Expr *getInputExpr(unsigned i) const {
return const_cast<AsmStmt*>(this)->getInputExpr(i);
}
void setOutputsAndInputs(unsigned NumOutputs,
- unsigned NumInputs,
+ unsigned NumInputs,
const std::string *Names,
StringLiteral **Constraints,
Stmt **Exprs);
//===--- Other ---===//
-
+
/// getNamedOperand - Given a symbolic operand reference like %[foo],
/// translate this into a numeric value needed to reference the same operand.
/// This returns -1 if the operand name is invalid.
int getNamedOperand(const std::string &SymbolicName) const;
-
+
unsigned getNumClobbers() const { return Clobbers.size(); }
StringLiteral *getClobber(unsigned i) { return Clobbers[i]; }
@@ -1208,62 +1208,62 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(AsmLoc, RParenLoc);
}
-
+
static bool classof(const Stmt *T) {return T->getStmtClass() == AsmStmtClass;}
static bool classof(const AsmStmt *) { return true; }
-
+
// Input expr iterators.
-
+
typedef ExprIterator inputs_iterator;
typedef ConstExprIterator const_inputs_iterator;
-
+
inputs_iterator begin_inputs() {
return Exprs.data() + NumOutputs;
}
-
+
inputs_iterator end_inputs() {
return Exprs.data() + NumOutputs + NumInputs;
}
-
+
const_inputs_iterator begin_inputs() const {
return Exprs.data() + NumOutputs;
}
-
+
const_inputs_iterator end_inputs() const {
return Exprs.data() + NumOutputs + NumInputs;
}
-
+
// Output expr iterators.
-
+
typedef