Remove vtables from the Stmt hierarchy; this was pretty easy as

there were only three virtual methods of any significance.

The primary way to grab child iterators now is with
  Stmt::child_range children();
  Stmt::const_child_range children() const;
where a child_range is just a std::pair of iterators suitable for
being llvm::tie'd to some locals.  I've left the old child_begin()
and child_end() accessors in place, but it's probably a substantial
penalty to grab the iterators individually now, since the
switch-based dispatch is kindof inherently slower than vtable
dispatch.  Grabbing them together is probably a slight win over the
status quo, although of course we could've achieved that with vtables, too.

I also reclassified SwitchCase (correctly) as an abstract Stmt
class, which (as the first such class that wasn't an Expr subclass)
required some fiddling in a few places.

There are somewhat gross metaprogramming hooks in place to ensure
that new statements/expressions continue to implement
getSourceRange() and children().  I had to work around a recent clang
bug;  dgregor actually fixed it already, but I didn't want to
introduce a selfhosting dependency on ToT.

llvm-svn: 125183
This commit is contained in:
John McCall 2011-02-09 08:16:59 +00:00
parent 392d2ed8a1
commit bd06678921
20 changed files with 438 additions and 934 deletions

View File

@ -54,8 +54,6 @@ typedef llvm::SmallVector<CXXBaseSpecifier*, 4> CXXCastPath;
class Expr : public Stmt {
QualType TR;
virtual void ANCHOR(); // key function.
protected:
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK,
bool TD, bool VD, bool ContainsUnexpandedParameterPack) : Stmt(SC) {
@ -138,14 +136,9 @@ public:
ExprBits.ContainsUnexpandedParameterPack = PP;
}
/// 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.
virtual SourceRange getSourceRange() const = 0;
/// getExprLoc - Return the preferred location for the arrow when diagnosing
/// a problem with a generic expression.
virtual SourceLocation getExprLoc() const { return getLocStart(); }
SourceLocation getExprLoc() const;
/// isUnusedResultAWarning - Return true if this immediate expression should
/// be warned about if the result is unused. If so, fill in Loc and Ranges
@ -682,7 +675,7 @@ public:
SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; }
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const;
/// \brief Determine whether this declaration reference was preceded by a
/// C++ nested-name-specifier, e.g., \c N::foo.
@ -786,8 +779,7 @@ public:
static bool classof(const DeclRefExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
friend class ASTStmtReader;
friend class ASTStmtWriter;
@ -827,7 +819,7 @@ public:
static std::string ComputeName(IdentType IT, const Decl *CurrentDecl);
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
SourceRange getSourceRange() const { return SourceRange(Loc); }
static bool classof(const Stmt *T) {
return T->getStmtClass() == PredefinedExprClass;
@ -835,8 +827,7 @@ public:
static bool classof(const PredefinedExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// \brief Used by IntegerLiteral/FloatingLiteral to store the numeric without
@ -913,7 +904,7 @@ public:
static IntegerLiteral *Create(ASTContext &C, EmptyShell Empty);
llvm::APInt getValue() const { return Num.getValue(); }
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
SourceRange getSourceRange() const { return SourceRange(Loc); }
/// \brief Retrieve the location of the literal.
SourceLocation getLocation() const { return Loc; }
@ -927,8 +918,7 @@ public:
static bool classof(const IntegerLiteral *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
class CharacterLiteral : public Expr {
@ -949,7 +939,7 @@ public:
SourceLocation getLocation() const { return Loc; }
bool isWide() const { return IsWide; }
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
SourceRange getSourceRange() const { return SourceRange(Loc); }
unsigned getValue() const { return Value; }
@ -963,8 +953,7 @@ public:
static bool classof(const CharacterLiteral *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
class FloatingLiteral : public Expr {
@ -1005,7 +994,7 @@ public:
SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; }
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
SourceRange getSourceRange() const { return SourceRange(Loc); }
static bool classof(const Stmt *T) {
return T->getStmtClass() == FloatingLiteralClass;
@ -1013,8 +1002,7 @@ public:
static bool classof(const FloatingLiteral *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// ImaginaryLiteral - We support imaginary integer and floating point literals,
@ -1038,15 +1026,14 @@ public:
Expr *getSubExpr() { return cast<Expr>(Val); }
void setSubExpr(Expr *E) { Val = E; }
virtual SourceRange getSourceRange() const { return Val->getSourceRange(); }
SourceRange getSourceRange() const { return Val->getSourceRange(); }
static bool classof(const Stmt *T) {
return T->getStmtClass() == ImaginaryLiteralClass;
}
static bool classof(const ImaginaryLiteral *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Val, &Val+1); }
};
/// StringLiteral - This represents a string literal expression, e.g. "foo"
@ -1139,7 +1126,7 @@ public:
tokloc_iterator tokloc_begin() const { return TokLocs; }
tokloc_iterator tokloc_end() const { return TokLocs+NumConcatenated; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(TokLocs[0], TokLocs[NumConcatenated-1]);
}
static bool classof(const Stmt *T) {
@ -1148,8 +1135,7 @@ public:
static bool classof(const StringLiteral *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// ParenExpr - This represents a parethesized expression, e.g. "(1)". This
@ -1173,7 +1159,7 @@ public:
Expr *getSubExpr() { return cast<Expr>(Val); }
void setSubExpr(Expr *E) { Val = E; }
virtual SourceRange getSourceRange() const { return SourceRange(L, R); }
SourceRange getSourceRange() const { return SourceRange(L, R); }
/// \brief Get the location of the left parentheses '('.
SourceLocation getLParen() const { return L; }
@ -1189,8 +1175,7 @@ public:
static bool classof(const ParenExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Val, &Val+1); }
};
@ -1271,13 +1256,13 @@ public:
/// the given unary opcode.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc);
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
if (isPostfix())
return SourceRange(Val->getLocStart(), Loc);
else
return SourceRange(Loc, Val->getLocEnd());
}
virtual SourceLocation getExprLoc() const { return Loc; }
SourceLocation getExprLoc() const { return Loc; }
static bool classof(const Stmt *T) {
return T->getStmtClass() == UnaryOperatorClass;
@ -1285,8 +1270,7 @@ public:
static bool classof(const UnaryOperator *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Val, &Val+1); }
};
/// OffsetOfExpr - [C99 7.17] - This represents an expression of the form
@ -1473,7 +1457,7 @@ public:
return NumExprs;
}
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(OperatorLoc, RParenLoc);
}
@ -1484,8 +1468,12 @@ public:
static bool classof(const OffsetOfExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
Stmt **begin =
reinterpret_cast<Stmt**>(reinterpret_cast<OffsetOfNode*>(this + 1)
+ NumComps);
return child_range(begin, begin + NumExprs);
}
};
/// SizeOfAlignOfExpr - [C99 6.5.3.4] - This is for sizeof/alignof, both of
@ -1565,7 +1553,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(OpLoc, RParenLoc);
}
@ -1575,8 +1563,7 @@ public:
static bool classof(const SizeOfAlignOfExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children();
};
//===----------------------------------------------------------------------===//
@ -1639,14 +1626,14 @@ public:
return cast<Expr>(getRHS()->getType()->isIntegerType() ? getRHS():getLHS());
}
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(getLHS()->getLocStart(), RBracketLoc);
}
SourceLocation getRBracketLoc() const { return RBracketLoc; }
void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
virtual SourceLocation getExprLoc() const { return getBase()->getExprLoc(); }
SourceLocation getExprLoc() const { return getBase()->getExprLoc(); }
static bool classof(const Stmt *T) {
return T->getStmtClass() == ArraySubscriptExprClass;
@ -1654,8 +1641,9 @@ public:
static bool classof(const ArraySubscriptExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
}
};
@ -1775,7 +1763,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(getCallee()->getLocStart(), RParenLoc);
}
@ -1786,8 +1774,10 @@ public:
static bool classof(const CallExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&SubExprs[0],
&SubExprs[0]+NumArgs+getNumPreArgs()+PREARGS_START);
}
};
/// MemberExpr - [C99 6.5.2.3] Structure and Union Members. X->F and X.F.
@ -2007,7 +1997,7 @@ public:
SourceLocation getMemberLoc() const { return MemberLoc; }
void setMemberLoc(SourceLocation L) { MemberLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
// If we have an implicit base (like a C++ implicit this),
// make sure not to return its location
SourceLocation EndLoc = (HasExplicitTemplateArgumentList)
@ -2019,7 +2009,7 @@ public:
return SourceRange(BaseLoc, EndLoc);
}
virtual SourceLocation getExprLoc() const { return MemberLoc; }
SourceLocation getExprLoc() const { return MemberLoc; }
static bool classof(const Stmt *T) {
return T->getStmtClass() == MemberExprClass;
@ -2027,8 +2017,7 @@ public:
static bool classof(const MemberExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Base, &Base+1); }
friend class ASTReader;
friend class ASTStmtWriter;
@ -2073,7 +2062,7 @@ public:
TypeSourceInfo *getTypeSourceInfo() const { return TInfo; }
void setTypeSourceInfo(TypeSourceInfo* tinfo) { TInfo = tinfo; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
// FIXME: Init should never be null.
if (!Init)
return SourceRange();
@ -2088,8 +2077,7 @@ public:
static bool classof(const CompoundLiteralExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Init, &Init+1); }
};
/// CastExpr - Base class for type casts, including both implicit
@ -2228,8 +2216,7 @@ public:
static bool classof(const CastExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Op, &Op+1); }
};
/// ImplicitCastExpr - Allows us to explicitly represent implicit type
@ -2277,7 +2264,7 @@ public:
static ImplicitCastExpr *CreateEmpty(ASTContext &Context, unsigned PathSize);
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return getSubExpr()->getSourceRange();
}
@ -2367,7 +2354,7 @@ public:
SourceLocation getRParenLoc() const { return RPLoc; }
void setRParenLoc(SourceLocation L) { RPLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(LPLoc, getSubExpr()->getSourceRange().getEnd());
}
static bool classof(const Stmt *T) {
@ -2436,7 +2423,7 @@ public:
Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
void setRHS(Expr *E) { SubExprs[RHS] = E; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(getLHS()->getLocStart(), getRHS()->getLocEnd());
}
@ -2503,8 +2490,9 @@ public:
static bool classof(const BinaryOperator *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
}
protected:
BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
@ -2636,7 +2624,7 @@ public:
SourceLocation getColonLoc() const { return ColonLoc; }
void setColonLoc(SourceLocation L) { ColonLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd());
}
static bool classof(const Stmt *T) {
@ -2645,8 +2633,9 @@ public:
static bool classof(const ConditionalOperator *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
}
};
/// AddrLabelExpr - The GNU address of label extension, representing &&label.
@ -2668,7 +2657,7 @@ public:
SourceLocation getLabelLoc() const { return LabelLoc; }
void setLabelLoc(SourceLocation L) { LabelLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(AmpAmpLoc, LabelLoc);
}
@ -2681,8 +2670,7 @@ public:
static bool classof(const AddrLabelExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
@ -2709,7 +2697,7 @@ public:
const CompoundStmt *getSubStmt() const { return cast<CompoundStmt>(SubStmt); }
void setSubStmt(CompoundStmt *S) { SubStmt = S; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(LParenLoc, RParenLoc);
}
@ -2724,8 +2712,7 @@ public:
static bool classof(const StmtExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&SubStmt, &SubStmt+1); }
};
@ -2760,7 +2747,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(BuiltinLoc, RParenLoc);
}
static bool classof(const Stmt *T) {
@ -2794,8 +2781,9 @@ public:
}
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&SubExprs[0], &SubExprs[0]+NumExprs);
}
};
/// ChooseExpr - GNU builtin-in function __builtin_choose_expr.
@ -2851,7 +2839,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(BuiltinLoc, RParenLoc);
}
static bool classof(const Stmt *T) {
@ -2860,8 +2848,9 @@ public:
static bool classof(const ChooseExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
}
};
/// GNUNullExpr - Implements the GNU __null extension, which is a name
@ -2886,7 +2875,7 @@ public:
SourceLocation getTokenLocation() const { return TokenLoc; }
void setTokenLocation(SourceLocation L) { TokenLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(TokenLoc);
}
static bool classof(const Stmt *T) {
@ -2895,8 +2884,7 @@ public:
static bool classof(const GNUNullExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// VAArgExpr, used for the builtin function __builtin_va_arg.
@ -2931,7 +2919,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(BuiltinLoc, RParenLoc);
}
static bool classof(const Stmt *T) {
@ -2940,8 +2928,7 @@ public:
static bool classof(const VAArgExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Val, &Val+1); }
};
/// @brief Describes an C or C++ initializer list.
@ -3080,7 +3067,7 @@ public:
HadArrayRangeDesignator = ARD;
}
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == InitListExprClass;
@ -3088,8 +3075,10 @@ public:
static bool classof(const InitListExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
if (InitExprs.empty()) return child_range();
return child_range(&InitExprs[0], &InitExprs[0] + InitExprs.size());
}
typedef InitExprsTy::iterator iterator;
typedef InitExprsTy::const_iterator const_iterator;
@ -3390,7 +3379,7 @@ public:
void ExpandDesignator(ASTContext &C, unsigned Idx, const Designator *First,
const Designator *Last);
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == DesignatedInitExprClass;
@ -3398,8 +3387,10 @@ public:
static bool classof(const DesignatedInitExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
Stmt **begin = reinterpret_cast<Stmt**>(this + 1);
return child_range(begin, begin + NumSubExprs);
}
};
/// \brief Represents an implicitly-generated value initialization of
@ -3425,13 +3416,12 @@ public:
}
static bool classof(const ImplicitValueInitExpr *) { return true; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange();
}
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
@ -3464,7 +3454,7 @@ public:
SourceLocation getLParenLoc() const { return LParenLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(LParenLoc, RParenLoc);
}
static bool classof(const Stmt *T) {
@ -3473,8 +3463,9 @@ public:
static bool classof(const ParenListExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&Exprs[0], &Exprs[0]+NumExprs);
}
friend class ASTStmtReader;
friend class ASTStmtWriter;
@ -3531,7 +3522,7 @@ public:
/// aggregate Constant of ConstantInt(s).
void getEncodedElementAccess(llvm::SmallVectorImpl<unsigned> &Elts) const;
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(getBase()->getLocStart(), AccessorLoc);
}
@ -3545,8 +3536,7 @@ public:
static bool classof(const ExtVectorElementExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Base, &Base+1); }
};
@ -3573,7 +3563,7 @@ public:
const Stmt *getBody() const;
Stmt *getBody();
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(getCaretLocation(), getBody()->getLocEnd());
}
@ -3586,8 +3576,7 @@ public:
static bool classof(const BlockExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// BlockDeclRefExpr - A reference to a local variable declared in an
@ -3613,7 +3602,7 @@ public:
SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; }
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
SourceRange getSourceRange() const { return SourceRange(Loc); }
bool isByRef() const { return IsByRef; }
void setByRef(bool BR) { IsByRef = BR; }
@ -3627,8 +3616,7 @@ public:
static bool classof(const BlockDeclRefExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// OpaqueValueExpr - An expression referring to an opaque object of a
@ -3654,9 +3642,8 @@ public:
/// \brief Retrieve the location of this expression.
SourceLocation getLocation() const { return Loc; }
virtual SourceRange getSourceRange() const;
virtual child_iterator child_begin();
virtual child_iterator child_end();
SourceRange getSourceRange() const { return Loc; }
child_range children() { return child_range(); }
static bool classof(const Stmt *T) {
return T->getStmtClass() == OpaqueValueExprClass;

View File

@ -71,7 +71,7 @@ public:
/// bracket.
SourceLocation getOperatorLoc() const { return getRParenLoc(); }
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXOperatorCallExprClass;
@ -108,7 +108,7 @@ public:
/// FIXME: Returns 0 for member pointer call exprs.
CXXRecordDecl *getRecordDecl();
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXMemberCallExprClass;
@ -151,7 +151,7 @@ public:
/// \brief Retrieve the location of the closing parenthesis.
SourceLocation getRParenLoc() const { return RParenLoc; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(Loc, RParenLoc);
}
static bool classof(const Stmt *T) {
@ -306,7 +306,7 @@ public:
bool getValue() const { return Value; }
void setValue(bool V) { Value = V; }
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
SourceRange getSourceRange() const { return SourceRange(Loc); }
SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; }
@ -317,8 +317,7 @@ public:
static bool classof(const CXXBoolLiteralExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal
@ -333,7 +332,7 @@ public:
explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
: Expr(CXXNullPtrLiteralExprClass, Empty) { }
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
SourceRange getSourceRange() const { return SourceRange(Loc); }
SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; }
@ -343,8 +342,7 @@ public:
}
static bool classof(const CXXNullPtrLiteralExpr *) { return true; }
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets
@ -411,7 +409,7 @@ public:
Operand = E;
}
virtual SourceRange getSourceRange() const { return Range; }
SourceRange getSourceRange() const { return Range; }
void setSourceRange(SourceRange R) { Range = R; }
static bool classof(const Stmt *T) {
@ -420,8 +418,11 @@ public:
static bool classof(const CXXTypeidExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
if (isTypeOperand()) return child_range();
Stmt **begin = reinterpret_cast<Stmt**>(&Operand);
return child_range(begin, begin + 1);
}
};
/// CXXUuidofExpr - A microsoft C++ @c __uuidof expression, which gets
@ -481,7 +482,7 @@ public:
Operand = E;
}
virtual SourceRange getSourceRange() const { return Range; }
SourceRange getSourceRange() const { return Range; }
void setSourceRange(SourceRange R) { Range = R; }
static bool classof(const Stmt *T) {
@ -490,8 +491,11 @@ public:
static bool classof(const CXXUuidofExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
if (isTypeOperand()) return child_range();
Stmt **begin = reinterpret_cast<Stmt**>(&Operand);
return child_range(begin, begin + 1);
}
};
/// CXXThisExpr - Represents the "this" expression in C++, which is a
@ -523,7 +527,7 @@ public:
SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; }
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
SourceRange getSourceRange() const { return SourceRange(Loc); }
bool isImplicit() const { return Implicit; }
void setImplicit(bool I) { Implicit = I; }
@ -534,8 +538,7 @@ public:
static bool classof(const CXXThisExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles
@ -562,7 +565,7 @@ public:
SourceLocation getThrowLoc() const { return ThrowLoc; }
void setThrowLoc(SourceLocation L) { ThrowLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
if (getSubExpr() == 0)
return SourceRange(ThrowLoc, ThrowLoc);
return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd());
@ -574,8 +577,9 @@ public:
static bool classof(const CXXThrowExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&Op, Op ? &Op+1 : &Op);
}
};
/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a
@ -649,7 +653,7 @@ public:
/// used.
SourceLocation getUsedLocation() const { return Loc; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
// Default argument expressions have no representation in the
// source, so they have an empty source range.
return SourceRange();
@ -661,8 +665,7 @@ public:
static bool classof(const CXXDefaultArgExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
friend class ASTStmtReader;
friend class ASTStmtWriter;
@ -724,7 +727,7 @@ public:
Expr *getSubExpr() { return cast<Expr>(SubExpr); }
void setSubExpr(Expr *E) { SubExpr = E; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SubExpr->getSourceRange();
}
@ -735,8 +738,7 @@ public:
static bool classof(const CXXBindTemporaryExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
};
/// CXXConstructExpr - Represents a call to a C++ constructor.
@ -842,7 +844,7 @@ public:
Args[Arg] = ArgExpr;
}
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const;
SourceRange getParenRange() const { return ParenRange; }
static bool classof(const Stmt *T) {
@ -852,8 +854,9 @@ public:
static bool classof(const CXXConstructExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&Args[0], &Args[0]+NumArgs);
}
friend class ASTStmtReader;
};
@ -893,7 +896,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(TyBeginLoc, RParenLoc);
}
static bool classof(const Stmt *T) {
@ -931,7 +934,7 @@ public:
TypeSourceInfo *getTypeSourceInfo() const { return Type; }
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXTemporaryObjectExprClass;
@ -970,7 +973,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXScalarValueInitExprClass;
@ -978,8 +981,7 @@ public:
static bool classof(const CXXScalarValueInitExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// CXXNewExpr - A new expression for memory allocation and constructor calls,
@ -1152,7 +1154,7 @@ public:
SourceLocation getConstructorLParen() const { return ConstructorLParen; }
SourceLocation getConstructorRParen() const { return ConstructorRParen; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(StartLoc, EndLoc);
}
@ -1162,8 +1164,11 @@ public:
static bool classof(const CXXNewExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&SubExprs[0],
&SubExprs[0] + Array + getNumPlacementArgs()
+ getNumConstructorArgs());
}
};
/// CXXDeleteExpr - A delete expression for memory deallocation and destructor
@ -1221,7 +1226,7 @@ public:
/// return an invalid type.
QualType getDestroyedType() const;
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(Loc, Argument->getLocEnd());
}
@ -1231,8 +1236,7 @@ public:
static bool classof(const CXXDeleteExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Argument, &Argument+1); }
friend class ASTStmtReader;
};
@ -1424,7 +1428,7 @@ public:
DestroyedType = PseudoDestructorTypeStorage(Info);
}
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXPseudoDestructorExprClass;
@ -1432,8 +1436,7 @@ public:
static bool classof(const CXXPseudoDestructorExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Base, &Base + 1); }
};
/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the
@ -1469,7 +1472,7 @@ public:
: Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false),
QueriedType() { }
virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
SourceRange getSourceRange() const { return SourceRange(Loc, RParen);}
UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); }
@ -1485,8 +1488,7 @@ public:
static bool classof(const UnaryTypeTraitExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
friend class ASTStmtReader;
};
@ -1531,7 +1533,7 @@ public:
: Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false),
LhsType(), RhsType() { }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(Loc, RParen);
}
@ -1553,8 +1555,7 @@ public:
static bool classof(const BinaryTypeTraitExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
friend class ASTStmtReader;
};
@ -1825,15 +1826,14 @@ public:
return getExplicitTemplateArgs().NumTemplateArgs;
}
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
SourceRange Range(getNameInfo().getSourceRange());
if (getQualifier()) Range.setBegin(getQualifierRange().getBegin());
if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc());
return Range;
}
virtual StmtIterator child_begin();
virtual StmtIterator child_end();
child_range children() { return child_range(); }
static bool classof(const Stmt *T) {
return T->getStmtClass() == UnresolvedLookupExprClass;
@ -1956,7 +1956,7 @@ public:
return getExplicitTemplateArgs().NumTemplateArgs;
}
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
SourceRange Range(QualifierRange.getBegin(), getLocation());
if (hasExplicitTemplateArgs())
Range.setEnd(getRAngleLoc());
@ -1968,8 +1968,7 @@ public:
}
static bool classof(const DependentScopeDeclRefExpr *) { return true; }
virtual StmtIterator child_begin();
virtual StmtIterator child_end();
child_range children() { return child_range(); }
friend class ASTStmtReader;
friend class ASTStmtWriter;
@ -2017,7 +2016,7 @@ public:
const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
void setSubExpr(Expr *E) { SubExpr = E; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SubExpr->getSourceRange();
}
@ -2028,8 +2027,7 @@ public:
static bool classof(const ExprWithCleanups *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&SubExpr, &SubExpr + 1); }
};
/// \brief Describes an explicit type conversion that uses functional
@ -2136,7 +2134,7 @@ public:
*(arg_begin() + I) = E;
}
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXUnresolvedConstructExprClass;
@ -2144,8 +2142,10 @@ public:
static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
Stmt **begin = reinterpret_cast<Stmt**>(this+1);
return child_range(begin, begin + NumArgs);
}
};
/// \brief Represents a C++ member access expression where the actual
@ -2361,7 +2361,7 @@ public:
return getExplicitTemplateArgs().RAngleLoc;
}
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
SourceRange Range;
if (!isImplicitAccess())
Range.setBegin(Base->getSourceRange().getBegin());
@ -2383,8 +2383,10 @@ public:
static bool classof(const CXXDependentScopeMemberExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
if (isImplicitAccess()) return child_range();
return child_range(&Base, &Base + 1);
}
friend class ASTStmtReader;
friend class ASTStmtWriter;
@ -2554,7 +2556,7 @@ public:
return getExplicitTemplateArgs().RAngleLoc;
}
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
SourceRange Range = getMemberNameInfo().getSourceRange();
if (!isImplicitAccess())
Range.setBegin(Base->getSourceRange().getBegin());
@ -2572,8 +2574,10 @@ public:
static bool classof(const UnresolvedMemberExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
if (isImplicitAccess()) return child_range();
return child_range(&Base, &Base + 1);
}
};
/// \brief Represents a C++0x noexcept expression (C++ [expr.unary.noexcept]).
@ -2603,7 +2607,7 @@ public:
Expr *getOperand() const { return static_cast<Expr*>(Operand); }
virtual SourceRange getSourceRange() const { return Range; }
SourceRange getSourceRange() const { return Range; }
bool getValue() const { return Value; }
@ -2613,8 +2617,7 @@ public:
static bool classof(const CXXNoexceptExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Operand, &Operand + 1); }
};
/// \brief Represents a C++0x pack expansion that produces a sequence of
@ -2680,7 +2683,9 @@ public:
return llvm::Optional<unsigned>();
}
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const {
return SourceRange(Pattern->getLocStart(), EllipsisLoc);
}
static bool classof(const Stmt *T) {
return T->getStmtClass() == PackExpansionExprClass;
@ -2688,8 +2693,9 @@ public:
static bool classof(const PackExpansionExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&Pattern, &Pattern + 1);
}
};
inline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() {
@ -2778,7 +2784,9 @@ public:
return Length;
}
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const {
return SourceRange(OperatorLoc, RParenLoc);
}
static bool classof(const Stmt *T) {
return T->getStmtClass() == SizeOfPackExprClass;
@ -2786,8 +2794,7 @@ public:
static bool classof(const SizeOfPackExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// \brief Represents a reference to a non-type template parameter pack that
@ -2838,7 +2845,7 @@ public:
/// template arguments.
TemplateArgument getArgumentPack() const;
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const { return NameLoc; }
static bool classof(const Stmt *T) {
return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass;
@ -2848,8 +2855,7 @@ public:
}
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
} // end namespace clang

View File

@ -42,7 +42,7 @@ public:
SourceLocation getAtLoc() const { return AtLoc; }
void setAtLoc(SourceLocation L) { AtLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(AtLoc, String->getLocEnd());
}
@ -52,8 +52,7 @@ public:
static bool classof(const ObjCStringLiteral *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&String, &String+1); }
};
/// ObjCEncodeExpr, used for @encode in Objective-C. @encode has the same type
@ -86,7 +85,7 @@ public:
EncodedType = EncType;
}
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(AtLoc, RParenLoc);
}
@ -96,8 +95,7 @@ public:
static bool classof(const ObjCEncodeExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// ObjCSelectorExpr used for @selector in Objective-C.
@ -121,7 +119,7 @@ public:
void setAtLoc(SourceLocation L) { AtLoc = L; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(AtLoc, RParenLoc);
}
@ -134,8 +132,7 @@ public:
static bool classof(const ObjCSelectorExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// ObjCProtocolExpr used for protocol expression in Objective-C. This is used
@ -162,7 +159,7 @@ public:
void setAtLoc(SourceLocation L) { AtLoc = L; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(AtLoc, RParenLoc);
}
@ -172,8 +169,7 @@ public:
static bool classof(const ObjCProtocolExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// ObjCIvarRefExpr - A reference to an ObjC instance variable.
@ -212,7 +208,7 @@ public:
SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return isFreeIvar() ? SourceRange(Loc)
: SourceRange(getBase()->getLocStart(), Loc);
}
@ -223,8 +219,7 @@ public:
static bool classof(const ObjCIvarRefExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Base, &Base+1); }
};
/// ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC
@ -349,7 +344,7 @@ public:
bool isSuperReceiver() const { return Receiver.is<const Type*>(); }
bool isClassReceiver() const { return Receiver.is<ObjCInterfaceDecl*>(); }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange((isObjectReceiver() ? getBase()->getLocStart()
: getReceiverLocation()),
IdLoc);
@ -361,8 +356,14 @@ public:
static bool classof(const ObjCPropertyRefExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
if (Receiver.is<Stmt*>()) {
Stmt **begin = reinterpret_cast<Stmt**>(&Receiver); // hack!
return child_range(begin, begin+1);
}
return child_range();
}
private:
friend class ASTStmtReader;
void setExplicitProperty(ObjCPropertyDecl *D) {
@ -776,7 +777,7 @@ public:
LBracLoc = R.getBegin();
RBracLoc = R.getEnd();
}
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(LBracLoc, RBracLoc);
}
@ -786,8 +787,7 @@ public:
static bool classof(const ObjCMessageExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children();
typedef ExprIterator arg_iterator;
typedef ConstExprIterator const_arg_iterator;
@ -839,11 +839,11 @@ public:
SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; }
void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(getBase()->getLocStart(), IsaMemberLoc);
}
virtual SourceLocation getExprLoc() const { return IsaMemberLoc; }
SourceLocation getExprLoc() const { return IsaMemberLoc; }
static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCIsaExprClass;
@ -851,8 +851,7 @@ public:
static bool classof(const ObjCIsaExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Base, &Base+1); }
};
} // end namespace clang

View File

@ -1636,7 +1636,6 @@ DEF_TRAVERSE_STMT(ObjCAtThrowStmt, { })
DEF_TRAVERSE_STMT(ObjCAtTryStmt, { })
DEF_TRAVERSE_STMT(ObjCForCollectionStmt, { })
DEF_TRAVERSE_STMT(ReturnStmt, { })
DEF_TRAVERSE_STMT(SwitchCase, { })
DEF_TRAVERSE_STMT(SwitchStmt, { })
DEF_TRAVERSE_STMT(WhileStmt, { })

View File

@ -182,6 +182,9 @@ protected:
};
union {
// FIXME: this is wasteful on 64-bit platforms.
void *Aligner;
StmtBitfields StmtBits;
CompoundStmtBitfields CompoundStmtBits;
LabelStmtBitfields LabelStmtBits;
@ -232,7 +235,6 @@ public:
StmtBits.sClass = SC;
if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
}
virtual ~Stmt() {}
StmtClass getStmtClass() const {
return static_cast<StmtClass>(StmtBits.sClass);
@ -242,7 +244,8 @@ public:
/// 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.
virtual SourceRange getSourceRange() const = 0;
SourceRange getSourceRange() const;
SourceLocation getLocStart() const { return getSourceRange().getBegin(); }
SourceLocation getLocEnd() const { return getSourceRange().getEnd(); }
@ -289,22 +292,25 @@ public:
/// within CFGs.
bool hasImplicitControlFlow() const;
/// Child Iterators: All subclasses must implement child_begin and child_end
/// to permit easy iteration over the substatements/subexpessions of an
/// AST node. This permits easy iteration over all nodes in the AST.
/// Child Iterators: All subclasses must implement 'children'
/// to permit easy iteration over the substatements/subexpessions of an
/// 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;
typedef StmtRange child_range;
typedef ConstStmtRange const_child_range;
const_child_iterator child_begin() const {
return const_child_iterator(const_cast<Stmt*>(this)->child_begin());
child_range children();
const_child_range children() const {
return const_cast<Stmt*>(this)->children();
}
const_child_iterator child_end() const {
return const_child_iterator(const_cast<Stmt*>(this)->child_end());
}
child_iterator child_begin() { return children().first; }
child_iterator child_end() { return children().second; }
const_child_iterator child_begin() const { return children().first; }
const_child_iterator child_end() const { return children().second; }
/// \brief Produce a unique representation of the given statement.
///
@ -367,8 +373,10 @@ public:
static bool classof(const DeclStmt *) { return true; }
// Iterators over subexpressions.
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(child_iterator(DG.begin(), DG.end()),
child_iterator(DG.end(), DG.end()));
}
typedef DeclGroupRef::iterator decl_iterator;
typedef DeclGroupRef::const_iterator const_decl_iterator;
@ -402,16 +410,14 @@ public:
bool hasLeadingEmptyMacro() const { return LeadingEmptyMacro; }
virtual SourceRange getSourceRange() const { return SourceRange(SemiLoc); }
SourceRange getSourceRange() const { return SourceRange(SemiLoc); }
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();
child_range children() { return child_range(); }
friend class ASTStmtReader;
friend class ASTStmtWriter;
@ -482,7 +488,7 @@ public:
return const_reverse_body_iterator(body_begin());
}
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(LBracLoc, RBracLoc);
}
@ -497,8 +503,9 @@ public:
static bool classof(const CompoundStmt *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&Body[0], &Body[0]+CompoundStmtBits.NumStmts);
}
};
// SwitchCase is the base class for CaseStmt and DefaultStmt,
@ -517,17 +524,15 @@ public:
void setNextSwitchCase(SwitchCase *SC) { NextSwitchCase = SC; }
Stmt *getSubStmt() { return v_getSubStmt(); }
Stmt *getSubStmt();
virtual SourceRange getSourceRange() const { return SourceRange(); }
SourceRange getSourceRange() const { return SourceRange(); }
static bool classof(const Stmt *T) {
return T->getStmtClass() == CaseStmtClass ||
T->getStmtClass() == DefaultStmtClass;
T->getStmtClass() == DefaultStmtClass;
}
static bool classof(const SwitchCase *) { return true; }
protected:
virtual Stmt* v_getSubStmt() = 0;
};
class CaseStmt : public SwitchCase {
@ -537,8 +542,6 @@ class CaseStmt : public SwitchCase {
SourceLocation CaseLoc;
SourceLocation EllipsisLoc;
SourceLocation ColonLoc;
virtual Stmt* v_getSubStmt() { return getSubStmt(); }
public:
CaseStmt(Expr *lhs, Expr *rhs, SourceLocation caseLoc,
SourceLocation ellipsisLoc, SourceLocation colonLoc)
@ -578,7 +581,7 @@ public:
void setRHS(Expr *Val) { SubExprs[RHS] = reinterpret_cast<Stmt*>(Val); }
virtual SourceRange getSourceRange() const {
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()))
@ -592,15 +595,15 @@ public:
static bool classof(const CaseStmt *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&SubExprs[0], &SubExprs[END_EXPR]);
}
};
class DefaultStmt : public SwitchCase {
Stmt* SubStmt;
SourceLocation DefaultLoc;
SourceLocation ColonLoc;
virtual Stmt* v_getSubStmt() { return getSubStmt(); }
public:
DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt) :
SwitchCase(DefaultStmtClass), SubStmt(substmt), DefaultLoc(DL),
@ -618,7 +621,7 @@ public:
SourceLocation getColonLoc() const { return ColonLoc; }
void setColonLoc(SourceLocation L) { ColonLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(DefaultLoc, SubStmt->getLocEnd());
}
static bool classof(const Stmt *T) {
@ -627,8 +630,7 @@ public:
static bool classof(const DefaultStmt *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&SubStmt, &SubStmt+1); }
};
class LabelStmt : public Stmt {
@ -665,17 +667,15 @@ public:
bool HasUnusedAttribute() const { return LabelStmtBits.HasUnusedAttr; }
void setUnusedAttribute(bool U) { LabelStmtBits.HasUnusedAttr = U; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(IdentLoc, SubStmt->getLocEnd());
}
child_range children() { return child_range(&SubStmt, &SubStmt+1); }
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();
};
@ -722,22 +722,23 @@ public:
SourceLocation getElseLoc() const { return ElseLoc; }
void setElseLoc(SourceLocation L) { ElseLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
if (SubExprs[ELSE])
return SourceRange(IfLoc, SubExprs[ELSE]->getLocEnd());
else
return SourceRange(IfLoc, SubExprs[THEN]->getLocEnd());
}
// Iterators over subexpressions. The iterators will include iterating
// over the initialization expression referenced by the condition variable.
child_range children() {
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
}
static bool classof(const Stmt *T) {
return T->getStmtClass() == IfStmtClass;
}
static bool classof(const IfStmt *) { return true; }
// Iterators over subexpressions. The iterators will include iterating
// over the initialization expression referenced by the condition variable.
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
/// SwitchStmt - This represents a 'switch' stmt.
@ -813,17 +814,18 @@ public:
return (bool) AllEnumCasesCovered;
}
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(SwitchLoc, SubExprs[BODY]->getLocEnd());
}
// Iterators
child_range children() {
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
}
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();
};
@ -861,7 +863,7 @@ public:
SourceLocation getWhileLoc() const { return WhileLoc; }
void setWhileLoc(SourceLocation L) { WhileLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(WhileLoc, SubExprs[BODY]->getLocEnd());
}
static bool classof(const Stmt *T) {
@ -870,8 +872,9 @@ public:
static bool classof(const WhileStmt *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
}
};
/// DoStmt - This represents a 'do/while' stmt.
@ -909,7 +912,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(DoLoc, RParenLoc);
}
static bool classof(const Stmt *T) {
@ -918,8 +921,9 @@ public:
static bool classof(const DoStmt *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
}
};
@ -974,7 +978,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
}
static bool classof(const Stmt *T) {
@ -983,8 +987,9 @@ public:
static bool classof(const ForStmt *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
}
};
/// GotoStmt - This represents a direct goto.
@ -1008,7 +1013,7 @@ public:
SourceLocation getLabelLoc() const { return LabelLoc; }
void setLabelLoc(SourceLocation L) { LabelLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(GotoLoc, LabelLoc);
}
static bool classof(const Stmt *T) {
@ -1017,8 +1022,7 @@ public:
static bool classof(const GotoStmt *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// IndirectGotoStmt - This represents an indirect goto.
@ -1053,7 +1057,7 @@ public:
return const_cast<IndirectGotoStmt*>(this)->getConstantTarget();
}
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(GotoLoc, Target->getLocEnd());
}
@ -1063,8 +1067,7 @@ public:
static bool classof(const IndirectGotoStmt *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Target, &Target+1); }
};
@ -1081,7 +1084,7 @@ public:
SourceLocation getContinueLoc() const { return ContinueLoc; }
void setContinueLoc(SourceLocation L) { ContinueLoc = L; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(ContinueLoc);
}
@ -1091,8 +1094,7 @@ public:
static bool classof(const ContinueStmt *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
/// BreakStmt - This represents a break.
@ -1108,7 +1110,7 @@ public:
SourceLocation getBreakLoc() const { return BreakLoc; }
void setBreakLoc(SourceLocation L) { BreakLoc = L; }
virtual SourceRange getSourceRange() const { return SourceRange(BreakLoc); }
SourceRange getSourceRange() const { return SourceRange(BreakLoc); }
static bool classof(const Stmt *T) {
return T->getStmtClass() == BreakStmtClass;
@ -1116,8 +1118,7 @@ public:
static bool classof(const BreakStmt *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(); }
};
@ -1161,7 +1162,7 @@ public:
const VarDecl *getNRVOCandidate() const { return NRVOCandidate; }
void setNRVOCandidate(const VarDecl *Var) { NRVOCandidate = Var; }
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == ReturnStmtClass;
@ -1169,8 +1170,10 @@ public:
static bool classof(const ReturnStmt *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
if (RetExpr) return child_range(&RetExpr, &RetExpr+1);
return child_range();
}
};
/// AsmStmt - This represents a GNU inline-assembly statement extension.
@ -1368,7 +1371,7 @@ public:
StringLiteral *getClobber(unsigned i) { return Clobbers[i]; }
const StringLiteral *getClobber(unsigned i) const { return Clobbers[i]; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(AsmLoc, RParenLoc);
}
@ -1415,10 +1418,9 @@ public:
return &Exprs[0] + NumOutputs;
}
// Child iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs);
}
};
} // end namespace clang

View File

@ -37,7 +37,7 @@ public:
CXXCatchStmt(EmptyShell Empty)
: Stmt(CXXCatchStmtClass), ExceptionDecl(0), HandlerBlock(0) {}
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(CatchLoc, HandlerBlock->getLocEnd());
}
@ -51,8 +51,7 @@ public:
}
static bool classof(const CXXCatchStmt *) { return true; }
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&HandlerBlock, &HandlerBlock+1); }
friend class ASTStmtReader;
};
@ -84,7 +83,7 @@ public:
static CXXTryStmt *Create(ASTContext &C, EmptyShell Empty,
unsigned numHandlers);
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(getTryLoc(), getEndLoc());
}
@ -113,8 +112,9 @@ public:
}
static bool classof(const CXXTryStmt *) { return true; }
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(getStmts(), getStmts() + getNumHandlers() + 1);
}
friend class ASTStmtReader;
};

View File

@ -1,4 +1,4 @@
//===--- StmtIterator.h - Iterators for Statements ------------------------===//
//===--- StmtIterator.h - Iterators for Statements --------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@ -146,6 +146,15 @@ struct ConstStmtIterator : public StmtIteratorImpl<ConstStmtIterator,
StmtIteratorImpl<ConstStmtIterator,const Stmt*>(RHS) {}
};
typedef std::pair<StmtIterator,StmtIterator> StmtRange;
typedef std::pair<ConstStmtIterator,ConstStmtIterator> ConstStmtRange;
inline StmtIterator begin(StmtRange range) { return range.first; }
inline StmtIterator end(StmtRange range) { return range.second; }
inline ConstStmtIterator begin(ConstStmtRange range) { return range.first; }
inline ConstStmtIterator end(ConstStmtRange range) { return range.second; }
} // end namespace clang
#endif

View File

@ -55,7 +55,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
}
static bool classof(const Stmt *T) {
@ -64,8 +64,9 @@ public:
static bool classof(const ObjCForCollectionStmt *) { return true; }
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&SubExprs[0], &SubExprs[END_EXPR]);
}
};
/// ObjCAtCatchStmt - This represents objective-c's @catch statement.
@ -102,7 +103,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(AtCatchLoc, Body->getLocEnd());
}
@ -113,8 +114,7 @@ public:
}
static bool classof(const ObjCAtCatchStmt *) { return true; }
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Body, &Body + 1); }
};
/// ObjCAtFinallyStmt - This represent objective-c's @finally Statement
@ -133,7 +133,7 @@ public:
Stmt *getFinallyBody() { return AtFinallyStmt; }
void setFinallyBody(Stmt *S) { AtFinallyStmt = S; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd());
}
@ -145,8 +145,9 @@ public:
}
static bool classof(const ObjCAtFinallyStmt *) { return true; }
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&AtFinallyStmt, &AtFinallyStmt+1);
}
};
/// ObjCAtTryStmt - This represent objective-c's over-all
@ -239,15 +240,17 @@ public:
getStmts()[1 + NumCatchStmts] = S;
}
virtual SourceRange getSourceRange() const;
SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCAtTryStmtClass;
}
static bool classof(const ObjCAtTryStmt *) { return true; }
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(getStmts(),
getStmts() + 1 + NumCatchStmts + HasFinally);
}
};
/// ObjCAtSynchronizedStmt - This is for objective-c's @synchronized statement.
@ -291,7 +294,7 @@ public:
}
void setSynchExpr(Stmt *S) { SubStmts[SYNC_EXPR] = S; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
return SourceRange(AtSynchronizedLoc, getSynchBody()->getLocEnd());
}
@ -300,8 +303,9 @@ public:
}
static bool classof(const ObjCAtSynchronizedStmt *) { return true; }
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() {
return child_range(&SubStmts[0], &SubStmts[0]+END_EXPR);
}
};
/// ObjCAtThrowStmt - This represents objective-c's @throw statement.
@ -323,7 +327,7 @@ public:
SourceLocation getThrowLoc() { return AtThrowLoc; }
void setThrowLoc(SourceLocation Loc) { AtThrowLoc = Loc; }
virtual SourceRange getSourceRange() const {
SourceRange getSourceRange() const {
if (Throw)
return SourceRange(AtThrowLoc, Throw->getLocEnd());
else
@ -335,8 +339,7 @@ public:
}
static bool classof(const ObjCAtThrowStmt *) { return true; }
virtual child_iterator child_begin();
virtual child_iterator child_end();
child_range children() { return child_range(&Throw, &Throw+1); }
};
} // end namespace clang

View File

@ -23,7 +23,7 @@ def ContinueStmt : Stmt;
def BreakStmt : Stmt;
def ReturnStmt : Stmt;
def DeclStmt : Stmt;
def SwitchCase : Stmt;
def SwitchCase : Stmt<1>;
def CaseStmt : DStmt<SwitchCase>;
def DefaultStmt : DStmt<SwitchCase>;

View File

@ -30,8 +30,6 @@
#include <algorithm>
using namespace clang;
void Expr::ANCHOR() {} // key function for Expr class.
/// isKnownToHaveBooleanValue - Return true if this is an integer expression
/// that is known to return 0 or 1. This happens for _Bool/bool expressions
/// but also int expressions which are produced by things like comparisons in
@ -93,6 +91,42 @@ bool Expr::isKnownToHaveBooleanValue() const {
return false;
}
// Amusing macro metaprogramming hack: check whether a class provides
// a more specific implementation of getExprLoc().
namespace {
/// This implementation is used when a class provides a custom
/// implementation of getExprLoc.
template <class E, class T>
SourceLocation getExprLocImpl(const Expr *expr,
SourceLocation (T::*v)() const) {
return static_cast<const E*>(expr)->getExprLoc();
}
/// This implementation is used when a class doesn't provide
/// a custom implementation of getExprLoc. Overload resolution
/// should pick it over the implementation above because it's
/// more specialized according to function template partial ordering.
template <class E>
SourceLocation getExprLocImpl(const Expr *expr,
SourceLocation (Expr::*v)() const) {
return static_cast<const E*>(expr)->getSourceRange().getBegin();
}
}
SourceLocation Expr::getExprLoc() const {
switch (getStmtClass()) {
case Stmt::NoStmtClass: llvm_unreachable("statement without class");
#define ABSTRACT_STMT(type)
#define STMT(type, base) \
case Stmt::type##Class: llvm_unreachable(#type " is not an Expr"); break;
#define EXPR(type, base) \
case Stmt::type##Class: return getExprLocImpl<type>(this, &type::getExprLoc);
#include "clang/AST/StmtNodes.inc"
}
llvm_unreachable("unknown statement kind");
return SourceLocation();
}
//===----------------------------------------------------------------------===//
// Primary Expressions.
//===----------------------------------------------------------------------===//
@ -1560,7 +1594,8 @@ static Expr::CanThrowResult MergeCanThrow(Expr::CanThrowResult CT1,
static Expr::CanThrowResult CanSubExprsThrow(ASTContext &C, const Expr *CE) {
Expr *E = const_cast<Expr*>(CE);
Expr::CanThrowResult R = Expr::CT_Cannot;
for (Expr::child_iterator I = E->child_begin(), IE = E->child_end();
Expr::child_iterator I, IE;
for (llvm::tie(I, IE) = E->children();
I != IE && R != Expr::CT_Can; ++I) {
R = MergeCanThrow(R, cast<Expr>(*I)->CanThrow(C));
}
@ -2735,242 +2770,29 @@ const Expr* ConstExprIterator::operator->() const { return cast<Expr>(*I); }
// Child Iterators for iterating over subexpressions/substatements
//===----------------------------------------------------------------------===//
// DeclRefExpr
Stmt::child_iterator DeclRefExpr::child_begin() { return child_iterator(); }
Stmt::child_iterator DeclRefExpr::child_end() { return child_iterator(); }
// ObjCIvarRefExpr
Stmt::child_iterator ObjCIvarRefExpr::child_begin() { return &Base; }
Stmt::child_iterator ObjCIvarRefExpr::child_end() { return &Base+1; }
// ObjCPropertyRefExpr
Stmt::child_iterator ObjCPropertyRefExpr::child_begin()
{
if (Receiver.is<Stmt*>()) {
// Hack alert!
return reinterpret_cast<Stmt**> (&Receiver);
}
return child_iterator();
}
Stmt::child_iterator ObjCPropertyRefExpr::child_end()
{ return Receiver.is<Stmt*>() ?
reinterpret_cast<Stmt**> (&Receiver)+1 :
child_iterator();
}
// ObjCIsaExpr
Stmt::child_iterator ObjCIsaExpr::child_begin() { return &Base; }
Stmt::child_iterator ObjCIsaExpr::child_end() { return &Base+1; }
// PredefinedExpr
Stmt::child_iterator PredefinedExpr::child_begin() { return child_iterator(); }
Stmt::child_iterator PredefinedExpr::child_end() { return child_iterator(); }
// IntegerLiteral
Stmt::child_iterator IntegerLiteral::child_begin() { return child_iterator(); }
Stmt::child_iterator IntegerLiteral::child_end() { return child_iterator(); }
// CharacterLiteral
Stmt::child_iterator CharacterLiteral::child_begin() { return child_iterator();}
Stmt::child_iterator CharacterLiteral::child_end() { return child_iterator(); }
// FloatingLiteral
Stmt::child_iterator FloatingLiteral::child_begin() { return child_iterator(); }
Stmt::child_iterator FloatingLiteral::child_end() { return child_iterator(); }
// ImaginaryLiteral
Stmt::child_iterator ImaginaryLiteral::child_begin() { return &Val; }
Stmt::child_iterator ImaginaryLiteral::child_end() { return &Val+1; }
// StringLiteral
Stmt::child_iterator StringLiteral::child_begin() { return child_iterator(); }
Stmt::child_iterator StringLiteral::child_end() { return child_iterator(); }
// ParenExpr
Stmt::child_iterator ParenExpr::child_begin() { return &Val; }
Stmt::child_iterator ParenExpr::child_end() { return &Val+1; }
// UnaryOperator
Stmt::child_iterator UnaryOperator::child_begin() { return &Val; }
Stmt::child_iterator UnaryOperator::child_end() { return &Val+1; }
// OffsetOfExpr
Stmt::child_iterator OffsetOfExpr::child_begin() {
return reinterpret_cast<Stmt **> (reinterpret_cast<OffsetOfNode *> (this + 1)
+ NumComps);
}
Stmt::child_iterator OffsetOfExpr::child_end() {
return child_iterator(&*child_begin() + NumExprs);
}
// SizeOfAlignOfExpr
Stmt::child_iterator SizeOfAlignOfExpr::child_begin() {
Stmt::child_range SizeOfAlignOfExpr::children() {
// If this is of a type and the type is a VLA type (and not a typedef), the
// size expression of the VLA needs to be treated as an executable expression.
// Why isn't this weirdness documented better in StmtIterator?
if (isArgumentType()) {
if (const VariableArrayType* T = dyn_cast<VariableArrayType>(
getArgumentType().getTypePtr()))
return child_iterator(T);
return child_iterator();
return child_range(child_iterator(T), child_iterator());
return child_range();
}
return child_iterator(&Argument.Ex);
}
Stmt::child_iterator SizeOfAlignOfExpr::child_end() {
if (isArgumentType())
return child_iterator();
return child_iterator(&Argument.Ex + 1);
}
// ArraySubscriptExpr
Stmt::child_iterator ArraySubscriptExpr::child_begin() {
return &SubExprs[0];
}
Stmt::child_iterator ArraySubscriptExpr::child_end() {
return &SubExprs[0]+END_EXPR;
}
// CallExpr
Stmt::child_iterator CallExpr::child_begin() {
return &SubExprs[0];
}
Stmt::child_iterator CallExpr::child_end() {
return &SubExprs[0]+NumArgs+getNumPreArgs()+PREARGS_START;
}
// MemberExpr
Stmt::child_iterator MemberExpr::child_begin() { return &Base; }
Stmt::child_iterator MemberExpr::child_end() { return &Base+1; }
// ExtVectorElementExpr
Stmt::child_iterator ExtVectorElementExpr::child_begin() { return &Base; }
Stmt::child_iterator ExtVectorElementExpr::child_end() { return &Base+1; }
// CompoundLiteralExpr
Stmt::child_iterator CompoundLiteralExpr::child_begin() { return &Init; }
Stmt::child_iterator CompoundLiteralExpr::child_end() { return &Init+1; }
// CastExpr
Stmt::child_iterator CastExpr::child_begin() { return &Op; }
Stmt::child_iterator CastExpr::child_end() { return &Op+1; }
// BinaryOperator
Stmt::child_iterator BinaryOperator::child_begin() {
return &SubExprs[0];
}
Stmt::child_iterator BinaryOperator::child_end() {
return &SubExprs[0]+END_EXPR;
}
// ConditionalOperator
Stmt::child_iterator ConditionalOperator::child_begin() {
return &SubExprs[0];
}
Stmt::child_iterator ConditionalOperator::child_end() {
return &SubExprs[0]+END_EXPR;
}
// AddrLabelExpr
Stmt::child_iterator AddrLabelExpr::child_begin() { return child_iterator(); }
Stmt::child_iterator AddrLabelExpr::child_end() { return child_iterator(); }
// StmtExpr
Stmt::child_iterator StmtExpr::child_begin() { return &SubStmt; }
Stmt::child_iterator StmtExpr::child_end() { return &SubStmt+1; }
// ChooseExpr
Stmt::child_iterator ChooseExpr::child_begin() { return &SubExprs[0]; }
Stmt::child_iterator ChooseExpr::child_end() { return &SubExprs[0]+END_EXPR; }
// GNUNullExpr
Stmt::child_iterator GNUNullExpr::child_begin() { return child_iterator(); }
Stmt::child_iterator GNUNullExpr::child_end() { return child_iterator(); }
// ShuffleVectorExpr
Stmt::child_iterator ShuffleVectorExpr::child_begin() {
return &SubExprs[0];
}
Stmt::child_iterator ShuffleVectorExpr::child_end() {
return &SubExprs[0]+NumExprs;
}
// VAArgExpr
Stmt::child_iterator VAArgExpr::child_begin() { return &Val; }
Stmt::child_iterator VAArgExpr::child_end() { return &Val+1; }
// InitListExpr
Stmt::child_iterator InitListExpr::child_begin() {
return InitExprs.size() ? &InitExprs[0] : 0;
}
Stmt::child_iterator InitListExpr::child_end() {
return InitExprs.size() ? &InitExprs[0] + InitExprs.size() : 0;
}
// DesignatedInitExpr
Stmt::child_iterator DesignatedInitExpr::child_begin() {
char* Ptr = static_cast<char*>(static_cast<void *>(this));
Ptr += sizeof(DesignatedInitExpr);
return reinterpret_cast<Stmt**>(reinterpret_cast<void**>(Ptr));
}
Stmt::child_iterator DesignatedInitExpr::child_end() {
return child_iterator(&*child_begin() + NumSubExprs);
}
// ImplicitValueInitExpr
Stmt::child_iterator ImplicitValueInitExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator ImplicitValueInitExpr::child_end() {
return child_iterator();
}
// ParenListExpr
Stmt::child_iterator ParenListExpr::child_begin() {
return &Exprs[0];
}
Stmt::child_iterator ParenListExpr::child_end() {
return &Exprs[0]+NumExprs;
}
// ObjCStringLiteral
Stmt::child_iterator ObjCStringLiteral::child_begin() {
return &String;
}
Stmt::child_iterator ObjCStringLiteral::child_end() {
return &String+1;
}
// ObjCEncodeExpr
Stmt::child_iterator ObjCEncodeExpr::child_begin() { return child_iterator(); }
Stmt::child_iterator ObjCEncodeExpr::child_end() { return child_iterator(); }
// ObjCSelectorExpr
Stmt::child_iterator ObjCSelectorExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator ObjCSelectorExpr::child_end() {
return child_iterator();
}
// ObjCProtocolExpr
Stmt::child_iterator ObjCProtocolExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator ObjCProtocolExpr::child_end() {
return child_iterator();
return child_range(&Argument.Ex, &Argument.Ex + 1);
}
// ObjCMessageExpr
Stmt::child_iterator ObjCMessageExpr::child_begin() {
Stmt::child_range ObjCMessageExpr::children() {
Stmt **begin;
if (getReceiverKind() == Instance)
return reinterpret_cast<Stmt **>(this + 1);
return reinterpret_cast<Stmt **>(getArgs());
}
Stmt::child_iterator ObjCMessageExpr::child_end() {
return reinterpret_cast<Stmt **>(getArgs() + getNumArgs());
begin = reinterpret_cast<Stmt **>(this + 1);
else
begin = reinterpret_cast<Stmt **>(getArgs());
return child_range(begin,
reinterpret_cast<Stmt **>(getArgs() + getNumArgs()));
}
// Blocks
@ -2988,14 +2810,3 @@ BlockDeclRefExpr::BlockDeclRefExpr(VarDecl *d, QualType t, ExprValueKind VK,
ExprBits.ValueDependent = ValueDependent;
}
Stmt::child_iterator BlockExpr::child_begin() { return child_iterator(); }
Stmt::child_iterator BlockExpr::child_end() { return child_iterator(); }
Stmt::child_iterator BlockDeclRefExpr::child_begin() { return child_iterator();}
Stmt::child_iterator BlockDeclRefExpr::child_end() { return child_iterator(); }
// OpaqueValueExpr
SourceRange OpaqueValueExpr::getSourceRange() const { return Loc; }
Stmt::child_iterator OpaqueValueExpr::child_begin() { return child_iterator(); }
Stmt::child_iterator OpaqueValueExpr::child_end() { return child_iterator(); }

View File

@ -29,67 +29,12 @@ QualType CXXTypeidExpr::getTypeOperand() const {
.getUnqualifiedType();
}
// CXXTypeidExpr - has child iterators if the operand is an expression
Stmt::child_iterator CXXTypeidExpr::child_begin() {
return isTypeOperand() ? child_iterator()
: reinterpret_cast<Stmt **>(&Operand);
}
Stmt::child_iterator CXXTypeidExpr::child_end() {
return isTypeOperand() ? child_iterator()
: reinterpret_cast<Stmt **>(&Operand) + 1;
}
QualType CXXUuidofExpr::getTypeOperand() const {
assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
return Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType()
.getUnqualifiedType();
}
// CXXUuidofExpr - has child iterators if the operand is an expression
Stmt::child_iterator CXXUuidofExpr::child_begin() {
return isTypeOperand() ? child_iterator()
: reinterpret_cast<Stmt **>(&Operand);
}
Stmt::child_iterator CXXUuidofExpr::child_end() {
return isTypeOperand() ? child_iterator()
: reinterpret_cast<Stmt **>(&Operand) + 1;
}
// CXXBoolLiteralExpr
Stmt::child_iterator CXXBoolLiteralExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator CXXBoolLiteralExpr::child_end() {
return child_iterator();
}
// CXXNullPtrLiteralExpr
Stmt::child_iterator CXXNullPtrLiteralExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator CXXNullPtrLiteralExpr::child_end() {
return child_iterator();
}
// CXXThisExpr
Stmt::child_iterator CXXThisExpr::child_begin() { return child_iterator(); }
Stmt::child_iterator CXXThisExpr::child_end() { return child_iterator(); }
// CXXThrowExpr
Stmt::child_iterator CXXThrowExpr::child_begin() { return &Op; }
Stmt::child_iterator CXXThrowExpr::child_end() {
// If Op is 0, we are processing throw; which has no children.
return Op ? &Op+1 : &Op;
}
// CXXDefaultArgExpr
Stmt::child_iterator CXXDefaultArgExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator CXXDefaultArgExpr::child_end() {
return child_iterator();
}
// CXXScalarValueInitExpr
SourceRange CXXScalarValueInitExpr::getSourceRange() const {
SourceLocation Start = RParenLoc;
@ -98,13 +43,6 @@ SourceRange CXXScalarValueInitExpr::getSourceRange() const {
return SourceRange(Start, RParenLoc);
}
Stmt::child_iterator CXXScalarValueInitExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator CXXScalarValueInitExpr::child_end() {
return child_iterator();
}
// CXXNewExpr
CXXNewExpr::CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
Expr **placementArgs, unsigned numPlaceArgs,
@ -163,11 +101,6 @@ void CXXNewExpr::AllocateArgsArray(ASTContext &C, bool isArray,
}
Stmt::child_iterator CXXNewExpr::child_begin() { return &SubExprs[0]; }
Stmt::child_iterator CXXNewExpr::child_end() {
return &SubExprs[0] + Array + getNumPlacementArgs() + getNumConstructorArgs();
}
// CXXDeleteExpr
QualType CXXDeleteExpr::getDestroyedType() const {
const Expr *Arg = getArgument();
@ -187,15 +120,7 @@ QualType CXXDeleteExpr::getDestroyedType() const {
return ArgType->getAs<PointerType>()->getPointeeType();
}
Stmt::child_iterator CXXDeleteExpr::child_begin() { return &Argument; }
Stmt::child_iterator CXXDeleteExpr::child_end() { return &Argument+1; }
// CXXPseudoDestructorExpr
Stmt::child_iterator CXXPseudoDestructorExpr::child_begin() { return &Base; }
Stmt::child_iterator CXXPseudoDestructorExpr::child_end() {
return &Base + 1;
}
PseudoDestructorTypeStorage::PseudoDestructorTypeStorage(TypeSourceInfo *Info)
: Type(Info)
{
@ -355,28 +280,6 @@ CXXRecordDecl *OverloadExpr::getNamingClass() const {
return cast<UnresolvedMemberExpr>(this)->getNamingClass();
}
Stmt::child_iterator UnresolvedLookupExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator UnresolvedLookupExpr::child_end() {
return child_iterator();
}
// UnaryTypeTraitExpr
Stmt::child_iterator UnaryTypeTraitExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator UnaryTypeTraitExpr::child_end() {
return child_iterator();
}
//BinaryTypeTraitExpr
Stmt::child_iterator BinaryTypeTraitExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator BinaryTypeTraitExpr::child_end() {
return child_iterator();
}
// DependentScopeDeclRefExpr
DependentScopeDeclRefExpr::DependentScopeDeclRefExpr(QualType T,
NestedNameSpecifier *Qualifier,
@ -431,14 +334,6 @@ DependentScopeDeclRefExpr::CreateEmpty(ASTContext &C,
return E;
}
StmtIterator DependentScopeDeclRefExpr::child_begin() {
return child_iterator();
}
StmtIterator DependentScopeDeclRefExpr::child_end() {
return child_iterator();
}
SourceRange CXXConstructExpr::getSourceRange() const {
if (ParenRange.isValid())
return SourceRange(Loc, ParenRange.getEnd());
@ -746,32 +641,6 @@ ExprWithCleanups *ExprWithCleanups::Create(ASTContext &C,
return new (C) ExprWithCleanups(C, SubExpr, Temps, NumTemps);
}
// CXXBindTemporaryExpr
Stmt::child_iterator CXXBindTemporaryExpr::child_begin() {
return &SubExpr;
}
Stmt::child_iterator CXXBindTemporaryExpr::child_end() {
return &SubExpr + 1;
}
// CXXConstructExpr
Stmt::child_iterator CXXConstructExpr::child_begin() {
return &Args[0];
}
Stmt::child_iterator CXXConstructExpr::child_end() {
return &Args[0]+NumArgs;
}
// ExprWithCleanups
Stmt::child_iterator ExprWithCleanups::child_begin() {
return &SubExpr;
}
Stmt::child_iterator ExprWithCleanups::child_end() {
return &SubExpr + 1;
}
CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(TypeSourceInfo *Type,
SourceLocation LParenLoc,
Expr **Args,
@ -820,14 +689,6 @@ SourceRange CXXUnresolvedConstructExpr::getSourceRange() const {
return SourceRange(Type->getTypeLoc().getBeginLoc(), RParenLoc);
}
Stmt::child_iterator CXXUnresolvedConstructExpr::child_begin() {
return child_iterator(reinterpret_cast<Stmt **>(this + 1));
}
Stmt::child_iterator CXXUnresolvedConstructExpr::child_end() {
return child_iterator(reinterpret_cast<Stmt **>(this + 1) + NumArgs);
}
CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr(ASTContext &C,
Expr *Base, QualType BaseType,
bool IsArrow,
@ -927,16 +788,6 @@ CXXDependentScopeMemberExpr::CreateEmpty(ASTContext &C,
return E;
}
Stmt::child_iterator CXXDependentScopeMemberExpr::child_begin() {
return child_iterator(&Base);
}
Stmt::child_iterator CXXDependentScopeMemberExpr::child_end() {
if (isImplicitAccess())
return child_iterator(&Base);
return child_iterator(&Base + 1);
}
UnresolvedMemberExpr::UnresolvedMemberExpr(ASTContext &C,
bool HasUnresolvedUsing,
Expr *Base, QualType BaseType,
@ -1025,47 +876,6 @@ CXXRecordDecl *UnresolvedMemberExpr::getNamingClass() const {
return Record;
}
Stmt::child_iterator UnresolvedMemberExpr::child_begin() {
return child_iterator(&Base);
}
Stmt::child_iterator UnresolvedMemberExpr::child_end() {
if (isImplicitAccess())
return child_iterator(&Base);
return child_iterator(&Base + 1);
}
Stmt::child_iterator CXXNoexceptExpr::child_begin() {
return child_iterator(&Operand);
}
Stmt::child_iterator CXXNoexceptExpr::child_end() {
return child_iterator(&Operand + 1);
}
SourceRange PackExpansionExpr::getSourceRange() const {
return SourceRange(Pattern->getLocStart(), EllipsisLoc);
}
Stmt::child_iterator PackExpansionExpr::child_begin() {
return child_iterator(&Pattern);
}
Stmt::child_iterator PackExpansionExpr::child_end() {
return child_iterator(&Pattern + 1);
}
SourceRange SizeOfPackExpr::getSourceRange() const {
return SourceRange(OperatorLoc, RParenLoc);
}
Stmt::child_iterator SizeOfPackExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator SizeOfPackExpr::child_end() {
return child_iterator();
}
SubstNonTypeTemplateParmPackExpr::
SubstNonTypeTemplateParmPackExpr(QualType T,
NonTypeTemplateParmDecl *Param,
@ -1080,16 +890,4 @@ TemplateArgument SubstNonTypeTemplateParmPackExpr::getArgumentPack() const {
return TemplateArgument(Arguments, NumArguments);
}
SourceRange SubstNonTypeTemplateParmPackExpr::getSourceRange() const {
return NameLoc;
}
Stmt::child_iterator SubstNonTypeTemplateParmPackExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator SubstNonTypeTemplateParmPackExpr::child_end() {
return child_iterator();
}

View File

@ -90,6 +90,7 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
switch (E->getStmtClass()) {
// First come the expressions that are always lvalues, unconditionally.
case Stmt::NoStmtClass:
#define ABSTRACT_STMT(Kind)
#define STMT(Kind, Base) case Expr::Kind##Class:
#define EXPR(Kind, Base)
#include "clang/AST/StmtNodes.inc"

View File

@ -2578,6 +2578,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) {
}
switch (E->getStmtClass()) {
#define ABSTRACT_STMT(Node)
#define STMT(Node, Base) case Expr::Node##Class:
#define EXPR(Node, Base)
#include "clang/AST/StmtNodes.inc"

View File

@ -1690,6 +1690,7 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) {
// ::= L <mangled-name> E # external name
switch (E->getStmtClass()) {
case Expr::NoStmtClass:
#define ABSTRACT_STMT(Type)
#define EXPR(Type, Base)
#define STMT(Type, Base) \
case Expr::Type##Class:

View File

@ -84,6 +84,61 @@ bool Stmt::CollectingStats(bool Enable) {
return StatSwitch;
}
namespace {
struct good {};
struct bad {};
static inline good is_good(good); // static inline to suppress unused warning
typedef Stmt::child_range children_t();
template <class T> good implements_children(children_t T::*);
static inline bad implements_children(children_t Stmt::*);
typedef SourceRange getSourceRange_t() const;
template <class T> good implements_getSourceRange(getSourceRange_t T::*);
static inline bad implements_getSourceRange(getSourceRange_t Stmt::*);
#define ASSERT_IMPLEMENTS_children(type) \
(void) sizeof(is_good(implements_children(&type::children)))
#define ASSERT_IMPLEMENTS_getSourceRange(type) \
(void) sizeof(is_good(implements_getSourceRange(&type::getSourceRange)))
}
/// Check whether the various Stmt classes implement their member
/// functions.
static inline void check_implementations() {
#define ABSTRACT_STMT(type)
#define STMT(type, base) \
ASSERT_IMPLEMENTS_children(type); \
ASSERT_IMPLEMENTS_getSourceRange(type);
#include "clang/AST/StmtNodes.inc"
}
Stmt::child_range Stmt::children() {
switch (getStmtClass()) {
case Stmt::NoStmtClass: llvm_unreachable("statement without class");
#define ABSTRACT_STMT(type)
#define STMT(type, base) \
case Stmt::type##Class: \
return static_cast<type*>(this)->children();
#include "clang/AST/StmtNodes.inc"
}
llvm_unreachable("unknown statement kind!");
return child_range();
}
SourceRange Stmt::getSourceRange() const {
switch (getStmtClass()) {
case Stmt::NoStmtClass: llvm_unreachable("statement without class");
#define ABSTRACT_STMT(type)
#define STMT(type, base) \
case Stmt::type##Class: \
return static_cast<const type*>(this)->getSourceRange();
#include "clang/AST/StmtNodes.inc"
}
llvm_unreachable("unknown statement kind!");
return SourceRange();
}
void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) {
if (this->Body)
C.Deallocate(Body);
@ -556,6 +611,11 @@ void SwitchStmt::setConditionVariable(ASTContext &C, VarDecl *V) {
V->getSourceRange().getEnd());
}
Stmt *SwitchCase::getSubStmt() {
if (isa<CaseStmt>(this)) return cast<CaseStmt>(this)->getSubStmt();
return cast<DefaultStmt>(this)->getSubStmt();
}
WhileStmt::WhileStmt(ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,
SourceLocation WL)
: Stmt(WhileStmtClass)
@ -585,89 +645,6 @@ void WhileStmt::setConditionVariable(ASTContext &C, VarDecl *V) {
V->getSourceRange().getEnd());
}
//===----------------------------------------------------------------------===//
// Child Iterators for iterating over subexpressions/substatements
//===----------------------------------------------------------------------===//
// DeclStmt
Stmt::child_iterator DeclStmt::child_begin() {
return StmtIterator(DG.begin(), DG.end());
}
Stmt::child_iterator DeclStmt::child_end() {
return StmtIterator(DG.end(), DG.end());
}
// NullStmt
Stmt::child_iterator NullStmt::child_begin() { return child_iterator(); }
Stmt::child_iterator NullStmt::child_end() { return child_iterator(); }
// CompoundStmt
Stmt::child_iterator CompoundStmt::child_begin() { return &Body[0]; }
Stmt::child_iterator CompoundStmt::child_end() {
return &Body[0]+CompoundStmtBits.NumStmts;
}
// CaseStmt
Stmt::child_iterator CaseStmt::child_begin() { return &SubExprs[0]; }
Stmt::child_iterator CaseStmt::child_end() { return &SubExprs[END_EXPR]; }
// DefaultStmt
Stmt::child_iterator DefaultStmt::child_begin() { return &SubStmt; }
Stmt::child_iterator DefaultStmt::child_end() { return &SubStmt+1; }
// LabelStmt
Stmt::child_iterator LabelStmt::child_begin() { return &SubStmt; }
Stmt::child_iterator LabelStmt::child_end() { return &SubStmt+1; }
// IfStmt
Stmt::child_iterator IfStmt::child_begin() {
return &SubExprs[0];
}
Stmt::child_iterator IfStmt::child_end() {
return &SubExprs[0]+END_EXPR;
}
// SwitchStmt
Stmt::child_iterator SwitchStmt::child_begin() {
return &SubExprs[0];
}
Stmt::child_iterator SwitchStmt::child_end() {
return &SubExprs[0]+END_EXPR;
}
// WhileStmt
Stmt::child_iterator WhileStmt::child_begin() {
return &SubExprs[0];
}
Stmt::child_iterator WhileStmt::child_end() {
return &SubExprs[0]+END_EXPR;
}
// DoStmt
Stmt::child_iterator DoStmt::child_begin() { return &SubExprs[0]; }
Stmt::child_iterator DoStmt::child_end() { return &SubExprs[0]+END_EXPR; }
// ForStmt
Stmt::child_iterator ForStmt::child_begin() {
return &SubExprs[0];
}
Stmt::child_iterator ForStmt::child_end() {
return &SubExprs[0]+END_EXPR;
}
// ObjCForCollectionStmt
Stmt::child_iterator ObjCForCollectionStmt::child_begin() {
return &SubExprs[0];
}
Stmt::child_iterator ObjCForCollectionStmt::child_end() {
return &SubExprs[0]+END_EXPR;
}
// GotoStmt
Stmt::child_iterator GotoStmt::child_begin() { return child_iterator(); }
Stmt::child_iterator GotoStmt::child_end() { return child_iterator(); }
// IndirectGotoStmt
LabelStmt *IndirectGotoStmt::getConstantTarget() {
if (AddrLabelExpr *E =
@ -676,17 +653,6 @@ LabelStmt *IndirectGotoStmt::getConstantTarget() {
return 0;
}
Stmt::child_iterator IndirectGotoStmt::child_begin() { return &Target; }
Stmt::child_iterator IndirectGotoStmt::child_end() { return &Target+1; }
// ContinueStmt
Stmt::child_iterator ContinueStmt::child_begin() { return child_iterator(); }
Stmt::child_iterator ContinueStmt::child_end() { return child_iterator(); }
// BreakStmt
Stmt::child_iterator BreakStmt::child_begin() { return child_iterator(); }
Stmt::child_iterator BreakStmt::child_end() { return child_iterator(); }
// ReturnStmt
const Expr* ReturnStmt::getRetValue() const {
return cast_or_null<Expr>(RetExpr);
@ -694,69 +660,3 @@ const Expr* ReturnStmt::getRetValue() const {
Expr* ReturnStmt::getRetValue() {
return cast_or_null<Expr>(RetExpr);
}
Stmt::child_iterator ReturnStmt::child_begin() {
return &RetExpr;
}
Stmt::child_iterator ReturnStmt::child_end() {
return RetExpr ? &RetExpr+1 : &RetExpr;
}
// AsmStmt
Stmt::child_iterator AsmStmt::child_begin() {
return NumOutputs + NumInputs == 0 ? 0 : &Exprs[0];
}
Stmt::child_iterator AsmStmt::child_end() {
return NumOutputs + NumInputs == 0 ? 0 : &Exprs[0] + NumOutputs + NumInputs;
}
// ObjCAtCatchStmt
Stmt::child_iterator ObjCAtCatchStmt::child_begin() { return &Body; }
Stmt::child_iterator ObjCAtCatchStmt::child_end() { return &Body + 1; }
// ObjCAtFinallyStmt
Stmt::child_iterator ObjCAtFinallyStmt::child_begin() { return &AtFinallyStmt; }
Stmt::child_iterator ObjCAtFinallyStmt::child_end() { return &AtFinallyStmt+1; }
// ObjCAtTryStmt
Stmt::child_iterator ObjCAtTryStmt::child_begin() { return getStmts(); }
Stmt::child_iterator ObjCAtTryStmt::child_end() {
return getStmts() + 1 + NumCatchStmts + HasFinally;
}
// ObjCAtThrowStmt
Stmt::child_iterator ObjCAtThrowStmt::child_begin() {
return &Throw;
}
Stmt::child_iterator ObjCAtThrowStmt::child_end() {
return &Throw+1;
}
// ObjCAtSynchronizedStmt
Stmt::child_iterator ObjCAtSynchronizedStmt::child_begin() {
return &SubStmts[0];
}
Stmt::child_iterator ObjCAtSynchronizedStmt::child_end() {
return &SubStmts[0]+END_EXPR;
}
// CXXCatchStmt
Stmt::child_iterator CXXCatchStmt::child_begin() {
return &HandlerBlock;
}
Stmt::child_iterator CXXCatchStmt::child_end() {
return &HandlerBlock + 1;
}
// CXXTryStmt
Stmt::child_iterator CXXTryStmt::child_begin() {
return reinterpret_cast<Stmt **>(this + 1);
}
Stmt::child_iterator CXXTryStmt::child_end() {
return reinterpret_cast<Stmt **>(this + 1) + NumHandlers + 1;
}

View File

@ -220,10 +220,6 @@ void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
}
}
void StmtPrinter::VisitSwitchCase(SwitchCase*) {
assert(0 && "SwitchCase is an abstract class");
}
void StmtPrinter::VisitWhileStmt(WhileStmt *Node) {
Indent() << "while (";
PrintExpr(Node->getCond());

View File

@ -71,7 +71,6 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
switch (S->getStmtClass()) {
case Stmt::NoStmtClass:
case Stmt::CXXCatchStmtClass:
case Stmt::SwitchCaseClass:
llvm_unreachable("invalid statement class to emit generically");
case Stmt::NullStmtClass:
case Stmt::CompoundStmtClass:

View File

@ -2280,6 +2280,7 @@ StmtResult TreeTransform<Derived>::TransformStmt(Stmt *S) {
// Transform individual statement nodes
#define STMT(Node, Parent) \
case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
#define ABSTRACT_STMT(Node)
#define EXPR(Node, Parent)
#include "clang/AST/StmtNodes.inc"
@ -4829,13 +4830,6 @@ TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
S->getStartLoc(), S->getEndLoc());
}
template<typename Derived>
StmtResult
TreeTransform<Derived>::TransformSwitchCase(SwitchCase *S) {
assert(false && "SwitchCase is abstract and cannot be transformed");
return SemaRef.Owned(S);
}
template<typename Derived>
StmtResult
TreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) {

View File

@ -860,7 +860,6 @@ void ExprEngine::Visit(const Stmt* S, ExplodedNode* Pred,
case Stmt::LabelStmtClass:
case Stmt::NoStmtClass:
case Stmt::NullStmtClass:
case Stmt::SwitchCaseClass:
case Stmt::OpaqueValueExprClass:
llvm_unreachable("Stmt should not be in analyzer evaluation loop");
break;

View File

@ -86,7 +86,6 @@ CXCursor cxcursor::MakeCXCursor(Stmt *S, Decl *Parent,
case Stmt::BreakStmtClass:
case Stmt::ReturnStmtClass:
case Stmt::DeclStmtClass:
case Stmt::SwitchCaseClass:
case Stmt::AsmStmtClass:
case Stmt::ObjCAtTryStmtClass:
case Stmt::ObjCAtCatchStmtClass: