aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/Expr.h228
-rw-r--r--include/clang/AST/Makefile13
-rw-r--r--include/clang/AST/Stmt.h61
-rw-r--r--include/clang/AST/StmtNodes.def165
-rw-r--r--include/clang/AST/StmtNodes.td127
-rw-r--r--include/clang/AST/StmtVisitor.h6
-rw-r--r--include/clang/CMakeLists.txt1
-rw-r--r--include/clang/Makefile2
-rw-r--r--lib/AST/Expr.cpp160
-rw-r--r--lib/AST/Stmt.cpp58
-rw-r--r--lib/AST/StmtPrinter.cpp8
-rw-r--r--lib/AST/StmtProfile.cpp8
-rw-r--r--lib/CodeGen/Mangle.cpp48
-rw-r--r--lib/Sema/TreeTransform.h426
14 files changed, 668 insertions, 643 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index d24d335b25..2946e464a7 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -203,13 +203,13 @@ public:
/// \brief Returns whether this expression refers to a vector element.
bool refersToVectorElement() const;
-
+
/// 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
/// C.
bool isKnownToHaveBooleanValue() const;
-
+
/// isIntegerConstantExpr - Return true if this expression is a valid integer
/// constant expression, and, if so, return its value in Result. If not a
/// valid i-c-e, return false and fill in Loc (if specified) with the location
@@ -223,7 +223,7 @@ public:
}
/// isConstantInitializer - Returns true if this expression is a constant
/// initializer, which can be emitted at compile-time.
- bool isConstantInitializer(ASTContext &Ctx) const;
+ bool isConstantInitializer(ASTContext &Ctx) const;
/// EvalResult is a struct with detailed info about an evaluated expression.
struct EvalResult {
@@ -269,11 +269,11 @@ public:
bool isEvaluatable(ASTContext &Ctx) const;
/// HasSideEffects - This routine returns true for all those expressions
- /// which must be evaluated each time and must not be optimization away
+ /// which must be evaluated each time and must not be optimization away
/// or evaluated at compile time. Example is a function call, volatile
/// variable read.
bool HasSideEffects(ASTContext &Ctx) const;
-
+
/// EvaluateAsInt - Call Evaluate and return the folded integer. This
/// must be called on an expression that constant folds to an integer.
llvm::APSInt EvaluateAsInt(ASTContext &Ctx) const;
@@ -291,16 +291,16 @@ public:
enum NullPointerConstantValueDependence {
/// \brief Specifies that the expression should never be value-dependent.
NPC_NeverValueDependent = 0,
-
+
/// \brief Specifies that a value-dependent expression of integral or
/// dependent type should be considered a null pointer constant.
NPC_ValueDependentIsNull,
-
+
/// \brief Specifies that a value-dependent expression should be considered
/// to never be a null pointer constant.
NPC_ValueDependentIsNotNull
};
-
+
/// isNullPointerConstant - C99 6.3.2.3p3 - Return true if this is either an
/// integer constant expression with the value zero, or if this is one that is
/// cast to void*.
@@ -329,12 +329,12 @@ public:
/// \brief Determine whether this expression is a default function argument.
///
/// Default arguments are implicitly generated in the abstract syntax tree
- /// by semantic analysis for function calls, object constructions, etc. in
+ /// by semantic analysis for function calls, object constructions, etc. in
/// C++. Default arguments are represented by \c CXXDefaultArgExpr nodes;
/// this routine also looks through any implicit casts to determine whether
/// the expression is a default argument.
bool isDefaultArgument() const;
-
+
/// \brief Determine whether this expression directly creates a
/// temporary object (of class type).
bool isTemporaryObject() const { return getTemporaryObject() != 0; }
@@ -374,7 +374,7 @@ public:
struct NameQualifier {
/// \brief The nested name specifier.
NestedNameSpecifier *NNS;
-
+
/// \brief The source range covered by the nested name specifier.
SourceRange Range;
};
@@ -384,20 +384,20 @@ struct NameQualifier {
struct ExplicitTemplateArgumentList {
/// \brief The source location of the left angle bracket ('<');
SourceLocation LAngleLoc;
-
+
/// \brief The source location of the right angle bracket ('>');
SourceLocation RAngleLoc;
-
+
/// \brief The number of template arguments in TemplateArgs.
/// The actual template arguments (if any) are stored after the
/// ExplicitTemplateArgumentList structure.
unsigned NumTemplateArgs;
-
+
/// \brief Retrieve the template arguments
TemplateArgumentLoc *getTemplateArgs() {
return reinterpret_cast<TemplateArgumentLoc *> (this + 1);
}
-
+
/// \brief Retrieve the template arguments
const TemplateArgumentLoc *getTemplateArgs() const {
return reinterpret_cast<const TemplateArgumentLoc *> (this + 1);
@@ -407,25 +407,25 @@ struct ExplicitTemplateArgumentList {
void copyInto(TemplateArgumentListInfo &List) const;
static std::size_t sizeFor(const TemplateArgumentListInfo &List);
};
-
+
/// DeclRefExpr - [C99 6.5.1p2] - A reference to a declared variable, function,
/// enum, etc.
class DeclRefExpr : public Expr {
enum {
- // Flag on DecoratedD that specifies when this declaration reference
+ // Flag on DecoratedD that specifies when this declaration reference
// expression has a C++ nested-name-specifier.
HasQualifierFlag = 0x01,
- // Flag on DecoratedD that specifies when this declaration reference
+ // Flag on DecoratedD that specifies when this declaration reference
// expression has an explicit C++ template argument list.
HasExplicitTemplateArgumentListFlag = 0x02
};
-
- // DecoratedD - The declaration that we are referencing, plus two bits to
+
+ // DecoratedD - The declaration that we are referencing, plus two bits to
// indicate whether (1) the declaration's name was explicitly qualified and
- // (2) the declaration's name was followed by an explicit template
+ // (2) the declaration's name was followed by an explicit template
// argument list.
llvm::PointerIntPair<ValueDecl *, 2> DecoratedD;
-
+
// Loc - The location of the declaration name itself.
SourceLocation Loc;
@@ -433,39 +433,39 @@ class DeclRefExpr : public Expr {
NameQualifier *getNameQualifier() {
if ((DecoratedD.getInt() & HasQualifierFlag) == 0)
return 0;
-
+
return reinterpret_cast<NameQualifier *> (this + 1);
}
-
+
/// \brief Retrieve the qualifier that preceded the member name, if any.
const NameQualifier *getNameQualifier() const {
return const_cast<DeclRefExpr *>(this)->getNameQualifier();
}
-
+
/// \brief Retrieve the explicit template argument list that followed the
/// member template name, if any.
ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() {
if ((DecoratedD.getInt() & HasExplicitTemplateArgumentListFlag) == 0)
return 0;
-
+
if ((DecoratedD.getInt() & HasQualifierFlag) == 0)
return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
-
+
return reinterpret_cast<ExplicitTemplateArgumentList *>(
getNameQualifier() + 1);
}
-
+
/// \brief Retrieve the explicit template argument list that followed the
/// member template name, if any.
const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const {
return const_cast<DeclRefExpr *>(this)->getExplicitTemplateArgumentList();
}
-
+
DeclRefExpr(NestedNameSpecifier *Qualifier, SourceRange QualifierRange,
ValueDecl *D, SourceLocation NameLoc,
const TemplateArgumentListInfo *TemplateArgs,
QualType T);
-
+
protected:
/// \brief Computes the type- and value-dependence flags for this
/// declaration reference expression.
@@ -493,7 +493,7 @@ public:
SourceLocation NameLoc,
QualType T,
const TemplateArgumentListInfo *TemplateArgs = 0);
-
+
ValueDecl *getDecl() { return DecoratedD.getPointer(); }
const ValueDecl *getDecl() const { return DecoratedD.getPointer(); }
void setDecl(ValueDecl *NewD) { DecoratedD.setPointer(NewD); }
@@ -505,26 +505,26 @@ public:
/// \brief Determine whether this declaration reference was preceded by a
/// C++ nested-name-specifier, e.g., \c N::foo.
bool hasQualifier() const { return DecoratedD.getInt() & HasQualifierFlag; }
-
+
/// \brief If the name was qualified, retrieves the source range of
/// the nested-name-specifier that precedes the name. Otherwise,
/// returns an empty source range.
SourceRange getQualifierRange() const {
if (!hasQualifier())
return SourceRange();
-
+
return getNameQualifier()->Range;
}
-
- /// \brief If the name was qualified, retrieves the nested-name-specifier
+
+ /// \brief If the name was qualified, retrieves the nested-name-specifier
/// that precedes the name. Otherwise, returns NULL.
NestedNameSpecifier *getQualifier() const {
if (!hasQualifier())
return 0;
-
+
return getNameQualifier()->NNS;
}
-
+
/// \brief Determines whether this member expression actually had a C++
/// template argument list explicitly specified, e.g., x.f<int>.
bool hasExplicitTemplateArgumentList() const {
@@ -537,43 +537,43 @@ public:
if (hasExplicitTemplateArgumentList())
getExplicitTemplateArgumentList()->copyInto(List);
}
-
+
/// \brief Retrieve the location of the left angle bracket following the
/// member name ('<'), if any.
SourceLocation getLAngleLoc() const {
if (!hasExplicitTemplateArgumentList())
return SourceLocation();
-
+
return getExplicitTemplateArgumentList()->LAngleLoc;
}
-
+
/// \brief Retrieve the template arguments provided as part of this
/// template-id.
const TemplateArgumentLoc *getTemplateArgs() const {
if (!hasExplicitTemplateArgumentList())
return 0;
-
+
return getExplicitTemplateArgumentList()->getTemplateArgs();
}
-
+
/// \brief Retrieve the number of template arguments provided as part of this
/// template-id.
unsigned getNumTemplateArgs() const {
if (!hasExplicitTemplateArgumentList())
return 0;
-
+
return getExplicitTemplateArgumentList()->NumTemplateArgs;
}
-
+
/// \brief Retrieve the location of the right angle bracket following the
/// template arguments ('>').
SourceLocation getRAngleLoc() const {
if (!hasExplicitTemplateArgumentList())
return SourceLocation();
-
+
return getExplicitTemplateArgumentList()->RAngleLoc;
}
-
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == DeclRefExprClass;
}
@@ -601,7 +601,7 @@ private:
IdentType Type;
public:
PredefinedExpr(SourceLocation l, QualType type, IdentType IT)
- : Expr(PredefinedExprClass, type, type->isDependentType(),
+ : Expr(PredefinedExprClass, type, type->isDependentType(),
type->isDependentType()), Loc(l), Type(IT) {}
/// \brief Construct an empty predefined expression.
@@ -1008,14 +1008,14 @@ public:
/// @code
/// struct S {
/// float f;
-/// double d;
+/// double d;
/// };
/// struct T {
/// int i;
/// struct S s[10];
/// };
/// @endcode
-/// we can represent and evaluate the expression @c offsetof(struct T, s[2].d).
+/// we can represent and evaluate the expression @c offsetof(struct T, s[2].d).
class OffsetOfExpr : public Expr {
public:
@@ -1037,48 +1037,48 @@ public:
private:
enum { MaskBits = 2, Mask = 0x03 };
-
+
/// \brief The source range that covers this part of the designator.
SourceRange Range;
-
+
/// \brief The data describing the designator, which comes in three
/// different forms, depending on the lower two bits.
- /// - An unsigned index into the array of Expr*'s stored after this node
+ /// - An unsigned index into the array of Expr*'s stored after this node
/// in memory, for [constant-expression] designators.
/// - A FieldDecl*, for references to a known field.
/// - An IdentifierInfo*, for references to a field with a given name
/// when the class type is dependent.
- /// - A CXXBaseSpecifier*, for references that look at a field in a
+ /// - A CXXBaseSpecifier*, for references that look at a field in a
/// base class.
uintptr_t Data;
-
+
public:
/// \brief Create an offsetof node that refers to an array element.
- OffsetOfNode(SourceLocation LBracketLoc, unsigned Index,
+ OffsetOfNode(SourceLocation LBracketLoc, unsigned Index,
SourceLocation RBracketLoc)
: Range(LBracketLoc, RBracketLoc), Data((Index << 2) | Array) { }
-
+
/// \brief Create an offsetof node that refers to a field.
- OffsetOfNode(SourceLocation DotLoc, FieldDecl *Field,
+ OffsetOfNode(SourceLocation DotLoc, FieldDecl *Field,
SourceLocation NameLoc)
- : Range(DotLoc.isValid()? DotLoc : NameLoc, NameLoc),
+ : Range(DotLoc.isValid()? DotLoc : NameLoc, NameLoc),
Data(reinterpret_cast<uintptr_t>(Field) | OffsetOfNode::Field) { }
-
+
/// \brief Create an offsetof node that refers to an identifier.
OffsetOfNode(SourceLocation DotLoc, IdentifierInfo *Name,
SourceLocation NameLoc)
- : Range(DotLoc.isValid()? DotLoc : NameLoc, NameLoc),
+ : Range(DotLoc.isValid()? DotLoc : NameLoc, NameLoc),
Data(reinterpret_cast<uintptr_t>(Name) | Identifier) { }
/// \brief Create an offsetof node that refers into a C++ base class.
explicit OffsetOfNode(const CXXBaseSpecifier *Base)
: Range(), Data(reinterpret_cast<uintptr_t>(Base) | OffsetOfNode::Base) {}
-
+
/// \brief Determine what kind of offsetof node this is.
- Kind getKind() const {
+ Kind getKind() const {
return static_cast<Kind>(Data & Mask);
}
-
+
/// \brief For an array element node, returns the index into the array
/// of expressions.
unsigned getArrayExprIndex() const {
@@ -1091,28 +1091,28 @@ public:
assert(getKind() == Field);
return reinterpret_cast<FieldDecl *>(Data & ~(uintptr_t)Mask);
}
-
+
/// \brief For a field or identifier offsetof node, returns the name of
/// the field.
IdentifierInfo *getFieldName() const;
-
+
/// \brief For a base class node, returns the base specifier.
CXXBaseSpecifier *getBase() const {
assert(getKind() == Base);
- return reinterpret_cast<CXXBaseSpecifier *>(Data & ~(uintptr_t)Mask);
+ return reinterpret_cast<CXXBaseSpecifier *>(Data & ~(uintptr_t)Mask);
}
-
+
/// \brief Retrieve the source range that covers this offsetof node.
///
/// For an array element node, the source range contains the locations of
/// the square brackets. For a field or identifier node, the source range
- /// contains the location of the period (if there is one) and the
+ /// contains the location of the period (if there is one) and the
/// identifier.
SourceRange getRange() const { return Range; }
};
private:
-
+
SourceLocation OperatorLoc, RParenLoc;
// Base type;
TypeSourceInfo *TSInfo;
@@ -1120,26 +1120,26 @@ private:
unsigned NumComps;
// Number of sub-expressions (i.e. array subscript expressions).
unsigned NumExprs;
-
- OffsetOfExpr(ASTContext &C, QualType type,
+
+ OffsetOfExpr(ASTContext &C, QualType type,
SourceLocation OperatorLoc, TypeSourceInfo *tsi,
- OffsetOfNode* compsPtr, unsigned numComps,
+ OffsetOfNode* compsPtr, unsigned numComps,
Expr** exprsPtr, unsigned numExprs,
SourceLocation RParenLoc);
explicit OffsetOfExpr(unsigned numComps, unsigned numExprs)
: Expr(OffsetOfExprClass, EmptyShell()),
- TSInfo(0), NumComps(numComps), NumExprs(numExprs) {}
+ TSInfo(0), NumComps(numComps), NumExprs(numExprs) {}
public:
-
- static OffsetOfExpr *Create(ASTContext &C, QualType type,
- SourceLocation OperatorLoc, TypeSourceInfo *tsi,
- OffsetOfNode* compsPtr, unsigned numComps,
+
+ static OffsetOfExpr *Create(ASTContext &C, QualType type,
+ SourceLocation OperatorLoc, TypeSourceInfo *tsi,
+ OffsetOfNode* compsPtr, unsigned numComps,
Expr** exprsPtr, unsigned numExprs,
SourceLocation RParenLoc);
- static OffsetOfExpr *CreateEmpty(ASTContext &C,
+ static OffsetOfExpr *CreateEmpty(ASTContext &C,
unsigned NumComps, unsigned NumExprs);
/// getOperatorLoc - Return the location of the operator.
@@ -1149,14 +1149,14 @@ public:
/// \brief Return the location of the right parentheses.
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation R) { RParenLoc = R; }
-
+
TypeSourceInfo *getTypeSourceInfo() const {
return TSInfo;
}
void setTypeSourceInfo(TypeSourceInfo *tsi) {
TSInfo = tsi;
}
-
+
const OffsetOfNode &getComponent(unsigned Idx) {
assert(Idx < NumComps && "Subscript out of range");
return reinterpret_cast<OffsetOfNode *> (this + 1)[Idx];
@@ -1166,7 +1166,7 @@ public:
assert(Idx < NumComps && "Subscript out of range");
reinterpret_cast<OffsetOfNode *> (this + 1)[Idx] = ON;
}
-
+
unsigned getNumComponents() const {
return NumComps;
}
@@ -1182,7 +1182,7 @@ public:
reinterpret_cast<Expr **>(
reinterpret_cast<OffsetOfNode *>(this+1) + NumComps)[Idx] = E;
}
-
+
unsigned getNumExpressions() const {
return NumExprs;
}
@@ -1468,10 +1468,13 @@ public:
}
static bool classof(const Stmt *T) {
- return T->getStmtClass() >= firstCallExprConstant &&
- T->getStmtClass() <= lastCallExprConstant;
+ return T->getStmtClass() == CallExprClass ||
+ T->getStmtClass() == CXXOperatorCallExprClass ||
+ T->getStmtClass() == CXXMemberCallExprClass;
}
static bool classof(const CallExpr *) { return true; }
+ static bool classof(const CXXOperatorCallExpr *) { return true; }
+ static bool classof(const CXXMemberCallExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
@@ -1618,7 +1621,7 @@ public:
if (hasExplicitTemplateArgumentList())
getExplicitTemplateArgumentList()->copyInto(List);
}
-
+
/// \brief Retrieve the location of the left angle bracket following the
/// member name ('<'), if any.
SourceLocation getLAngleLoc() const {
@@ -1797,47 +1800,47 @@ public:
/// CK_DerivedToBaseMemberPointer - Member pointer in derived class to
/// member pointer in base class.
CK_DerivedToBaseMemberPointer,
-
+
/// CK_UserDefinedConversion - Conversion using a user defined type
/// conversion function.
CK_UserDefinedConversion,
/// CK_ConstructorConversion - Conversion by constructor
CK_ConstructorConversion,
-
+
/// CK_IntegralToPointer - Integral to pointer
CK_IntegralToPointer,
-
+
/// CK_PointerToIntegral - Pointer to integral
CK_PointerToIntegral,
-
+
/// CK_ToVoid - Cast to void.
CK_ToVoid,
-
+
/// CK_VectorSplat - Casting from an integer/floating type to an extended
- /// vector type with the same element type as the src type. Splats the
+ /// vector type with the same element type as the src type. Splats the
/// src expression into the destination expression.
CK_VectorSplat,
-
+
/// CK_IntegralCast - Casting between integral types of different size.
CK_IntegralCast,
/// CK_IntegralToFloating - Integral to floating point.
CK_IntegralToFloating,
-
+
/// CK_FloatingToIntegral - Floating point to integral.
CK_FloatingToIntegral,
-
+
/// CK_FloatingCast - Casting between floating types of different size.
CK_FloatingCast,
-
+
/// CK_MemberPointerToBoolean - Member pointer to boolean
CK_MemberPointerToBoolean,
- /// CK_AnyPointerToObjCPointerCast - Casting any pointer to objective-c
+ /// CK_AnyPointerToObjCPointerCast - Casting any pointer to objective-c
/// pointer
CK_AnyPointerToObjCPointerCast,
- /// CK_AnyPointerToBlockPointerCast - Casting any pointer to block
+ /// CK_AnyPointerToBlockPointerCast - Casting any pointer to block
/// pointer
CK_AnyPointerToBlockPointerCast
@@ -1930,8 +1933,14 @@ public:
const CXXBaseSpecifierArray& getBasePath() const { return BasePath; }
static bool classof(const Stmt *T) {
- return T->getStmtClass() >= firstCastExprConstant &&
- T->getStmtClass() <= lastCastExprConstant;
+ StmtClass SC = T->getStmtClass();
+ if (SC >= CXXStaticCastExprClass && SC <= CXXFunctionalCastExprClass)
+ return true;
+
+ if (SC >= ImplicitCastExprClass && SC <= CStyleCastExprClass)
+ return true;
+
+ return false;
}
static bool classof(const CastExpr *) { return true; }
@@ -1961,9 +1970,9 @@ class ImplicitCastExpr : public CastExpr {
bool LvalueCast;
public:
- ImplicitCastExpr(QualType ty, CastKind kind, Expr *op,
+ ImplicitCastExpr(QualType ty, CastKind kind, Expr *op,
CXXBaseSpecifierArray BasePath, bool Lvalue)
- : CastExpr(ImplicitCastExprClass, ty, kind, op, BasePath),
+ : CastExpr(ImplicitCastExprClass, ty, kind, op, BasePath),
LvalueCast(Lvalue) { }
/// \brief Construct an empty implicit cast.
@@ -2028,8 +2037,13 @@ public:
QualType getTypeAsWritten() const { return TInfo->getType(); }
static bool classof(const Stmt *T) {
- return T->getStmtClass() >= firstExplicitCastExprConstant &&
- T->getStmtClass() <= lastExplicitCastExprConstant;
+ StmtClass SC = T->getStmtClass();
+ if (SC >= CStyleCastExprClass && SC <= CStyleCastExprClass)
+ return true;
+ if (SC >= CXXStaticCastExprClass && SC <= CXXFunctionalCastExprClass)
+ return true;
+
+ return false;
}
static bool classof(const ExplicitCastExpr *) { return true; }
};
@@ -2184,8 +2198,8 @@ public:
bool isShiftAssignOp() const { return Opc == ShlAssign || Opc == ShrAssign; }
static bool classof(const Stmt *S) {
- return S->getStmtClass() >= firstBinaryOperatorConstant &&
- S->getStmtClass() <= lastBinaryOperatorConstant;
+ return S->getStmtClass() == BinaryOperatorClass ||
+ S->getStmtClass() == CompoundAssignOperatorClass;
}
static bool classof(const BinaryOperator *) { return true; }
@@ -2866,7 +2880,7 @@ protected:
virtual void DoDestroy(ASTContext &C);
void DestroyDesignators(ASTContext &C);
-
+
public:
/// A field designator, e.g., ".x".
struct FieldDesignator {
@@ -3034,7 +3048,7 @@ public:
Designator *getDesignator(unsigned Idx) { return &designators_begin()[Idx]; }
- void setDesignators(ASTContext &C, const Designator *Desigs,
+ void setDesignators(ASTContext &C, const Designator *Desigs,
unsigned NumDesigs);
Expr *getArrayIndex(const Designator& D);
diff --git a/include/clang/AST/Makefile b/include/clang/AST/Makefile
deleted file mode 100644
index a25977cad6..0000000000
--- a/include/clang/AST/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-LEVEL = ../../../../..
-BUILT_SOURCES = StmtNodes.inc
-
-TABLEGEN_INC_FILES_COMMON = 1
-
-include $(LEVEL)/Makefile.common
-
-INPUT_TDS = $(PROJ_SRC_DIR)/StmtNodes.td
-
-$(ObjDir)/StmtNodes.inc.tmp : StmtNodes.td $(TBLGEN) $(ObjDir)/.dir
- $(Echo) "Building Clang statement node tables with tblgen"
- $(Verb) $(TableGen) -gen-clang-stmt-nodes -o $(call SYSPATH, $@) $<
-
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index 2b050d3999..0b68a40073 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -99,24 +99,11 @@ public:
NoStmtClass = 0,
#define STMT(CLASS, PARENT) CLASS##Class,
#define FIRST_STMT(CLASS) firstStmtConstant = CLASS##Class,
-// LAST_STMT will always come last
-#define LAST_STMT(CLASS) lastStmtConstant = CLASS##Class
+#define LAST_STMT(CLASS) lastStmtConstant = CLASS##Class,
#define FIRST_EXPR(CLASS) firstExprConstant = CLASS##Class,
-#define LAST_EXPR(CLASS) lastExprConstant = CLASS##Class,
-#define FIRST_CALLEXPR(CLASS) firstCallExprConstant = CLASS##Class,
-#define LAST_CALLEXPR(CLASS) lastCallExprConstant = CLASS##Class,
-#define FIRST_CASTEXPR(CLASS) firstCastExprConstant = CLASS##Class,
-#define LAST_CASTEXPR(CLASS) lastCastExprConstant = CLASS##Class,
-#define FIRST_EXPLICITCASTEXPR(CLASS) firstExplicitCastExprConstant = \
- CLASS##Class,
-#define LAST_EXPLICITCASTEXPR(CLASS) lastExplicitCastExprConstant = \
- CLASS##Class,
-#define FIRST_BINARYOPERATOR(CLASS) firstBinaryOperatorConstant = \
- CLASS##Class,
-#define LAST_BINARYOPERATOR(CLASS) lastBinaryOperatorConstant = \
- CLASS##Class,
-#define ABSTRACT(STMT)
-#include "clang/AST/StmtNodes.inc"
+#define LAST_EXPR(CLASS) lastExprConstant = CLASS##Class
+#define ABSTRACT_EXPR(CLASS, PARENT)
+#include "clang/AST/StmtNodes.def"
};
private:
/// \brief The statement class.
@@ -211,9 +198,9 @@ public:
return this;
}
- StmtClass getStmtClass() const {
+ StmtClass getStmtClass() const {
assert(RefCount >= 1 && "Referencing already-destroyed statement!");
- return (StmtClass)sClass;
+ return (StmtClass)sClass;
}
const char *getStmtClassName() const;
@@ -633,10 +620,10 @@ class IfStmt : public Stmt {
/// \brief If non-NULL, the declaration in the "if" statement.
VarDecl *Var;
-
+
SourceLocation IfLoc;
SourceLocation ElseLoc;
-
+
public:
IfStmt(SourceLocation IL, VarDecl *var, Expr *cond, Stmt *then,
SourceLocation EL = SourceLocation(), Stmt *elsev = 0)
@@ -659,7 +646,7 @@ public:
/// \endcode
VarDecl *getConditionVariable() const { return Var; }
void setConditionVariable(VarDecl *V) { Var = V; }
-
+
const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); }
const Stmt *getThen() const { return SubExprs[THEN]; }
@@ -711,8 +698,8 @@ protected:
virtual void DoDestroy(ASTContext &Ctx);
public:
- SwitchStmt(VarDecl *Var, Expr *cond)
- : Stmt(SwitchStmtClass), Var(Var), FirstCase(0)
+ SwitchStmt(VarDecl *Var, Expr *cond)
+ : Stmt(SwitchStmtClass), Var(Var), FirstCase(0)
{
SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
SubExprs[BODY] = NULL;
@@ -785,7 +772,7 @@ class WhileStmt : public Stmt {
SourceLocation WhileLoc;
public:
WhileStmt(VarDecl *Var, Expr *cond, Stmt *body, SourceLocation WL)
- : Stmt(WhileStmtClass), Var(Var)
+ : Stmt(WhileStmtClass), Var(Var)
{
SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
SubExprs[BODY] = body;
@@ -827,7 +814,7 @@ public:
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
-
+
protected:
virtual void DoDestroy(ASTContext &Ctx);
};
@@ -893,10 +880,10 @@ class ForStmt : public Stmt {
SourceLocation LParenLoc, RParenLoc;
public:
- ForStmt(Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc, Stmt *Body,
+ ForStmt(Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc, Stmt *Body,
SourceLocation FL, SourceLocation LP, SourceLocation RP)
- : Stmt(ForStmtClass), CondVar(condVar), ForLoc(FL), LParenLoc(LP),
- RParenLoc(RP)
+ : Stmt(ForStmtClass), CondVar(condVar), ForLoc(FL), LParenLoc(LP),
+ RParenLoc(RP)
{
SubExprs[INIT] = Init;
SubExprs[COND] = reinterpret_cast<Stmt*>(Cond);
@@ -908,7 +895,7 @@ public:
explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) { }
Stmt *getInit() { return SubExprs[INIT]; }
-
+
/// \brief Retrieve the variable declared in this "for" statement, if any.
///
/// In the following example, "y" is the condition variable.
@@ -919,7 +906,7 @@ public:
/// \endcode
VarDecl *getConditionVariable() const { return CondVar; }
void setConditionVariable(VarDecl *V) { CondVar = V; }
-
+
Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
Expr *getInc() { return reinterpret_cast<Expr*>(SubExprs[INC]); }
Stmt *getBody() { return SubExprs[BODY]; }
@@ -952,7 +939,7 @@ public:
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
-
+
protected:
virtual void DoDestroy(ASTContext &Ctx);
};
@@ -1144,16 +1131,16 @@ class AsmStmt : public Stmt {
protected:
virtual void DoDestroy(ASTContext &Ctx);
-
+
public:
- AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, bool isvolatile,
+ AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, bool isvolatile,
bool msasm, unsigned numoutputs, unsigned numinputs,
IdentifierInfo **names, StringLiteral **constraints,
Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
StringLiteral **clobbers, SourceLocation rparenloc);
/// \brief Build an empty inline-assembly statement.
- explicit AsmStmt(EmptyShell Empty) : Stmt(AsmStmtClass, Empty),
+ explicit AsmStmt(EmptyShell Empty) : Stmt(AsmStmtClass, Empty),
Names(0), Constraints(0), Exprs(0), Clobbers(0) { }
SourceLocation getAsmLoc() const { return AsmLoc; }
@@ -1235,7 +1222,7 @@ public:
llvm::StringRef getOutputName(unsigned i) const {
if (IdentifierInfo *II = getOutputIdentifier(i))
return II->getName();
-
+
return llvm::StringRef();
}
@@ -1305,7 +1292,7 @@ public:
StringLiteral **Constraints,
Stmt **Exprs,
unsigned NumOutputs,
- unsigned NumInputs,
+ unsigned NumInputs,
StringLiteral **Clobbers,
unsigned NumClobbers);
diff --git a/include/clang/AST/StmtNodes.def b/include/clang/AST/StmtNodes.def
new file mode 100644
index 0000000000..3a23e49148
--- /dev/null
+++ b/include/clang/AST/StmtNodes.def
@@ -0,0 +1,165 @@
+//===-- StmtNodes.def - Metadata about Stmt AST nodes -----------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the AST Node info database.
+//
+//===---------------------------------------------------------------------===//
+
+#ifndef FIRST_STMT
+#define FIRST_STMT(CLASS)
+#define LAST_STMT(CLASS)
+#endif
+
+#ifndef FIRST_EXPR
+#define FIRST_EXPR(CLASS)
+#define LAST_EXPR(CLASS)
+#endif
+
+#ifndef EXPR
+# define EXPR(Type, Base) STMT(Type, Base)
+#endif
+
+#ifndef ABSTRACT_EXPR
+# define ABSTRACT_EXPR(Type, Base) EXPR(Type, Base)
+#endif
+
+// Normal Statements.
+STMT(NullStmt , Stmt)
+FIRST_STMT(NullStmt)
+STMT(CompoundStmt , Stmt)
+STMT(CaseStmt , SwitchCase)
+STMT(DefaultStmt , SwitchCase)
+STMT(LabelStmt , Stmt)
+STMT(IfStmt , Stmt)
+STMT(SwitchStmt , Stmt)
+STMT(WhileStmt , Stmt)
+STMT(DoStmt , Stmt)
+STMT(ForStmt , Stmt)
+STMT(GotoStmt , Stmt)
+STMT(IndirectGotoStmt, Stmt)
+STMT(ContinueStmt , Stmt)
+STMT(BreakStmt , Stmt)
+STMT(ReturnStmt , Stmt)
+STMT(DeclStmt , Stmt)
+STMT(SwitchCase , Stmt)
+
+// GNU Stmt Extensions
+STMT(AsmStmt , Stmt)
+
+// Obj-C statements
+STMT(ObjCAtTryStmt , Stmt)
+STMT(ObjCAtCatchStmt , Stmt)
+STMT(ObjCAtFinallyStmt , Stmt)
+STMT(ObjCAtThrowStmt , Stmt)
+STMT(ObjCAtSynchronizedStmt , Stmt)
+// Obj-C2 statements
+STMT(ObjCForCollectionStmt, Stmt)
+
+// C++ statements
+STMT(CXXCatchStmt, Stmt)
+STMT(CXXTryStmt , Stmt)
+
+LAST_STMT(CXXTryStmt)
+
+// Expressions.
+ABSTRACT_EXPR(Expr , Stmt)
+EXPR(PredefinedExpr , Expr)
+EXPR(DeclRefExpr , Expr)
+EXPR(IntegerLiteral , Expr)
+EXPR(FloatingLiteral , Expr)
+EXPR(ImaginaryLiteral , Expr)
+EXPR(StringLiteral , Expr)
+EXPR(CharacterLiteral , Expr)
+EXPR(ParenExpr , Expr)
+EXPR(UnaryOperator , Expr)
+EXPR(OffsetOfExpr , Expr)
+EXPR(SizeOfAlignOfExpr , Expr)
+EXPR(ArraySubscriptExpr , Expr)
+EXPR(CallExpr , Expr)
+EXPR(MemberExpr , Expr)
+ABSTRACT_EXPR(CastExpr , Expr)
+EXPR(BinaryOperator , Expr)
+EXPR(CompoundAssignOperator, BinaryOperator)
+EXPR(ConditionalOperator , Expr)
+EXPR(ImplicitCastExpr , CastExpr)
+ABSTRACT_EXPR(ExplicitCastExpr, CastExpr)
+EXPR(CStyleCastExpr , ExplicitCastExpr)
+EXPR(CompoundLiteralExpr , Expr)
+EXPR(ExtVectorElementExpr , Expr)
+EXPR(InitListExpr , Expr)
+EXPR(DesignatedInitExpr , Expr)
+EXPR(ImplicitValueInitExpr , Expr)
+EXPR(ParenListExpr , Expr)
+EXPR(VAArgExpr , Expr)
+
+// GNU Extensions.
+EXPR(AddrLabelExpr , Expr)
+EXPR(StmtExpr