From: Sean Hunt Date: Wed, 5 May 2010 04:13:52 +0000 (+0000) Subject: Change StmtNodes.def to StmtNodes.td in anticipation of a rewrite of attributes X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9d90d62e1661720d9cf533290b4227c4fde780a4;p=clang Change StmtNodes.def to StmtNodes.td in anticipation of a rewrite of attributes git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103072 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 2946e464a7..d24d335b25 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 (this + 1); } - + /// \brief Retrieve the template arguments const TemplateArgumentLoc *getTemplateArgs() const { return reinterpret_cast (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 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 (this + 1); } - + /// \brief Retrieve the qualifier that preceded the member name, if any. const NameQualifier *getNameQualifier() const { return const_cast(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(this + 1); - + return reinterpret_cast( getNameQualifier() + 1); } - + /// \brief Retrieve the explicit template argument list that followed the /// member template name, if any. const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const { return const_cast(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. 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(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(Name) | Identifier) { } /// \brief Create an offsetof node that refers into a C++ base class. explicit OffsetOfNode(const CXXBaseSpecifier *Base) : Range(), Data(reinterpret_cast(Base) | OffsetOfNode::Base) {} - + /// \brief Determine what kind of offsetof node this is. - Kind getKind() const { + Kind getKind() const { return static_cast(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(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(Data & ~(uintptr_t)Mask); + return reinterpret_cast(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 (this + 1)[Idx]; @@ -1166,7 +1166,7 @@ public: assert(Idx < NumComps && "Subscript out of range"); reinterpret_cast (this + 1)[Idx] = ON; } - + unsigned getNumComponents() const { return NumComps; } @@ -1182,7 +1182,7 @@ public: reinterpret_cast( reinterpret_cast(this+1) + NumComps)[Idx] = E; } - + unsigned getNumExpressions() const { return NumExprs; } @@ -1468,13 +1468,10 @@ public: } static bool classof(const Stmt *T) { - return T->getStmtClass() == CallExprClass || - T->getStmtClass() == CXXOperatorCallExprClass || - T->getStmtClass() == CXXMemberCallExprClass; + return T->getStmtClass() >= firstCallExprConstant && + T->getStmtClass() <= lastCallExprConstant; } 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(); @@ -1621,7 +1618,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 { @@ -1800,47 +1797,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 @@ -1933,14 +1930,8 @@ public: const CXXBaseSpecifierArray& getBasePath() const { return BasePath; } static bool classof(const Stmt *T) { - StmtClass SC = T->getStmtClass(); - if (SC >= CXXStaticCastExprClass && SC <= CXXFunctionalCastExprClass) - return true; - - if (SC >= ImplicitCastExprClass && SC <= CStyleCastExprClass) - return true; - - return false; + return T->getStmtClass() >= firstCastExprConstant && + T->getStmtClass() <= lastCastExprConstant; } static bool classof(const CastExpr *) { return true; } @@ -1970,9 +1961,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. @@ -2037,13 +2028,8 @@ public: QualType getTypeAsWritten() const { return TInfo->getType(); } static bool classof(const Stmt *T) { - StmtClass SC = T->getStmtClass(); - if (SC >= CStyleCastExprClass && SC <= CStyleCastExprClass) - return true; - if (SC >= CXXStaticCastExprClass && SC <= CXXFunctionalCastExprClass) - return true; - - return false; + return T->getStmtClass() >= firstExplicitCastExprConstant && + T->getStmtClass() <= lastExplicitCastExprConstant; } static bool classof(const ExplicitCastExpr *) { return true; } }; @@ -2198,8 +2184,8 @@ public: bool isShiftAssignOp() const { return Opc == ShlAssign || Opc == ShrAssign; } static bool classof(const Stmt *S) { - return S->getStmtClass() == BinaryOperatorClass || - S->getStmtClass() == CompoundAssignOperatorClass; + return S->getStmtClass() >= firstBinaryOperatorConstant && + S->getStmtClass() <= lastBinaryOperatorConstant; } static bool classof(const BinaryOperator *) { return true; } @@ -2880,7 +2866,7 @@ protected: virtual void DoDestroy(ASTContext &C); void DestroyDesignators(ASTContext &C); - + public: /// A field designator, e.g., ".x". struct FieldDesignator { @@ -3048,7 +3034,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 new file mode 100644 index 0000000000..a25977cad6 --- /dev/null +++ b/include/clang/AST/Makefile @@ -0,0 +1,13 @@ +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 0b68a40073..2b050d3999 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -99,11 +99,24 @@ public: NoStmtClass = 0, #define STMT(CLASS, PARENT) CLASS##Class, #define FIRST_STMT(CLASS) firstStmtConstant = CLASS##Class, -#define LAST_STMT(CLASS) lastStmtConstant = CLASS##Class, +// LAST_STMT will always come last +#define LAST_STMT(CLASS) lastStmtConstant = CLASS##Class #define FIRST_EXPR(CLASS) firstExprConstant = CLASS##Class, -#define LAST_EXPR(CLASS) lastExprConstant = CLASS##Class -#define ABSTRACT_EXPR(CLASS, PARENT) -#include "clang/AST/StmtNodes.def" +#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" }; private: /// \brief The statement class. @@ -198,9 +211,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; @@ -620,10 +633,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) @@ -646,7 +659,7 @@ public: /// \endcode VarDecl *getConditionVariable() const { return Var; } void setConditionVariable(VarDecl *V) { Var = V; } - + const Expr *getCond() const { return reinterpret_cast(SubExprs[COND]);} void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast(E); } const Stmt *getThen() const { return SubExprs[THEN]; } @@ -698,8 +711,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(cond); SubExprs[BODY] = NULL; @@ -772,7 +785,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(cond); SubExprs[BODY] = body; @@ -814,7 +827,7 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); - + protected: virtual void DoDestroy(ASTContext &Ctx); }; @@ -880,10 +893,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(Cond); @@ -895,7 +908,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. @@ -906,7 +919,7 @@ public: /// \endcode VarDecl *getConditionVariable() const { return CondVar; } void setConditionVariable(VarDecl *V) { CondVar = V; } - + Expr *getCond() { return reinterpret_cast(SubExprs[COND]); } Expr *getInc() { return reinterpret_cast(SubExprs[INC]); } Stmt *getBody() { return SubExprs[BODY]; } @@ -939,7 +952,7 @@ public: // Iterators virtual child_iterator child_begin(); virtual child_iterator child_end(); - + protected: virtual void DoDestroy(ASTContext &Ctx); }; @@ -1131,16 +1144,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; } @@ -1222,7 +1235,7 @@ public: llvm::StringRef getOutputName(unsigned i) const { if (IdentifierInfo *II = getOutputIdentifier(i)) return II->getName(); - + return llvm::StringRef(); } @@ -1292,7 +1305,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 deleted file mode 100644 index 3a23e49148..0000000000 --- a/include/clang/AST/StmtNodes.def +++ /dev/null @@ -1,165 +0,0 @@ -//===-- 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 , Expr) -EXPR(TypesCompatibleExpr , Expr) -EXPR(ChooseExpr , Expr) -EXPR(GNUNullExpr , Expr) - -// C++ Expressions. -EXPR(CXXOperatorCallExpr , CallExpr) -EXPR(CXXMemberCallExpr , CallExpr) -ABSTRACT_EXPR(CXXNamedCastExpr , ExplicitCastExpr) -EXPR(CXXStaticCastExpr , CXXNamedCastExpr) -EXPR(CXXDynamicCastExpr , CXXNamedCastExpr) -EXPR(CXXReinterpretCastExpr , CXXNamedCastExpr) -EXPR(CXXConstCastExpr , CXXNamedCastExpr) -EXPR(CXXFunctionalCastExpr , ExplicitCastExpr) -EXPR(CXXTypeidExpr , Expr) -EXPR(CXXBoolLiteralExpr , Expr) -EXPR(CXXNullPtrLiteralExpr , Expr) -EXPR(CXXThisExpr , Expr) -EXPR(CXXThrowExpr , Expr) -EXPR(CXXDefaultArgExpr , Expr) -EXPR(CXXZeroInitValueExpr , Expr) -EXPR(CXXNewExpr , Expr) -EXPR(CXXDeleteExpr , Expr) -EXPR(CXXPseudoDestructorExpr, Expr) -EXPR(UnresolvedLookupExpr , Expr) -EXPR(UnaryTypeTraitExpr , Expr) -EXPR(DependentScopeDeclRefExpr , Expr) -EXPR(CXXConstructExpr , Expr) -EXPR(CXXBindTemporaryExpr , Expr) -EXPR(CXXBindReferenceExpr , Expr) -EXPR(CXXExprWithTemporaries , Expr) -EXPR(CXXTemporaryObjectExpr , CXXConstructExpr) -EXPR(CXXUnresolvedConstructExpr, Expr) -EXPR(CXXDependentScopeMemberExpr, Expr) -EXPR(UnresolvedMemberExpr , Expr) - -// Obj-C Expressions. -EXPR(ObjCStringLiteral , Expr) -EXPR(ObjCEncodeExpr , Expr) -EXPR(ObjCMessageExpr , Expr) -EXPR(ObjCSelectorExpr , Expr) -EXPR(ObjCProtocolExpr , Expr) -EXPR(ObjCIvarRefExpr , Expr) -EXPR(ObjCPropertyRefExpr , Expr) -EXPR(ObjCImplicitSetterGetterRefExpr , Expr) -EXPR(ObjCSuperExpr , Expr) -EXPR(ObjCIsaExpr , Expr) - -// Clang Extensions. -EXPR(ShuffleVectorExpr , Expr) -EXPR(BlockExpr , Expr) -EXPR(BlockDeclRefExpr , Expr) - -FIRST_EXPR(PredefinedExpr) -LAST_EXPR(BlockDeclRefExpr) - -#undef ABSTRACT_EXPR -#undef EXPR -#undef STMT -#undef FIRST_STMT -#undef LAST_STMT -#undef FIRST_EXPR -#undef LAST_EXPR diff --git a/include/clang/AST/StmtNodes.td b/include/clang/AST/StmtNodes.td new file mode 100644 index 0000000000..60c94a609b --- /dev/null +++ b/include/clang/AST/StmtNodes.td @@ -0,0 +1,127 @@ +class Stmt { + bit Abstract = abstract; +} + +class DStmt : Stmt { + Stmt Base = base; +} + +// Statements +def NullStmt : Stmt; +def CompoundStmt : Stmt; +def LabelStmt : Stmt; +def IfStmt : Stmt; +def SwitchStmt : Stmt; +def WhileStmt : Stmt; +def DoStmt : Stmt; +def ForStmt : Stmt; +def GotoStmt : Stmt; +def IndirectGotoStmt : Stmt; +def ContinueStmt : Stmt; +def BreakStmt : Stmt; +def ReturnStmt : Stmt; +def DeclStmt : Stmt; +def SwitchCase : Stmt; +def CaseStmt : DStmt; +def DefaultStmt : DStmt; + +// GNU Extensions +def AsmStmt : Stmt; + +// Obj-C statements +def ObjCAtTryStmt : Stmt; +def ObjCAtCatchStmt : Stmt; +def ObjCAtFinallyStmt : Stmt; +def ObjCAtThrowStmt : Stmt; +def ObjCAtSynchronizedStmt : Stmt; +def ObjCForCollectionStmt : Stmt; + +// C++ statments +def CXXCatchStmt : Stmt; +def CXXTryStmt : Stmt; + +// Expressions +def Expr : Stmt<1>; +def PredefinedExpr : DStmt; +def DeclRefExpr : DStmt; +def IntegerLiteral : DStmt; +def FloatingLiteral : DStmt; +def ImaginaryLiteral : DStmt; +def StringLiteral : DStmt; +def CharacterLiteral : DStmt; +def ParenExpr : DStmt; +def UnaryOperator : DStmt; +def OffsetOfExpr : DStmt; +def SizeOfAlignOfExpr : DStmt; +def ArraySubscriptExpr : DStmt; +def CallExpr : DStmt; +def MemberExpr : DStmt; +def CastExpr : DStmt; +def BinaryOperator : DStmt; +def CompoundAssignOperator : DStmt; +def ConditionalOperator : DStmt; +def ImplicitCastExpr : DStmt; +def ExplicitCastExpr : DStmt; +def CStyleCastExpr : DStmt; +def CompoundLiteralExpr : DStmt; +def ExtVectorElementExpr : DStmt; +def InitListExpr : DStmt; +def DesignatedInitExpr : DStmt; +def ImplicitValueInitExpr : DStmt; +def ParenListExpr : DStmt; +def VAArgExpr : DStmt; + +// GNU Extensions. +def AddrLabelExpr : DStmt; +def StmtExpr : DStmt; +def TypesCompatibleExpr : DStmt; +def ChooseExpr : DStmt; +def GNUNullExpr : DStmt; + +// C++ Expressions. +def CXXOperatorCallExpr : DStmt; +def CXXMemberCallExpr : DStmt; +def CXXNamedCastExpr : DStmt; +def CXXStaticCastExpr : DStmt; +def CXXDynamicCastExpr : DStmt; +def CXXReinterpretCastExpr : DStmt; +def CXXConstCastExpr : DStmt; +def CXXFunctionalCastExpr : DStmt; +def CXXTypeidExpr : DStmt; +def CXXBoolLiteralExpr : DStmt; +def CXXNullPtrLiteralExpr : DStmt; +def CXXThisExpr : DStmt; +def CXXThrowExpr : DStmt; +def CXXDefaultArgExpr : DStmt; +def CXXZeroInitValueExpr : DStmt; +def CXXNewExpr : DStmt; +def CXXDeleteExpr : DStmt; +def CXXPseudoDestructorExpr : DStmt; +def UnresolvedLookupExpr : DStmt; +def UnaryTypeTraitExpr : DStmt; +def DependentScopeDeclRefExpr : DStmt; +def CXXConstructExpr : DStmt; +def CXXBindTemporaryExpr : DStmt; +def CXXBindReferenceExpr : DStmt; +def CXXExprWithTemporaries : DStmt; +def CXXTemporaryObjectExpr : DStmt; +def CXXUnresolvedConstructExpr : DStmt; +def CXXDependentScopeMemberExpr : DStmt; +def UnresolvedMemberExpr : DStmt; + +// Obj-C Expressions. +def ObjCStringLiteral : DStmt; +def ObjCEncodeExpr : DStmt; +def ObjCMessageExpr : DStmt; +def ObjCSelectorExpr : DStmt; +def ObjCProtocolExpr : DStmt; +def ObjCIvarRefExpr : DStmt; +def ObjCPropertyRefExpr : DStmt; +def ObjCImplicitSetterGetterRefExpr : DStmt; +def ObjCSuperExpr : DStmt; +def ObjCIsaExpr : DStmt; + +// Clang Extensions. +def ShuffleVectorExpr : DStmt; +def BlockExpr : DStmt; +def BlockDeclRefExpr : DStmt; diff --git a/include/clang/AST/StmtVisitor.h b/include/clang/AST/StmtVisitor.h index 4986f08ac1..f1d478ded4 100644 --- a/include/clang/AST/StmtVisitor.h +++ b/include/clang/AST/StmtVisitor.h @@ -105,10 +105,10 @@ public: // Top switch stmt: dispatch to VisitFooStmt for each FooStmt. switch (S->getStmtClass()) { default: assert(0 && "Unknown stmt kind!"); -#define ABSTRACT_EXPR(CLASS, PARENT) +#define ABSTRACT(STMT) #define STMT(CLASS, PARENT) \ case Stmt::CLASS ## Class: DISPATCH(CLASS, CLASS); -#include "clang/AST/StmtNodes.def" +#include "clang/AST/StmtNodes.inc" } } @@ -116,7 +116,7 @@ public: // back on VisitExpr or whatever else is the superclass. #define STMT(CLASS, PARENT) \ RetTy Visit ## CLASS(CLASS *S) { DISPATCH(PARENT, PARENT); } -#include "clang/AST/StmtNodes.def" +#include "clang/AST/StmtNodes.inc" // If the implementation doesn't implement binary operator methods, fall back // on VisitBinaryOperator. diff --git a/include/clang/CMakeLists.txt b/include/clang/CMakeLists.txt index 61d2bf602d..c2880481a2 100644 --- a/include/clang/CMakeLists.txt +++ b/include/clang/CMakeLists.txt @@ -1,2 +1,3 @@ +add_subdirectory(AST) add_subdirectory(Basic) add_subdirectory(Driver) diff --git a/include/clang/Makefile b/include/clang/Makefile index d76e0a9c63..7a8d128bba 100644 --- a/include/clang/Makefile +++ b/include/clang/Makefile @@ -1,5 +1,5 @@ LEVEL = ../../../.. -DIRS := Basic Driver +DIRS := AST Basic Driver include $(LEVEL)/Makefile.common diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 00662a53af..3e79f66251 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -34,12 +34,12 @@ using namespace clang; bool Expr::isKnownToHaveBooleanValue() const { // If this value has _Bool type, it is obvious 0/1. if (getType()->isBooleanType()) return true; - // If this is a non-scalar-integer type, we don't care enough to try. + // If this is a non-scalar-integer type, we don't care enough to try. if (!getType()->isIntegralType()) return false; - + if (const ParenExpr *PE = dyn_cast(this)) return PE->getSubExpr()->isKnownToHaveBooleanValue(); - + if (const UnaryOperator *UO = dyn_cast(this)) { switch (UO->getOpcode()) { case UnaryOperator::Plus: @@ -49,10 +49,10 @@ bool Expr::isKnownToHaveBooleanValue() const { return false; } } - + if (const CastExpr *CE = dyn_cast(this)) return CE->getSubExpr()->isKnownToHaveBooleanValue(); - + if (const BinaryOperator *BO = dyn_cast(this)) { switch (BO->getOpcode()) { default: return false; @@ -65,24 +65,24 @@ bool Expr::isKnownToHaveBooleanValue() const { case BinaryOperator::LAnd: // AND operator. case BinaryOperator::LOr: // Logical OR operator. return true; - + case BinaryOperator::And: // Bitwise AND operator. case BinaryOperator::Xor: // Bitwise XOR operator. case BinaryOperator::Or: // Bitwise OR operator. // Handle things like (x==2)|(y==12). return BO->getLHS()->isKnownToHaveBooleanValue() && BO->getRHS()->isKnownToHaveBooleanValue(); - + case BinaryOperator::Comma: case BinaryOperator::Assign: return BO->getRHS()->isKnownToHaveBooleanValue(); } } - + if (const ConditionalOperator *CO = dyn_cast(this)) return CO->getTrueExpr()->isKnownToHaveBooleanValue() && CO->getFalseExpr()->isKnownToHaveBooleanValue(); - + return false; } @@ -118,13 +118,13 @@ std::size_t ExplicitTemplateArgumentList::sizeFor( void DeclRefExpr::computeDependence() { TypeDependent = false; ValueDependent = false; - + NamedDecl *D = getDecl(); // (TD) C++ [temp.dep.expr]p3: // An id-expression is type-dependent if it contains: // - // and + // and // // (VD) C++ [temp.dep.constexpr]p2: // An identifier is value-dependent if it is: @@ -136,16 +136,16 @@ void DeclRefExpr::computeDependence() { ValueDependent = true; } // (TD) - a conversion-function-id that specifies a dependent type - else if (D->getDeclName().getNameKind() + else if (D->getDeclName().getNameKind() == DeclarationName::CXXConversionFunctionName && D->getDeclName().getCXXNameType()->isDependentType()) { TypeDependent = true; ValueDependent = true; } // (TD) - a template-id that is dependent, - else if (hasExplicitTemplateArgumentList() && + else if (hasExplicitTemplateArgumentList() && TemplateSpecializationType::anyDependentTemplateArguments( - getTemplateArgs(), + getTemplateArgs(), getNumTemplateArgs())) { TypeDependent = true; ValueDependent = true; @@ -168,7 +168,7 @@ void DeclRefExpr::computeDependence() { // (handled by DependentScopeDeclRefExpr) } -DeclRefExpr::DeclRefExpr(NestedNameSpecifier *Qualifier, +DeclRefExpr::DeclRefExpr(NestedNameSpecifier *Qualifier, SourceRange QualifierRange, ValueDecl *D, SourceLocation NameLoc, const TemplateArgumentListInfo *TemplateArgs, @@ -183,7 +183,7 @@ DeclRefExpr::DeclRefExpr(NestedNameSpecifier *Qualifier, NQ->NNS = Qualifier; NQ->Range = QualifierRange; } - + if (TemplateArgs) getExplicitTemplateArgumentList()->initializeFrom(*TemplateArgs); @@ -200,10 +200,10 @@ DeclRefExpr *DeclRefExpr::Create(ASTContext &Context, std::size_t Size = sizeof(DeclRefExpr); if (Qualifier != 0) Size += sizeof(NameQualifier); - + if (TemplateArgs) Size += ExplicitTemplateArgumentList::sizeFor(*TemplateArgs); - + void *Mem = Context.Allocate(Size, llvm::alignof()); return new (Mem) DeclRefExpr(Qualifier, QualifierRange, D, NameLoc, TemplateArgs, T); @@ -212,7 +212,7 @@ DeclRefExpr *DeclRefExpr::Create(ASTContext &Context, SourceRange DeclRefExpr::getSourceRange() const { // FIXME: Does not handle multi-token names well, e.g., operator[]. SourceRange R(Loc); - + if (hasQualifier()) R.setBegin(getQualifierRange().getBegin()); if (hasExplicitTemplateArgumentList()) @@ -549,14 +549,14 @@ QualType CallExpr::getCallReturnType() const { return FnType->getResultType(); } -OffsetOfExpr *OffsetOfExpr::Create(ASTContext &C, QualType type, +OffsetOfExpr *OffsetOfExpr::Create(ASTContext &C, QualType type, SourceLocation OperatorLoc, - TypeSourceInfo *tsi, - OffsetOfNode* compsPtr, unsigned numComps, + TypeSourceInfo *tsi, + OffsetOfNode* compsPtr, unsigned numComps, Expr** exprsPtr, unsigned numExprs, SourceLocation RParenLoc) { void *Mem = C.Allocate(sizeof(OffsetOfExpr) + - sizeof(OffsetOfNode) * numComps + + sizeof(OffsetOfNode) * numComps + sizeof(Expr*) * numExprs); return new (Mem) OffsetOfExpr(C, type, OperatorLoc, tsi, compsPtr, numComps, @@ -571,22 +571,22 @@ OffsetOfExpr *OffsetOfExpr::CreateEmpty(ASTContext &C, return new (Mem) OffsetOfExpr(numComps, numExprs); } -OffsetOfExpr::OffsetOfExpr(ASTContext &C, QualType type, +OffsetOfExpr::OffsetOfExpr(ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, - OffsetOfNode* compsPtr, unsigned numComps, + OffsetOfNode* compsPtr, unsigned numComps, Expr** exprsPtr, unsigned numExprs, SourceLocation RParenLoc) - : Expr(OffsetOfExprClass, type, /*TypeDependent=*/false, + : Expr(OffsetOfExprClass, type, /*TypeDependent=*/false, /*ValueDependent=*/tsi->getType()->isDependentType() || hasAnyTypeDependentArguments(exprsPtr, numExprs) || hasAnyValueDependentArguments(exprsPtr, numExprs)), - OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi), - NumComps(numComps), NumExprs(numExprs) + OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi), + NumComps(numComps), NumExprs(numExprs) { for(unsigned i = 0; i < numComps; ++i) { setComponent(i, compsPtr[i]); } - + for(unsigned i = 0; i < numExprs; ++i) { setIndexExpr(i, exprsPtr[i]); } @@ -596,7 +596,7 @@ IdentifierInfo *OffsetOfExpr::OffsetOfNode::getFieldName() const { assert(getKind() == Field || getKind() == Identifier); if (getKind() == Field) return getField()->getIdentifier(); - + return reinterpret_cast (Data & ~(uintptr_t)Mask); } @@ -714,22 +714,22 @@ Expr *CastExpr::getSubExprAsWritten() { CastExpr *E = this; do { SubExpr = E->getSubExpr(); - + // Skip any temporary bindings; they're implicit. if (CXXBindTemporaryExpr *Binder = dyn_cast(SubExpr)) SubExpr = Binder->getSubExpr(); - + // Conversions by constructor and conversion functions have a // subexpression describing the call; strip it off. if (E->getCastKind() == CastExpr::CK_ConstructorConversion) SubExpr = cast(SubExpr)->getArg(0); else if (E->getCastKind() == CastExpr::CK_UserDefinedConversion) SubExpr = cast(SubExpr)->getImplicitObjectArgument(); - + // If the subexpression we're left with is an implicit cast, look // through that, too. - } while ((E = dyn_cast(SubExpr))); - + } while ((E = dyn_cast(SubExpr))); + return SubExpr; } @@ -842,15 +842,15 @@ InitListExpr::InitListExpr(ASTContext &C, SourceLocation lbraceloc, : Expr(InitListExprClass, QualType(), false, false), InitExprs(C, numInits), LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), SyntacticForm(0), - UnionFieldInit(0), HadArrayRangeDesignator(false) -{ + UnionFieldInit(0), HadArrayRangeDesignator(false) +{ for (unsigned I = 0; I != numInits; ++I) { if (initExprs[I]->isTypeDependent()) TypeDependent = true; if (initExprs[I]->isValueDependent()) ValueDependent = true; } - + InitExprs.insert(C, InitExprs.end(), initExprs, initExprs+numInits); } @@ -1091,7 +1091,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1, if (getType()->isVoidType()) return false; const CastExpr *CE = cast(this); - + // If this is a cast to void or a constructor conversion, check the operand. // Otherwise, the result of the cast is unused. if (CE->getCastKind() == CastExpr::CK_ToVoid || @@ -1234,7 +1234,7 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { // Not an lvalue. return LV_InvalidExpression; } - + // C99 6.5.2.3p4 if (m->isArrow()) return LV_Valid; @@ -1242,8 +1242,8 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { if (BaseExp->getStmtClass() == ObjCPropertyRefExprClass || BaseExp->getStmtClass() == ObjCImplicitSetterGetterRefExprClass) return LV_SubObjCPropertySetting; - return - BaseExp->isLvalue(Ctx); + return + BaseExp->isLvalue(Ctx); } case UnaryOperatorClass: if (cast(this)->getOpcode() == UnaryOperator::Deref) @@ -1280,13 +1280,13 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { return BinOp->getRHS()->isLvalue(Ctx); // C++ [expr.mptr.oper]p6 - // The result of a .* expression is an lvalue only if its first operand is - // an lvalue and its second operand is a pointer to data member. + // The result of a .* expression is an lvalue only if its first operand is + // an lvalue and its second operand is a pointer to data member. if (BinOp->getOpcode() == BinaryOperator::PtrMemD && !BinOp->getType()->isFunctionType()) return BinOp->getLHS()->isLvalue(Ctx); - // The result of an ->* expression is an lvalue only if its second operand + // The result of an ->* expression is an lvalue only if its second operand // is a pointer to data member. if (BinOp->getOpcode() == BinaryOperator::PtrMemI && !BinOp->getType()->isFunctionType()) { @@ -1294,7 +1294,7 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { if (Ty->isMemberPointerType() && !Ty->isMemberFunctionPointerType()) return LV_Valid; } - + if (!BinOp->isAssignmentOp()) return LV_InvalidExpression; @@ -1365,7 +1365,7 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { // If this is a conversion to a class temporary, make a note of // that. - if (Ctx.getLangOptions().CPlusPlus && + if (Ctx.getLangOptions().CPlusPlus && cast(this)->getTypeAsWritten()->isRecordType()) return LV_ClassTemporary; @@ -1594,7 +1594,7 @@ bool Expr::isDefaultArgument() const { const Expr *E = this; while (const ImplicitCastExpr *ICE = dyn_cast(E)) E = ICE->getSubExprAsWritten(); - + return isa(E); } @@ -1617,7 +1617,7 @@ static const Expr *skipTemporaryBindingsAndNoOpCasts(const Expr *E) { else break; } - + return E; } @@ -1745,13 +1745,13 @@ bool Expr::isConstantInitializer(ASTContext &Ctx) const { // cast-to-union extension. if (getType()->isRecordType()) return cast(this)->getSubExpr()->isConstantInitializer(Ctx); - + // Integer->integer casts can be handled here, which is important for // things like (int)(&&x-&&y). Scary but true. if (getType()->isIntegerType() && cast(this)->getSubExpr()->getType()->isIntegerType()) return cast(this)->getSubExpr()->isConstantInitializer(Ctx); - + break; } return isEvaluatable(Ctx); @@ -1810,7 +1810,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { switch (E->getStmtClass()) { #define STMT(Node, Base) case Expr::Node##Class: #define EXPR(Node, Base) -#include "clang/AST/StmtNodes.def" +#include "clang/AST/StmtNodes.inc" case Expr::PredefinedExprClass: case Expr::FloatingLiteralClass: case Expr::ImaginaryLiteralClass: @@ -1902,7 +1902,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { Qualifiers Quals = Ctx.getCanonicalType(Dcl->getType()).getQualifiers(); if (Quals.hasVolatile() || !Quals.hasConst()) return ICEDiag(2, cast(E)->getLocation()); - + // Look for a declaration of this variable that has an initializer. const VarDecl *ID = 0; const Expr *Init = Dcl->getAnyInitializer(ID); @@ -2146,10 +2146,10 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx, case NPC_NeverValueDependent: assert(false && "Unexpected value dependent expression!"); // If the unthinkable happens, fall through to the safest alternative. - + case NPC_ValueDependentIsNull: return isTypeDependent() || getType()->isIntegralType(); - + case NPC_ValueDependentIsNotNull: return false; } @@ -2188,7 +2188,7 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx, return true; // This expression must be an integer type. - if (!getType()->isIntegerType() || + if (!getType()->isIntegerType() || (Ctx.getLangOptions().CPlusPlus && getType()->isEnumeralType())) return false; @@ -2222,14 +2222,14 @@ FieldDecl *Expr::getBitField() { bool Expr::refersToVectorElement() const { const Expr *E = this->IgnoreParens(); - + while (const ImplicitCastExpr *ICE = dyn_cast(E)) { if (ICE->isLvalueCast() && ICE->getCastKind() == CastExpr::CK_NoOp) E = ICE->getSubExpr()->IgnoreParens(); else break; } - + if (const ArraySubscriptExpr *ASE = dyn_cast(E)) return ASE->getBase()->getType()->isVectorType(); @@ -2307,7 +2307,7 @@ ObjCMessageExpr::ObjCMessageExpr(QualType T, SourceLocation SuperLoc, bool IsInstanceSuper, QualType SuperType, - Selector Sel, + Selector Sel, ObjCMethodDecl *Method, Expr **Args, unsigned NumArgs, SourceLocation RBracLoc) @@ -2317,7 +2317,7 @@ ObjCMessageExpr::ObjCMessageExpr(QualType T, HasMethod(Method != 0), SuperLoc(SuperLoc), SelectorOrMethod(reinterpret_cast(Method? Method : Sel.getAsOpaquePtr())), - LBracLoc(LBracLoc), RBracLoc(RBracLoc) + LBracLoc(LBracLoc), RBracLoc(RBracLoc) { setReceiverPointer(SuperType.getAsOpaquePtr()); if (NumArgs) @@ -2327,17 +2327,17 @@ ObjCMessageExpr::ObjCMessageExpr(QualType T, ObjCMessageExpr::ObjCMessageExpr(QualType T, SourceLocation LBracLoc, TypeSourceInfo *Receiver, - Selector Sel, + Selector Sel, ObjCMethodDecl *Method, Expr **Args, unsigned NumArgs, SourceLocation RBracLoc) : Expr(ObjCMessageExprClass, T, T->isDependentType(), - (T->isDependentType() || + (T->isDependentType() || hasAnyValueDependentArguments(Args, NumArgs))), NumArgs(NumArgs), Kind(Class), HasMethod(Method != 0), SelectorOrMethod(reinterpret_cast(Method? Method : Sel.getAsOpaquePtr())), - LBracLoc(LBracLoc), RBracLoc(RBracLoc) + LBracLoc(LBracLoc), RBracLoc(RBracLoc) { setReceiverPointer(Receiver); if (NumArgs) @@ -2347,17 +2347,17 @@ ObjCMessageExpr::ObjCMessageExpr(QualType T, ObjCMessageExpr::ObjCMessageExpr(QualType T, SourceLocation LBracLoc, Expr *Receiver, - Selector Sel, + Selector Sel, ObjCMethodDecl *Method, Expr **Args, unsigned NumArgs, SourceLocation RBracLoc) : Expr(ObjCMessageExprClass, T, Receiver->isTypeDependent(), - (Receiver->isTypeDependent() || + (Receiver->isTypeDependent() || hasAnyValueDependentArguments(Args, NumArgs))), NumArgs(NumArgs), Kind(Instance), HasMethod(Method != 0), SelectorOrMethod(reinterpret_cast(Method? Method : Sel.getAsOpaquePtr())), - LBracLoc(LBracLoc), RBracLoc(RBracLoc) + LBracLoc(LBracLoc), RBracLoc(RBracLoc) { setReceiverPointer(Receiver); if (NumArgs) @@ -2369,59 +2369,59 @@ ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, SourceLocation SuperLoc, bool IsInstanceSuper, QualType SuperType, - Selector Sel, + Selector Sel, ObjCMethodDecl *Method, Expr **Args, unsigned NumArgs, SourceLocation RBracLoc) { - unsigned Size = sizeof(ObjCMessageExpr) + sizeof(void *) + + unsigned Size = sizeof(ObjCMessageExpr) + sizeof(void *) + NumArgs * sizeof(Expr *); void *Mem = Context.Allocate(Size, llvm::AlignOf::Alignment); return new (Mem) ObjCMessageExpr(T, LBracLoc, SuperLoc, IsInstanceSuper, - SuperType, Sel, Method, Args, NumArgs, + SuperType, Sel, Method, Args, NumArgs, RBracLoc); } ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, SourceLocation LBracLoc, TypeSourceInfo *Receiver, - Selector Sel, + Selector Sel, ObjCMethodDecl *Method, Expr **Args, unsigned NumArgs, SourceLocation RBracLoc) { - unsigned Size = sizeof(ObjCMessageExpr) + sizeof(void *) + + unsigned Size = sizeof(ObjCMessageExpr) + sizeof(void *) + NumArgs * sizeof(Expr *); void *Mem = Context.Allocate(Size, llvm::AlignOf::Alignment); - return new (Mem) ObjCMessageExpr(T, LBracLoc, Receiver, Sel, Method, Args, + return new (Mem) ObjCMessageExpr(T, LBracLoc, Receiver, Sel, Method, Args, NumArgs, RBracLoc); } ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, SourceLocation LBracLoc, Expr *Receiver, - Selector Sel, + Selector Sel, ObjCMethodDecl *Method, Expr **Args, unsigned NumArgs, SourceLocation RBracLoc) { - unsigned Size = sizeof(ObjCMessageExpr) + sizeof(void *) + + unsigned Size = sizeof(ObjCMessageExpr) + sizeof(void *) + NumArgs * sizeof(Expr *); void *Mem = Context.Allocate(Size, llvm::AlignOf::Alignment); - return new (Mem) ObjCMessageExpr(T, LBracLoc, Receiver, Sel, Method, Args, + return new (Mem) ObjCMessageExpr(T, LBracLoc, Receiver, Sel, Method, Args, NumArgs, RBracLoc); } -ObjCMessageExpr *ObjCMessageExpr::CreateEmpty(ASTContext &Context, +ObjCMessageExpr *ObjCMessageExpr::CreateEmpty(ASTContext &Context, unsigned NumArgs) { - unsigned Size = sizeof(ObjCMessageExpr) + sizeof(void *) + + unsigned Size = sizeof(ObjCMessageExpr) + sizeof(void *) + NumArgs * sizeof(Expr *); void *Mem = Context.Allocate(Size, llvm::AlignOf::Alignment); return new (Mem) ObjCMessageExpr(EmptyShell(), NumArgs); } - + Selector ObjCMessageExpr::getSelector() const { if (HasMethod) return reinterpret_cast(SelectorOrMethod) ->getSelector(); - return Selector(SelectorOrMethod); + return Selector(SelectorOrMethod); } ObjCInterfaceDecl *ObjCMessageExpr::getReceiverInterface() const { @@ -2500,7 +2500,7 @@ IdentifierInfo *DesignatedInitExpr::Designator::getFieldName() { return getField()->getIdentifier(); } -DesignatedInitExpr::DesignatedInitExpr(ASTContext &C, QualType Ty, +DesignatedInitExpr::DesignatedInitExpr(ASTContext &C, QualType Ty, unsigned NumDesignators, const Designator *Designators, SourceLocation EqualOrColonLoc, diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index 67fd74c288..69e61c3953 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -27,7 +27,7 @@ static struct StmtClassNameTable { const char *Name; unsigned Counter; unsigned Size; -} StmtClassInfo[Stmt::lastExprConstant+1]; +} StmtClassInfo[Stmt::lastStmtConstant+1]; static StmtClassNameTable &getStmtInfoTableEntry(Stmt::StmtClass E) { static bool Initialized = false; @@ -36,11 +36,11 @@ static StmtClassNameTable &getStmtInfoTableEntry(Stmt::StmtClass E) { // Intialize the table on the first use. Initialized = true; -#define ABSTRACT_EXPR(CLASS, PARENT) +#define ABSTRACT(STMT) #define STMT(CLASS, PARENT) \ StmtClassInfo[(unsigned)Stmt::CLASS##Class].Name = #CLASS; \ StmtClassInfo[(unsigned)Stmt::CLASS##Class].Size = sizeof(CLASS); -#include "clang/AST/StmtNodes.def" +#include "clang/AST/StmtNodes.inc" return StmtClassInfo[E]; } @@ -55,13 +55,13 @@ void Stmt::PrintStats() { unsigned sum = 0; fprintf(stderr, "*** Stmt/Expr Stats:\n"); - for (int i = 0; i != Stmt::lastExprConstant+1; i++) { + for (int i = 0; i != Stmt::lastStmtConstant+1; i++) { if (StmtClassInfo[i].Name == 0) continue; sum += StmtClassInfo[i].Counter; } fprintf(stderr, " %d stmts/exprs total.\n", sum); sum = 0; - for (int i = 0; i != Stmt::lastExprConstant+1; i++) { + for (int i = 0; i != Stmt::lastStmtConstant+1; i++) { if (StmtClassInfo[i].Name == 0) continue; if (StmtClassInfo[i].Counter == 0) continue; fprintf(stderr, " %d %s, %d each (%d bytes)\n", @@ -164,7 +164,7 @@ void AsmStmt::setOutputsAndInputsAndClobbers(ASTContext &C, StringLiteral **Constraints, Stmt **Exprs, unsigned NumOutputs, - unsigned NumInputs, + unsigned NumInputs, StringLiteral **Clobbers, unsigned NumClobbers) { this->NumOutputs = NumOutputs; @@ -172,19 +172,19 @@ void AsmStmt::setOutputsAndInputsAndClobbers(ASTContext &C, this->NumClobbers = NumClobbers; unsigned NumExprs = NumOutputs + NumInputs; - + C.Deallocate(this->Names); this->Names = new (C) IdentifierInfo*[NumExprs]; std::copy(Names, Names + NumExprs, this->Names); - + C.Deallocate(this->Exprs); this->Exprs = new (C) Stmt*[NumExprs]; std::copy(Exprs, Exprs + NumExprs, this->Exprs); - + C.Deallocate(this->Constraints); this->Constraints = new (C) StringLiteral*[NumExprs]; std::copy(Constraints, Constraints + NumExprs, this->Constraints); - + C.Deallocate(this->Clobbers); this->Clobbers = new (C) StringLiteral*[NumClobbers]; std::copy(Clobbers, Clobbers + NumClobbers, this->Clobbers); @@ -242,7 +242,7 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl&Pieces, std::string CurStringPiece; bool HasVariants = !C.Target.hasNoAsmVariants(); - + while (1) { // Done with the string? if (CurPtr == StrEnd) { @@ -263,7 +263,7 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl&Pieces, CurStringPiece += CurChar; continue; } - + // Escaped "%" character in asm string. if (CurPtr == StrEnd) { // % at end of string is invalid (no escape). @@ -356,8 +356,8 @@ QualType CXXCatchStmt::getCaughtType() const { // Constructors //===----------------------------------------------------------------------===// -AsmStmt::AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, - bool isvolatile, bool msasm, +AsmStmt::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, @@ -367,7 +367,7 @@ AsmStmt::AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, , NumOutputs(numoutputs), NumInputs(numinputs), NumClobbers(numclobbers) { unsigned NumExprs = NumOutputs +NumInputs; - + Names = new (C) IdentifierInfo*[NumExprs]; std::copy(names, names + NumExprs, Names); @@ -402,31 +402,31 @@ ObjCAtTryStmt::ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, Stmts[0] = atTryStmt; for (unsigned I = 0; I != NumCatchStmts; ++I) Stmts[I + 1] = CatchStmts[I]; - + if (HasFinally) Stmts[NumCatchStmts + 1] = atFinallyStmt; } -ObjCAtTryStmt *ObjCAtTryStmt::Create(ASTContext &Context, - SourceLocation atTryLoc, +ObjCAtTryStmt *ObjCAtTryStmt::Create(ASTContext &Context, + SourceLocation atTryLoc, Stmt *atTryStmt, - Stmt **CatchStmts, + Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt) { - unsigned Size = sizeof(ObjCAtTryStmt) + + unsigned Size = sizeof(ObjCAtTryStmt) + (1 + NumCatchStmts + (atFinallyStmt != 0)) * sizeof(Stmt *); void *Mem = Context.Allocate(Size, llvm::alignof()); return new (Mem) ObjCAtTryStmt(atTryLoc, atTryStmt, CatchStmts, NumCatchStmts, atFinallyStmt); } -ObjCAtTryStmt *ObjCAtTryStmt::CreateEmpty(ASTContext &Context, +ObjCAtTryStmt *ObjCAtTryStmt::CreateEmpty(ASTContext &Context, unsigned NumCatchStmts, bool HasFinally) { - unsigned Size = sizeof(ObjCAtTryStmt) + + unsigned Size = sizeof(ObjCAtTryStmt) + (1 + NumCatchStmts + HasFinally) * sizeof(Stmt *); void *Mem = Context.Allocate(Size, llvm::alignof()); - return new (Mem) ObjCAtTryStmt(EmptyShell(), NumCatchStmts, HasFinally); + return new (Mem) ObjCAtTryStmt(EmptyShell(), NumCatchStmts, HasFinally); } SourceRange ObjCAtTryStmt::getSourceRange() const { @@ -437,12 +437,12 @@ SourceRange ObjCAtTryStmt::getSourceRange() const { EndLoc = getCatchStmt(NumCatchStmts - 1)->getLocEnd(); else EndLoc = getTryBody()->getLocEnd(); - + return SourceRange(AtTryLoc, EndLoc); } CXXTryStmt *CXXTryStmt::Create(ASTContext &C, SourceLocation tryLoc, - Stmt *tryBlock, Stmt **handlers, + Stmt *tryBlock, Stmt **handlers, unsigned numHandlers) { std::size_t Size = sizeof(CXXTryStmt); Size += ((numHandlers + 1) * sizeof(Stmt)); @@ -474,7 +474,7 @@ static void BranchDestroy(ASTContext &C, Stmt *S, Stmt **SubExprs, // the expressions referenced by the condition variable. for (Stmt **I = SubExprs, **E = SubExprs + NumExprs; I != E; ++I) if (Stmt *Child = *I) Child->Destroy(C); - + S->~Stmt(); C.Deallocate((void *) S); } @@ -517,7 +517,7 @@ void SwitchStmt::DoDestroy(ASTContext &C) { SC->Destroy(C); SC = Next; } - + BranchDestroy(C, this, SubExprs, END_EXPR); } @@ -527,12 +527,12 @@ void WhileStmt::DoDestroy(ASTContext &C) { void AsmStmt::DoDestroy(ASTContext &C) { DestroyChildren(C); - + C.Deallocate(Names); C.Deallocate(Constraints); C.Deallocate(Exprs); C.Deallocate(Clobbers); - + this->~AsmStmt(); C.Deallocate((void *)this); } diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 52f627d449..7ea760d664 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -89,7 +89,7 @@ namespace { void VisitStmt(Stmt *Node); #define STMT(CLASS, PARENT) \ void Visit##CLASS(CLASS *Node); -#include "clang/AST/StmtNodes.def" +#include "clang/AST/StmtNodes.inc" }; } @@ -477,7 +477,7 @@ void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) { OS << TemplateSpecializationType::PrintTemplateArgumentList( Node->getTemplateArgs(), Node->getNumTemplateArgs(), - Policy); + Policy); } void StmtPrinter::VisitDependentScopeDeclRefExpr( @@ -727,12 +727,12 @@ void StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) { IdentifierInfo *Id = ON.getFieldName(); if (!Id) continue; - + if (PrintedSomething) OS << "."; else PrintedSomething = true; - OS << Id->getName(); + OS << Id->getName(); } OS << ")"; } diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp index d45bb2f010..514385ccbc 100644 --- a/lib/AST/StmtProfile.cpp +++ b/lib/AST/StmtProfile.cpp @@ -36,7 +36,7 @@ namespace { void VisitStmt(Stmt *S); #define STMT(Node, Base) void Visit##Node(Node *S); -#include "clang/AST/StmtNodes.def" +#include "clang/AST/StmtNodes.inc" /// \brief Visit a declaration that is referenced within an expression /// or statement. @@ -279,13 +279,13 @@ void StmtProfiler::VisitOffsetOfExpr(OffsetOfExpr *S) { case OffsetOfExpr::OffsetOfNode::Identifier: ID.AddPointer(ON.getFieldName()); break; - + case OffsetOfExpr::OffsetOfNode::Base: // These nodes are implicit, and therefore don't need profiling. break; } } - + VisitExpr(S); } @@ -740,7 +740,7 @@ void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) { case TemplateArgument::Template: VisitTemplateName(Arg.getAsTemplate()); break; - + case TemplateArgument::Declaration: VisitDecl(Arg.getAsDecl()); break; diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 8658cfb028..38fe0319e5 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -178,7 +178,7 @@ private: void mangleTemplateArgs(TemplateName Template, const TemplateArgument *TemplateArgs, - unsigned NumTemplateArgs); + unsigned NumTemplateArgs); void mangleTemplateArgs(const TemplateParameterList &PL, const TemplateArgument *TemplateArgs, unsigned NumTemplateArgs); @@ -439,7 +439,7 @@ void CXXNameMangler::mangleUnscopedTemplateName(TemplateName Template) { // ::= if (TemplateDecl *TD = Template.getAsTemplateDecl()) return mangleUnscopedTemplateName(TD); - + if (mangleSubstitution(Template)) return; @@ -454,7 +454,7 @@ void CXXNameMangler::mangleUnscopedTemplateName(TemplateName Template) { Diags.Report(FullSourceLoc(), DiagID); return; } - + mangleSourceName(Dependent->getIdentifier()); addSubstitution(Template); } @@ -506,7 +506,7 @@ void CXXNameMangler::mangleUnresolvedScope(NestedNameSpecifier *Qualifier) { dyn_cast(QTy)) { if (!mangleSubstitution(QualType(TST, 0))) { mangleTemplatePrefix(TST->getTemplateName()); - + // FIXME: GCC does not appear to mangle the template arguments when // the template in question is a dependent template name. Should we // emulate that badness? @@ -781,14 +781,14 @@ void CXXNameMangler::mangleTemplatePrefix(TemplateName Template) { if (QualifiedTemplateName *Qualified = Template.getAsQualifiedTemplateName()) mangleUnresolvedScope(Qualified->getQualifier()); - + if (OverloadedTemplateStorage *Overloaded = Template.getAsOverloadedTemplate()) { - mangleUnqualifiedName(0, (*Overloaded->begin())->getDeclName(), + mangleUnqualifiedName(0, (*Overloaded->begin())->getDeclName(), UnknownArity); return; } - + DependentTemplateName *Dependent = Template.getAsDependentTemplateName(); assert(Dependent && "Unknown template name kind?"); mangleUnresolvedScope(Dependent->getQualifier()); @@ -1224,9 +1224,9 @@ void CXXNameMangler::mangleType(const TemplateSpecializationType *T) { } else { if (mangleSubstitution(QualType(T, 0))) return; - + mangleTemplatePrefix(T->getTemplateName()); - + // FIXME: GCC does not appear to mangle the template arguments when // the template in question is a dependent template name. Should we // emulate that badness? @@ -1245,16 +1245,16 @@ void CXXNameMangler::mangleType(const DependentNameType *T) { const TemplateSpecializationType *TST = T->getTemplateId(); if (!mangleSubstitution(QualType(TST, 0))) { mangleTemplatePrefix(TST->getTemplateName()); - + // FIXME: GCC does not appear to mangle the template arguments when // the template in question is a dependent template name. Should we // emulate that badness? mangleTemplateArgs(TST->getTemplateName(), TST->getArgs(), - TST->getNumArgs()); + TST->getNumArgs()); addSubstitution(QualType(TST, 0)); } } - + Out << 'E'; } @@ -1369,7 +1369,7 @@ void CXXNameMangler::mangleExpression(const Expr *E) { #define EXPR(Type, Base) #define STMT(Type, Base) \ case Expr::Type##Class: -#include "clang/AST/StmtNodes.def" +#include "clang/AST/StmtNodes.inc" llvm_unreachable("unexpected statement kind"); break; @@ -1668,7 +1668,7 @@ void CXXNameMangler::mangleTemplateArgs(TemplateName Template, if (TemplateDecl *TD = Template.getAsTemplateDecl()) return mangleTemplateArgs(*TD->getTemplateParameters(), TemplateArgs, NumTemplateArgs); - + // ::= I + E Out << 'I'; for (unsigned i = 0; i != NumTemplateArgs; ++i) @@ -1791,7 +1791,7 @@ bool CXXNameMangler::mangleSubstitution(QualType T) { bool CXXNameMangler::mangleSubstitution(TemplateName Template) { if (TemplateDecl *TD = Template.getAsTemplateDecl()) return mangleSubstitution(TD); - + Template = Context.getASTContext().getCanonicalTemplateName(Template); return mangleSubstitution( reinterpret_cast(Template.getAsVoidPointer())); @@ -1978,7 +1978,7 @@ void CXXNameMangler::addSubstitution(QualType T) { void CXXNameMangler::addSubstitution(TemplateName Template) { if (TemplateDecl *TD = Template.getAsTemplateDecl()) return addSubstitution(TD); - + Template = Context.getASTContext().getCanonicalTemplateName(Template); addSubstitution(reinterpret_cast(Template.getAsVoidPointer())); } @@ -2036,38 +2036,38 @@ void MangleContext::mangleThunk(const CXXMethodDecl *MD, // # base is the nominal target function of thunk // # first call-offset is 'this' adjustment // # second call-offset is result adjustment - + assert(!isa(MD) && "Use mangleCXXDtor for destructor decls!"); - + CXXNameMangler Mangler(*this, Res); Mangler.getStream() << "_ZT"; if (!Thunk.Return.isEmpty()) Mangler.getStream() << 'c'; - + // Mangle the 'this' pointer adjustment. Mangler.mangleCallOffset(Thunk.This.NonVirtual, Thunk.This.VCallOffsetOffset); - + // Mangle the return pointer adjustment if there is one. if (!Thunk.Return.isEmpty()) Mangler.mangleCallOffset(Thunk.Return.NonVirtual, Thunk.Return.VBaseOffsetOffset); - + Mangler.mangleFunctionEncoding(MD); } -void +void MangleContext::mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, const ThisAdjustment &ThisAdjustment, llvm::SmallVectorImpl &Res) { // ::= T // # base is the nominal target function of thunk - + CXXNameMangler Mangler(*this, Res, DD, Type); Mangler.getStream() << "_ZT"; // Mangle the 'this' pointer adjustment. - Mangler.mangleCallOffset(ThisAdjustment.NonVirtual, + Mangler.mangleCallOffset(ThisAdjustment.NonVirtual, ThisAdjustment.VCallOffsetOffset); Mangler.mangleFunctionEncoding(DD); diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 5ce268bd9e..e412fd2099 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -96,7 +96,7 @@ public: typedef Sema::MultiExprArg MultiExprArg; typedef Sema::MultiStmtArg MultiStmtArg; typedef Sema::DeclPtrTy DeclPtrTy; - + /// \brief Initializes a new tree transformer. TreeTransform(Sema &SemaRef) : SemaRef(SemaRef) { } @@ -181,7 +181,7 @@ public: bool DropCallArgument(Expr *E) { return E->isDefaultArgument(); } - + /// \brief Transforms the given type into another type. /// /// By default, this routine transforms a type by creating a @@ -201,14 +201,14 @@ public: /// may override this function (to take over all type /// transformations) or some set of the TransformXXXType functions /// to alter the transformation. - TypeSourceInfo *TransformType(TypeSourceInfo *DI, + TypeSourceInfo *TransformType(TypeSourceInfo *DI, QualType ObjectType = QualType()); /// \brief Transform the given type-with-location into a new /// type, collecting location information in the given builder /// as necessary. /// - QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL, + QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL, QualType ObjectType = QualType()); /// \brief Transform the given statement. @@ -243,23 +243,23 @@ public: /// /// By default, invokes TransformDecl() to transform the declaration. /// Subclasses may override this function to provide alternate behavior. - Decl *TransformDefinition(SourceLocation Loc, Decl *D) { - return getDerived().TransformDecl(Loc, D); + Decl *TransformDefinition(SourceLocation Loc, Decl *D) { + return getDerived().TransformDecl(Loc, D); } /// \brief Transform the given declaration, which was the first part of a /// nested-name-specifier in a member access expression. /// - /// This specific declaration transformation only applies to the first + /// This specific declaration transformation only applies to the first /// identifier in a nested-name-specifier of a member access expression, e.g., /// the \c T in \c x->T::member /// /// By default, invokes TransformDecl() to transform the declaration. /// Subclasses may override this function to provide alternate behavior. - NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc) { - return cast_or_null(getDerived().TransformDecl(Loc, D)); + NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc) { + return cast_or_null(getDerived().TransformDecl(Loc, D)); } - + /// \brief Transform the given nested-name-specifier. /// /// By default, transforms all of the types and declarations within the @@ -330,10 +330,10 @@ public: /// on error. ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm); - QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL, + QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL, QualType ObjectType); - QualType + QualType TransformTemplateSpecializationType(const TemplateSpecializationType *T, QualType ObjectType); @@ -344,8 +344,8 @@ public: OwningStmtResult Transform##Node(Node *S); #define EXPR(Node, Parent) \ OwningExprResult Transform##Node(Node *E); -#define ABSTRACT_EXPR(Node, Parent) -#include "clang/AST/StmtNodes.def" +#define ABSTRACT(Stmt) +#include "clang/AST/StmtNodes.inc" /// \brief Build a new pointer type given its pointee type. /// @@ -534,7 +534,7 @@ public: /// \brief Build a new typename type that refers to a template-id. /// - /// By default, builds a new DependentNameType type from the + /// By default, builds a new DependentNameType type from the /// nested-name-specifier /// and the given type. Subclasses may override this routine to provide /// different behavior. @@ -548,7 +548,7 @@ public: return SemaRef.Context.getDependentNameType(Keyword, NNS, cast(T)); } - + // FIXME: Handle elaborated-type-specifiers separately. return SemaRef.Context.getQualifiedNameType(NNS, T); } @@ -558,13 +558,13 @@ public: /// By default, performs semantic analysis when building the typename type /// (or qualified name type). Subclasses may override this routine to provide /// different behavior. - QualType RebuildDependentNameType(ElaboratedTypeKeyword Keyword, + QualType RebuildDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Id, SourceRange SR) { CXXScopeSpec SS; SS.setScopeRep(NNS); - + if (NNS->isDependent()) { // If the name is still dependent, just build a new dependent name type. if (!SemaRef.computeDeclContext(SS)) @@ -577,13 +577,13 @@ public: // Fall through. case ETK_Typename: return SemaRef.CheckTypenameType(Keyword, NNS, *Id, SR); - + case ETK_Class: Kind = TagDecl::TK_class; break; case ETK_Struct: Kind = TagDecl::TK_struct; break; case ETK_Union: Kind = TagDecl::TK_union; break; case ETK_Enum: Kind = TagDecl::TK_enum; break; } - + // We had a dependent elaborated-type-specifier that as been transformed // into a non-dependent elaborated-type-specifier. Find the tag we're // referring to. @@ -598,16 +598,16 @@ public: case LookupResult::NotFound: case LookupResult::NotFoundInCurrentInstantiation: break; - + case LookupResult::Found: Tag = Result.getAsSingle(); break; - + case LookupResult::FoundOverloaded: case LookupResult::FoundUnresolvedValue: llvm_unreachable("Tag lookup cannot find non-tags"); return QualType(); - + case LookupResult::Ambiguous: // Let the LookupResult structure handle ambiguities. return QualType(); @@ -619,7 +619,7 @@ public: << Kind << Id << DC; return QualType(); } - + // FIXME: Terrible location information if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, SR.getEnd(), *Id)) { SemaRef.Diag(SR.getBegin(), diag::err_use_with_wrong_tag) << Id; @@ -697,7 +697,7 @@ public: TemplateName RebuildTemplateName(NestedNameSpecifier *Qualifier, OverloadedOperatorKind Operator, QualType ObjectType); - + /// \brief Build a new compound statement. /// /// By default, performs semantic analysis to build the new statement. @@ -759,9 +759,9 @@ public: /// By default, performs semantic analysis to build the new statement. /// Subclasses may override this routine to provide different behavior. OwningStmtResult RebuildIfStmt(SourceLocation IfLoc, Sema::FullExprArg Cond, - VarDecl *CondVar, StmtArg Then, + VarDecl *CondVar, StmtArg Then, SourceLocation ElseLoc, StmtArg Else) { - return getSema().ActOnIfStmt(IfLoc, Cond, DeclPtrTy::make(CondVar), + return getSema().ActOnIfStmt(IfLoc, Cond, DeclPtrTy::make(CondVar), move(Then), ElseLoc, move(Else)); } @@ -769,7 +769,7 @@ public: /// /// By default, performs semantic analysis to build the new statement. /// Subclasses may override this routine to provide different behavior. - OwningStmtResult RebuildSwitchStmtStart(Sema::FullExprArg Cond, + OwningStmtResult RebuildSwitchStmtStart(Sema::FullExprArg Cond, VarDecl *CondVar) { return getSema().ActOnStartOfSwitchStmt(Cond, DeclPtrTy::make(CondVar)); } @@ -815,10 +815,10 @@ public: /// Subclasses may override this routine to provide different behavior. OwningStmtResult RebuildForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, - StmtArg Init, Sema::FullExprArg Cond, + StmtArg Init, Sema::FullExprArg Cond, VarDecl *CondVar, Sema::FullExprArg Inc, SourceLocation RParenLoc, StmtArg Body) { - return getSema().ActOnForStmt(ForLoc, LParenLoc, move(Init), Cond, + return getSema().ActOnForStmt(ForLoc, LParenLoc, move(Init), Cond, DeclPtrTy::make(CondVar), Inc, RParenLoc, move(Body)); } @@ -883,7 +883,7 @@ public: MultiExprArg Clobbers, SourceLocation RParenLoc, bool MSAsm) { - return getSema().ActOnAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs, + return getSema().ActOnAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs, Names, move(Constraints), move(Exprs), move(AsmString), move(Clobbers), RParenLoc, MSAsm); @@ -907,11 +907,11 @@ public: /// Subclasses may override this routine to provide different behavior. VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *TInfo, QualType T) { - return getSema().BuildObjCExceptionDecl(TInfo, T, - ExceptionDecl->getIdentifier(), + return getSema().BuildObjCExceptionDecl(TInfo, T, + ExceptionDecl->getIdentifier(), ExceptionDecl->getLocation()); } - + /// \brief Build a new Objective-C @catch statement. /// /// By default, performs semantic analysis to build the new statement. @@ -924,7 +924,7 @@ public: Sema::DeclPtrTy::make(Var), move(Body)); } - + /// \brief Build a new Objective-C @finally statement. /// /// By default, performs semantic analysis to build the new statement. @@ -933,7 +933,7 @@ public: StmtArg Body) { return getSema().ActOnObjCAtFinallyStmt(AtLoc, move(Body)); } - + /// \brief Build a new Objective-C @throw statement. /// /// By default, performs semantic analysis to build the new statement. @@ -942,7 +942,7 @@ public: ExprArg Operand) { return getSema().BuildObjCAtThrowStmt(AtLoc, move(Operand)); } - + /// \brief Build a new Objective-C @synchronized statement. /// /// By default, performs semantic analysis to build the new statement. @@ -965,12 +965,12 @@ public: SourceLocation RParenLoc, StmtArg Body) { return getSema().ActOnObjCForCollectionStmt(ForLoc, LParenLoc, - move(Element), + move(Element), move(Collection), RParenLoc, move(Body)); } - + /// \brief Build a new C++ exception declaration. /// /// By default, performs semantic analysis to build the new decaration. @@ -1030,7 +1030,7 @@ public: SS.setRange(QualifierRange); // FIXME: loses template args. - + return getSema().BuildDeclarationNameExpr(SS, Loc, VD); } @@ -1079,7 +1079,7 @@ public: return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components, NumComponents, RParenLoc); } - + /// \brief Build a new sizeof or alignof expression with a type argument. /// /// By default, performs semantic analysis to build the new expression. @@ -1189,7 +1189,7 @@ public: OwningExprResult RebuildBinaryOperator(SourceLocation OpLoc, BinaryOperator::Opcode Opc, ExprArg LHS, ExprArg RHS) { - return getSema().BuildBinOp(/*Scope=*/0, OpLoc, Opc, + return getSema().BuildBinOp(/*Scope=*/0, OpLoc, Opc, LHS.takeAs(), RHS.takeAs()); } @@ -1261,7 +1261,7 @@ public: = SemaRef.ActOnInitList(LBraceLoc, move(Inits), RBraceLoc); if (Result.isInvalid() || ResultTy->isDependentType()) return move(Result); - + // Patch in the result type we were given, which may have been computed // when the initial InitListExpr was built. InitListExpr *ILE = cast((Expr *)Result.get()); @@ -1314,7 +1314,7 @@ public: OwningExprResult RebuildParenListExpr(SourceLocation LParenLoc, MultiExprArg SubExprs, SourceLocation RParenLoc) { - return getSema().ActOnParenOrParenListExpr(LParenLoc, RParenLoc, + return getSema().ActOnParenOrParenListExpr(LParenLoc, RParenLoc, move(SubExprs)); } @@ -1516,7 +1516,7 @@ public: SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc) { - return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand, + return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand, RParenLoc); } @@ -1558,7 +1558,7 @@ public: /// By default, builds a new default-argument expression, which does not /// require any semantic analysis. Subclasses may override this routine to /// provide different behavior. - OwningExprResult RebuildCXXDefaultArgExpr(SourceLocation Loc, + OwningExprResult RebuildCXXDefaultArgExpr(SourceLocation Loc, ParmVarDecl *Param) { return getSema().Owned(CXXDefaultArgExpr::Create(getSema().Context, Loc, Param)); @@ -1676,10 +1676,10 @@ public: bool IsElidable, MultiExprArg Args) { ASTOwningVector<&ActionBase::DeleteExpr> ConvertedArgs(SemaRef); - if (getSema().CompleteConstructorCall(Constructor, move(Args), Loc, + if (getSema().CompleteConstructorCall(Constructor, move(Args), Loc, ConvertedArgs)) return getSema().ExprError(); - + return getSema().BuildCXXConstructExpr(Loc, T, Constructor, IsElidable, move_arg(ConvertedArgs)); } @@ -1783,7 +1783,7 @@ public: OwningExprResult RebuildObjCMessageExpr(TypeSourceInfo *ReceiverTypeInfo, Selector Sel, ObjCMethodDecl *Method, - SourceLocation LBracLoc, + SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc) { return SemaRef.BuildClassMessage(ReceiverTypeInfo, @@ -1797,7 +1797,7 @@ public: OwningExprResult RebuildObjCMessageExpr(ExprArg Receiver, Selector Sel, ObjCMethodDecl *Method, - SourceLocation LBracLoc, + SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc) { QualType ReceiverType = static_cast(Receiver.get())->getType(); @@ -1825,15 +1825,15 @@ public: SS, DeclPtrTy()); if (Result.isInvalid()) return getSema().ExprError(); - + if (Result.get()) return move(Result); - - return getSema().BuildMemberReferenceExpr(getSema().Owned(Base), + + return getSema().BuildMemberReferenceExpr(getSema().Owned(Base), Base->getType(), - /*FIXME:*/IvarLoc, IsArrow, SS, + /*FIXME:*/IvarLoc, IsArrow, SS, /*FirstQualifierInScope=*/0, - R, + R, /*TemplateArgs=*/0); } @@ -1841,7 +1841,7 @@ public: /// /// By default, performs semantic analysis to build the new expression. /// Subclasses may override this routine to provide different behavior. - OwningExprResult RebuildObjCPropertyRefExpr(ExprArg BaseArg, + OwningExprResult RebuildObjCPropertyRefExpr(ExprArg BaseArg, ObjCPropertyDecl *Property, SourceLocation PropertyLoc) { CXXScopeSpec SS; @@ -1854,24 +1854,24 @@ public: SS, DeclPtrTy()); if (Result.isInvalid()) return getSema().ExprError(); - + if (Result.get()) return move(Result); - - return getSema().BuildMemberReferenceExpr(getSema().Owned(Base), + + return getSema().BuildMemberReferenceExpr(getSema().Owned(Base), Base->getType(), - /*FIXME:*/PropertyLoc, IsArrow, - SS, + /*FIXME:*/PropertyLoc, IsArrow, + SS, /*FirstQualifierInScope=*/0, - R, + R, /*TemplateArgs=*/0); } - - /// \brief Build a new Objective-C implicit setter/getter reference + + /// \brief Build a new Objective-C implicit setter/getter reference /// expression. /// /// By default, performs semantic analysis to build the new expression. - /// Subclasses may override this routine to provide different behavior. + /// Subclasses may override this routine to provide different behavior. OwningExprResult RebuildObjCImplicitSetterGetterRefExpr( ObjCMethodDecl *Getter, QualType T, @@ -1902,18 +1902,18 @@ public: SS, DeclPtrTy()); if (Result.isInvalid()) return getSema().ExprError(); - + if (Result.get()) return move(Result); - - return getSema().BuildMemberReferenceExpr(getSema().Owned(Base), + + return getSema().BuildMemberReferenceExpr(getSema().Owned(Base), Base->getType(), - /*FIXME:*/IsaLoc, IsArrow, SS, + /*FIXME:*/IsaLoc, IsArrow, SS, /*FirstQualifierInScope=*/0, - R, + R, /*TemplateArgs=*/0); } - + /// \brief Build a new shuffle vector expression. /// /// By default, performs semantic analysis to build the new expression. @@ -1966,13 +1966,13 @@ Sema::OwningStmtResult TreeTransform::TransformStmt(Stmt *S) { #define STMT(Node, Parent) \ case Stmt::Node##Class: return getDerived().Transform##Node(cast(S)); #define EXPR(Node, Parent) -#include "clang/AST/StmtNodes.def" +#include "clang/AST/StmtNodes.inc" // Transform expressions by calling TransformExpr. #define STMT(Node, Parent) -#define ABSTRACT_EXPR(Node, Parent) +#define ABSTRACT(Stmt) #define EXPR(Node, Parent) case Stmt::Node##Class: -#include "clang/AST/StmtNodes.def" +#include "clang/AST/StmtNodes.inc" { Sema::OwningExprResult E = getDerived().TransformExpr(cast(S)); if (E.isInvalid()) @@ -1994,10 +1994,10 @@ Sema::OwningExprResult TreeTransform::TransformExpr(Expr *E) { switch (E->getStmtClass()) { case Stmt::NoStmtClass: break; #define STMT(Node, Parent) case Stmt::Node##Class: break; -#define ABSTRACT_EXPR(Node, Parent) +#define ABSTRACT(Stmt) #define EXPR(Node, Parent) \ case Stmt::Node##Class: return getDerived().Transform##Node(cast(E)); -#include "clang/AST/StmtNodes.def" +#include "clang/AST/StmtNodes.inc" } return SemaRef.Owned(E->Retain()); @@ -2103,7 +2103,7 @@ TreeTransform::TransformDeclarationName(DeclarationName Name, case DeclarationName::CXXDestructorName: case DeclarationName::CXXConversionFunctionName: { TemporaryBase Rebase(*this, Loc, Name); - QualType T = getDerived().TransformType(Name.getCXXNameType(), + QualType T = getDerived().TransformType(Name.getCXXNameType(), ObjectType); if (T.isNull()) return DeclarationName(); @@ -2164,10 +2164,10 @@ TreeTransform::TransformTemplateName(TemplateName Name, return Name; if (DTN->isIdentifier()) - return getDerived().RebuildTemplateName(NNS, *DTN->getIdentifier(), + return getDerived().RebuildTemplateName(NNS, *DTN->getIdentifier(), ObjectType); - - return getDerived().RebuildTemplateName(NNS, DTN->getOperator(), + + return getDerived().RebuildTemplateName(NNS, DTN->getOperator(), ObjectType); } @@ -2202,13 +2202,13 @@ void TreeTransform::InventTemplateArgumentLoc( case TemplateArgument::Type: Output = TemplateArgumentLoc(Arg, SemaRef.Context.getTrivialTypeSourceInfo(Arg.getAsType(), Loc)); - + break; case TemplateArgument::Template: Output = TemplateArgumentLoc(Arg, SourceRange(), Loc); break; - + case TemplateArgument::Expression: Output = TemplateArgumentLoc(Arg, Arg.getAsExpr()); break; @@ -2271,18 +2271,18 @@ bool TreeTransform::TransformTemplateArgument( } case TemplateArgument::Template: { - TemporaryBase Rebase(*this, Input.getLocation(), DeclarationName()); + TemporaryBase Rebase(*this, Input.getLocation(), DeclarationName()); TemplateName Template = getDerived().TransformTemplateName(Arg.getAsTemplate()); if (Template.isNull()) return true; - + Output = TemplateArgumentLoc(TemplateArgument(Template), Input.getTemplateQualifierRange(), Input.getTemplateNameLoc()); return false; } - + case TemplateArgument::Expression: { // Template argument expressions are not potentially evaluated. EnterExpressionEvaluationContext Unevaluated(getSema(), @@ -2336,7 +2336,7 @@ bool TreeTransform::TransformTemplateArgument( //===----------------------------------------------------------------------===// template -QualType TreeTransform::TransformType(QualType T, +QualType TreeTransform::TransformType(QualType T, QualType ObjectType) { if (getDerived().AlreadyTransformed(T)) return T; @@ -2345,7 +2345,7 @@ QualType TreeTransform::TransformType(QualType T, // eventually turn into transformations on TypeLocs. TypeSourceInfo *DI = getSema().Context.CreateTypeSourceInfo(T); DI->getTypeLoc().initialize(getDerived().getBaseLocation()); - + TypeSourceInfo *NewDI = getDerived().TransformType(DI, ObjectType); if (!NewDI) @@ -2449,10 +2449,10 @@ QualType TreeTransform::TransformComplexType(TypeLocBuilder &TLB, template QualType TreeTransform::TransformPointerType(TypeLocBuilder &TLB, - PointerTypeLoc TL, + PointerTypeLoc TL, QualType ObjectType) { - QualType PointeeType - = getDerived().TransformType(TLB, TL.getPointeeLoc()); + QualType PointeeType + = getDerived().TransformType(TLB, TL.getPointeeLoc()); if (PointeeType.isNull()) return QualType(); @@ -2467,26 +2467,26 @@ QualType TreeTransform::TransformPointerType(TypeLocBuilder &TLB, const_cast( IFace->qual_begin()), IFace->getNumProtocols()); - - ObjCObjectPointerTypeLoc NewT = TLB.push(Result); - NewT.setStarLoc(TL.getSigilLoc()); + + ObjCObjectPointerTypeLoc NewT = TLB.push(Result); + NewT.setStarLoc(TL.getSigilLoc()); NewT.setHasProtocolsAsWritten(false); NewT.setLAngleLoc(SourceLocation()); NewT.setRAngleLoc(SourceLocation()); NewT.setHasBaseTypeAsWritten(true); return Result; } - + if (getDerived().AlwaysRebuild() || PointeeType != TL.getPointeeLoc().getType()) { Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc()); if (Result.isNull()) return QualType(); } - + PointerTypeLoc NewT = TLB.push(Result); NewT.setSigilLoc(TL.getSigilLoc()); - return Result; + return Result; } template @@ -2495,14 +2495,14 @@ TreeTransform::TransformBlockPointerType(TypeLocBuilder &TLB, BlockPointerTypeLoc TL, QualType ObjectType) { QualType PointeeType - = getDerived().TransformType(TLB, TL.getPointeeLoc()); - if (PointeeType.isNull()) - return QualType(); - - QualType Result = TL.getType(); - if (getDerived().AlwaysRebuild() || - PointeeType != TL.getPointeeLoc().getType()) { - Result = getDerived().RebuildBlockPointerType(PointeeType, + = getDerived().TransformType(TLB, TL.getPointeeLoc()); + if (PointeeType.isNull()) + return QualType(); + + QualType Result = TL.getType(); + if (getDerived().AlwaysRebuild() || + PointeeType != TL.getPointeeLoc().getType()) { + Result = getDerived().RebuildBlockPointerType(PointeeType, TL.getSigilLoc()); if (Result.isNull()) return QualType(); @@ -2620,7 +2620,7 @@ TreeTransform::TransformConstantArrayType(TypeLocBuilder &TLB, if (Result.isNull()) return QualType(); } - + ConstantArrayTypeLoc NewTL = TLB.push(Result); NewTL.setLBracketLoc(TL.getLBracketLoc()); NewTL.setRBracketLoc(TL.getRBracketLoc()); @@ -2655,7 +2655,7 @@ QualType TreeTransform::TransformIncompleteArrayType( if (Result.isNull()) return QualType(); } - + IncompleteArrayTypeLoc NewTL = TLB.push(Result); NewTL.setLBracketLoc(TL.getLBracketLoc()); NewTL.setRBracketLoc(TL.getRBracketLoc()); @@ -2697,7 +2697,7 @@ TreeTransform::TransformVariableArrayType(TypeLocBuilder &TLB, return QualType(); } else SizeResult.take(); - + VariableArrayTypeLoc NewTL = TLB.push(Result); NewTL.setLBracketLoc(TL.getLBracketLoc()); NewTL.setRBracketLoc(TL.getRBracketLoc()); @@ -2811,7 +2811,7 @@ QualType TreeTransform::TransformVectorType(TypeLocBuilder &TLB, if (Result.isNull()) return QualType(); } - + VectorTypeLoc NewTL = TLB.push(Result); NewTL.setNameLoc(TL.getNameLoc()); @@ -2836,7 +2836,7 @@ QualType TreeTransform::TransformExtVectorType(TypeLocBuilder &TLB, if (Result.isNull()) return QualType(); } - + ExtVectorTypeLoc NewTL = TLB.push(Result); NewTL.setNameLoc(TL.getNameLoc()); @@ -2914,12 +2914,12 @@ TreeTransform::TransformFunctionProtoType(TypeLocBuilder &TLB, llvm::SmallVector ParamDecls; if (getDerived().TransformFunctionTypeParams(TL, ParamTypes, ParamDecls)) return QualType(); - + FunctionProtoType *T = TL.getTypePtr(); QualType ResultType = getDerived().TransformType(TLB, TL.getResultLoc()); if (ResultType.isNull()) return QualType(); - + QualType Result = TL.getType(); if (getDerived().AlwaysRebuild() || ResultType != T->getResultType() || @@ -3227,7 +3227,7 @@ QualType TreeTransform::TransformTemplateSpecializationType( TypeLocBuilder IgnoredTLB; return TransformTemplateSpecializationType(IgnoredTLB, TL, ObjectType); } - + template QualType TreeTransform::TransformTemplateSpecializationType( TypeLocBuilder &TLB, @@ -3331,10 +3331,10 @@ QualType TreeTransform::TransformDependentNameType(TypeLocBuilder &TLB, NewTemplateId == QualType(TemplateId, 0)) return QualType(T, 0); - Result = getDerived().RebuildDependentNameType(T->getKeyword(), NNS, + Result = getDerived().RebuildDependentNameType(T->getKeyword(), NNS, NewTemplateId); } else { - Result = getDerived().RebuildDependentNameType(T->getKeyword(), NNS, + Result = getDerived().RebuildDependentNameType(T->getKeyword(), NNS, T->getIdentifier(), SR); } if (Result.isNull()) @@ -3477,7 +3477,7 @@ TreeTransform::TransformIfStmt(IfStmt *S) { OwningExprResult Cond(SemaRef); VarDecl *ConditionVar = 0; if (S->getConditionVariable()) { - ConditionVar + ConditionVar = cast_or_null( getDerived().TransformDefinition( S->getConditionVariable()->getLocation(), @@ -3486,11 +3486,11 @@ TreeTransform::TransformIfStmt(IfStmt *S) { return SemaRef.StmtError(); } else { Cond = getDerived().TransformExpr(S->getCond()); - + if (Cond.isInvalid()) return SemaRef.StmtError(); } - + Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond)); // Transform the "then" branch. @@ -3522,7 +3522,7 @@ TreeTransform::TransformSwitchStmt(SwitchStmt *S) { OwningExprResult Cond(SemaRef); VarDecl *ConditionVar = 0; if (S->getConditionVariable()) { - ConditionVar + ConditionVar = cast_or_null( getDerived().TransformDefinition( S->getConditionVariable()->getLocation(), @@ -3531,13 +3531,13 @@ TreeTransform::TransformSwitchStmt(SwitchStmt *S) { return SemaRef.StmtError(); } else { Cond = getDerived().TransformExpr(S->getCond()); - + if (Cond.isInvalid()) return SemaRef.StmtError(); } Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond)); - + // Rebuild the switch statement. OwningStmtResult Switch = getDerived().RebuildSwitchStmtStart(FullCond, ConditionVar); @@ -3561,7 +3561,7 @@ TreeTransform::TransformWhileStmt(WhileStmt *S) { OwningExprResult Cond(SemaRef); VarDecl *ConditionVar = 0; if (S->getConditionVariable()) { - ConditionVar + ConditionVar = cast_or_null( getDerived().TransformDefinition( S->getConditionVariable()->getLocation(), @@ -3570,7 +3570,7 @@ TreeTransform::TransformWhileStmt(WhileStmt *S) { return SemaRef.StmtError(); } else { Cond = getDerived().TransformExpr(S->getCond()); - + if (Cond.isInvalid()) return SemaRef.StmtError(); } @@ -3627,7 +3627,7 @@ TreeTransform::TransformForStmt(ForStmt *S) { OwningExprResult Cond(SemaRef); VarDecl *ConditionVar = 0; if (S->getConditionVariable()) { - ConditionVar + ConditionVar = cast_or_null( getDerived().TransformDefinition( S->getConditionVariable()->getLocation(), @@ -3636,7 +3636,7 @@ TreeTransform::TransformForStmt(ForStmt *S) { return SemaRef.StmtError(); } else { Cond = getDerived().TransformExpr(S->getCond()); - + if (Cond.isInvalid()) return SemaRef.StmtError(); } @@ -3747,7 +3747,7 @@ TreeTransform::TransformSwitchCase(SwitchCase *S) { template Sema::OwningStmtResult TreeTransform::TransformAsmStmt(AsmStmt *S) { - + ASTOwningVector<&ActionBase::DeleteExpr> Constraints(getSema()); ASTOwningVector<&ActionBase::DeleteExpr> Exprs(getSema()); llvm::SmallVector Names; @@ -3756,43 +3756,43 @@ TreeTransform::TransformAsmStmt(AsmStmt *S) { ASTOwningVector<&ActionBase::DeleteExpr> Clobbers(getSema()); bool ExprsChanged = false; - + // Go through the outputs. for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) { Names.push_back(S->getOutputIdentifier(I)); - + // No need to transform the constraint literal. Constraints.push_back(S->getOutputConstraintLiteral(I)->Retain()); - + // Transform the output expr. Expr *OutputExpr = S->getOutputExpr(I); OwningExprResult Result = getDerived().TransformExpr(OutputExpr); if (Result.isInvalid()) return SemaRef.StmtError(); - + ExprsChanged |= Result.get() != OutputExpr; - + Exprs.push_back(Result.takeAs()); } - + // Go through the inputs. for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) { Names.push_back(S->getInputIdentifier(I)); - + // No need to transform the constraint literal. Constraints.push_back(S->getInputConstraintLiteral(I)->Retain()); - + // Transform the input expr. Expr *InputExpr = S->getInputExpr(I); OwningExprResult Result = getDerived().TransformExpr(InputExpr); if (Result.isInvalid()) return SemaRef.StmtError(); - + ExprsChanged |= Result.get() != InputExpr; - + Exprs.push_back(Result.takeAs()); } - + if (!getDerived().AlwaysRebuild() && !ExprsChanged) return SemaRef.Owned(S->Retain()); @@ -3825,7 +3825,7 @@ TreeTransform::TransformObjCAtTryStmt(ObjCAtTryStmt *S) { OwningStmtResult TryBody = getDerived().TransformStmt(S->getTryBody()); if (TryBody.isInvalid()) return SemaRef.StmtError(); - + // Transform the @catch statements (if present). bool AnyCatchChanged = false; ASTOwningVector<&ActionBase::DeleteStmt> CatchStmts(SemaRef); @@ -3837,7 +3837,7 @@ TreeTransform::TransformObjCAtTryStmt(ObjCAtTryStmt *S) { AnyCatchChanged = true; CatchStmts.push_back(Catch.release()); } - + // Transform the @finally statement (if present). OwningStmtResult Finally(SemaRef); if (S->getFinallyStmt()) { @@ -3852,7 +3852,7 @@ TreeTransform::TransformObjCAtTryStmt(ObjCAtTryStmt *S) { !AnyCatchChanged && Finally.get() == S->getFinallyStmt()) return SemaRef.Owned(S->Retain()); - + // Build a new statement. return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), move(TryBody), move_arg(CatchStmts), move(Finally)); @@ -3870,26 +3870,26 @@ TreeTransform::TransformObjCAtCatchStmt(ObjCAtCatchStmt *S) { if (!TSInfo) return SemaRef.StmtError(); } - + QualType T; if (TSInfo) T = TSInfo->getType(); else { T = getDerived().TransformType(FromVar->getType()); if (T.isNull()) - return SemaRef.StmtError(); + return SemaRef.StmtError(); } - + Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T); if (!Var) return SemaRef.StmtError(); } - + OwningStmtResult Body = getDerived().TransformStmt(S->getCatchBody()); if (Body.isInvalid()) return SemaRef.StmtError(); - - return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(), + + return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(), S->getRParenLoc(), Var, move(Body)); } @@ -3901,7 +3901,7 @@ TreeTransform::TransformObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { OwningStmtResult Body = getDerived().TransformStmt(S->getFinallyBody()); if (Body.isInvalid()) return SemaRef.StmtError(); - + // If nothing changed, just retain this statement. if (!getDerived().AlwaysRebuild() && Body.get() == S->getFinallyBody()) @@ -3921,11 +3921,11 @@ TreeTransform::TransformObjCAtThrowStmt(ObjCAtThrowStmt *S) { if (Operand.isInvalid()) return getSema().StmtError(); } - + if (!getDerived().AlwaysRebuild() && Operand.get() == S->getThrowExpr()) return getSema().Owned(S->Retain()); - + return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), move(Operand)); } @@ -3937,12 +3937,12 @@ TreeTransform::TransformObjCAtSynchronizedStmt( OwningExprResult Object = getDerived().TransformExpr(S->getSynchExpr()); if (Object.isInvalid()) return SemaRef.StmtError(); - + // Transform the body. OwningStmtResult Body = getDerived().TransformStmt(S->getSynchBody()); if (Body.isInvalid()) return SemaRef.StmtError(); - + // If nothing change, just retain the current statement. if (!getDerived().AlwaysRebuild() && Object.get() == S->getSynchExpr() && @@ -3962,24 +3962,24 @@ TreeTransform::TransformObjCForCollectionStmt( OwningStmtResult Element = getDerived().TransformStmt(S->getElement()); if (Element.isInvalid()) return SemaRef.StmtError(); - + // Transform the collection expression. OwningExprResult Collection = getDerived().TransformExpr(S->getCollection()); if (Collection.isInvalid()) return SemaRef.StmtError(); - + // Transform the body. OwningStmtResult Body = getDerived().TransformStmt(S->getBody()); if (Body.isInvalid()) return SemaRef.StmtError(); - + // If nothing changed, just retain this statement. if (!getDerived().AlwaysRebuild() && Element.get() == S->getElement() && Collection.get() == S->getCollection() && Body.get() == S->getBody()) return SemaRef.Owned(S->Retain()); - + // Build a new statement. return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(), /*FIXME:*/S->getForLoc(), @@ -4093,7 +4093,7 @@ TreeTransform::TransformDeclRefExpr(DeclRefExpr *E) { if (!ND) return SemaRef.ExprError(); - if (!getDerived().AlwaysRebuild() && + if (!getDerived().AlwaysRebuild() && Qualifier == E->getQualifier() && ND == E->getDecl() && !E->hasExplicitTemplateArgumentList()) { @@ -4188,12 +4188,12 @@ TreeTransform::TransformOffsetOfExpr(OffsetOfExpr *E) { TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo()); if (!Type) return getSema().ExprError(); - + // Transform all of the components into components similar to what the // parser uses. - // FIXME: It would be slightly more efficient in the non-dependent case to - // just map FieldDecls, rather than requiring the rebuilder to look for - // the fields again. However, __builtin_offsetof is rare enough in + // FIXME: It would be slightly more efficient in the non-dependent case to + // just map FieldDecls, rather than requiring the rebuilder to look for + // the fields again. However, __builtin_offsetof is rare enough in // template code that we don't care. bool ExprChanged = false; typedef Action::OffsetOfComponent Component; @@ -4211,36 +4211,36 @@ TreeTransform::TransformOffsetOfExpr(OffsetOfExpr *E) { OwningExprResult Index = getDerived().TransformExpr(FromIndex); if (Index.isInvalid()) return getSema().ExprError(); - + ExprChanged = ExprChanged || Index.get() != FromIndex; Comp.isBrackets = true; Comp.U.E = Index.takeAs(); // FIXME: leaked break; } - + case Node::Field: case Node::Identifier: Comp.isBrackets = false; Comp.U.IdentInfo = ON.getFieldName(); if (!Comp.U.IdentInfo) continue; - + break; - + case Node::Base: // Will be recomputed during the rebuild. continue; } - + Components.push_back(Comp); } - + // If nothing changed, retain the existing expression. if (!getDerived().AlwaysRebuild() && Type == E->getTypeSourceInfo() && !ExprChanged) return SemaRef.Owned(E->Retain()); - + // Build a new offsetof expression. return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type, Components.data(), Components.size(), @@ -4385,7 +4385,7 @@ TreeTransform::TransformMemberExpr(MemberExpr *E) { Member == E->getMemberDecl() && FoundDecl == E->getFoundDecl() && !E->hasExplicitTemplateArgumentList()) { - + // Mark it referenced in the new context regardless. // FIXME: this is a bit instantiation-specific. SemaRef.MarkDeclarationReferenced(E->getMemberLoc(), Member); @@ -4403,7 +4403,7 @@ TreeTransform::TransformMemberExpr(MemberExpr *E) { TransArgs.addArgument(Loc); } } - + // FIXME: Bogus source location for the operator SourceLocation FakeOperatorLoc = SemaRef.PP.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd()); @@ -4662,7 +4662,7 @@ Sema::OwningExprResult TreeTransform::TransformImplicitValueInitExpr( ImplicitValueInitExpr *E) { TemporaryBase Rebase(*this, E->getLocStart(), DeclarationName()); - + // FIXME: Will we ever have proper type location here? Will we actually // need to transform the type? QualType T = getDerived().TransformType(E->getType()); @@ -4735,7 +4735,7 @@ TreeTransform::TransformAddrLabelExpr(AddrLabelExpr *E) { } template -Sema::OwningExprResult +Sema::OwningExprResult TreeTransform::TransformStmtExpr(StmtExpr *E) { OwningStmtResult SubStmt = getDerived().TransformCompoundStmt(E->getSubStmt(), true); @@ -4819,7 +4819,7 @@ TreeTransform::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) { case OO_Array_Delete: llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr"); return SemaRef.ExprError(); - + case OO_Call: { // This is a call to an object's operator(). assert(E->getNumArgs() >= 1 && "Object call is missing arguments"); @@ -4840,7 +4840,7 @@ TreeTransform::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) { for (unsigned I = 1, N = E->getNumArgs(); I != N; ++I) { if (getDerived().DropCallArgument(E->getArg(I))) break; - + OwningExprResult Arg = getDerived().TransformExpr(E->getArg(I)); if (Arg.isInvalid()) return SemaRef.ExprError(); @@ -5195,7 +5195,7 @@ TreeTransform::TransformCXXNewExpr(CXXNewExpr *E) { if (!OperatorDelete) return SemaRef.ExprError(); } - + if (!getDerived().AlwaysRebuild() && AllocType == E->getAllocatedType() && ArraySize.get() == E->getArraySize() && @@ -5225,9 +5225,9 @@ TreeTransform::TransformCXXNewExpr(CXXNewExpr *E) { // Do nothing } else if (const ConstantArrayType *ConsArrayT = dyn_cast(ArrayT)) { - ArraySize + ArraySize = SemaRef.Owned(new (SemaRef.Context) IntegerLiteral( - ConsArrayT->getSize(), + ConsArrayT->getSize(), SemaRef.Context.getSizeType(), /*FIXME:*/E->getLocStart())); AllocType = ConsArrayT->getElementType(); @@ -5270,7 +5270,7 @@ TreeTransform::TransformCXXDeleteExpr(CXXDeleteExpr *E) { if (!OperatorDelete) return SemaRef.ExprError(); } - + if (!getDerived().AlwaysRebuild() && Operand.get() == E->getArgument() && OperatorDelete == E->getOperatorDelete()) { @@ -5297,14 +5297,14 @@ TreeTransform::TransformCXXPseudoDestructorExpr( Sema::TypeTy *ObjectTypePtr = 0; bool MayBePseudoDestructor = false; - Base = SemaRef.ActOnStartCXXMemberReference(0, move(Base), + Base = SemaRef.ActOnStartCXXMemberReference(0, move(Base), E->getOperatorLoc(), E->isArrow()? tok::arrow : tok::period, ObjectTypePtr, MayBePseudoDestructor); if (Base.isInvalid()) return SemaRef.ExprError(); - + QualType ObjectType = QualType::getFromOpaquePtr(ObjectTypePtr); NestedNameSpecifier *Qualifier = getDerived().TransformNestedNameSpecifier(E->getQualifier(), @@ -5332,7 +5332,7 @@ TreeTransform::TransformCXXPseudoDestructorExpr( SS.setScopeRep(Qualifier); SS.setRange(E->getQualifierRange()); } - + Sema::TypeTy *T = SemaRef.getDestructorName(E->getTildeLoc(), *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(), @@ -5341,7 +5341,7 @@ TreeTransform::TransformCXXPseudoDestructorExpr( false); if (!T) return SemaRef.ExprError(); - + Destroyed = SemaRef.Context.getTrivialTypeSourceInfo(SemaRef.GetTypeFromParser(T), E->getDestroyedTypeLoc()); @@ -5349,12 +5349,12 @@ TreeTransform::TransformCXXPseudoDestructorExpr( TypeSourceInfo *ScopeTypeInfo = 0; if (E->getScopeTypeInfo()) { - ScopeTypeInfo = getDerived().TransformType(E->getScopeTypeInfo(), + ScopeTypeInfo = getDerived().TransformType(E->getScopeTypeInfo(), ObjectType); if (!ScopeTypeInfo) return SemaRef.ExprError(); } - + return getDerived().RebuildCXXPseudoDestructorExpr(move(Base), E->getOperatorLoc(), E->isArrow(), @@ -5414,11 +5414,11 @@ TreeTransform::TransformUnresolvedLookupExpr( Old->getQualifierRange()); if (!Qualifier) return SemaRef.ExprError(); - + SS.setScopeRep(Qualifier); SS.setRange(Old->getQualifierRange()); - } - + } + if (Old->getNamingClass()) { CXXRecordDecl *NamingClass = cast_or_null(getDerived().TransformDecl( @@ -5426,7 +5426,7 @@ TreeTransform::TransformUnresolvedLookupExpr( Old->getNamingClass())); if (!NamingClass) return SemaRef.ExprError(); - + R.setNamingClass(NamingClass); } @@ -5611,7 +5611,7 @@ TreeTransform::TransformCXXTemporaryObjectExpr( CXXConstructorDecl *Constructor = cast_or_null( - getDerived().TransformDecl(E->getLocStart(), + getDerived().TransformDecl(E->getLocStart(), E->getConstructor())); if (!Constructor) return SemaRef.ExprError(); @@ -5856,16 +5856,16 @@ TreeTransform::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old) // Determine the naming class. if (!Old->getNamingClass()) { - CXXRecordDecl *NamingClass + CXXRecordDecl *NamingClass = cast_or_null(getDerived().TransformDecl( Old->getMemberLoc(), Old->getNamingClass())); if (!NamingClass) return SemaRef.ExprError(); - + R.setNamingClass(NamingClass); } - + TemplateArgumentListInfo TransArgs; if (Old->hasExplicitTemplateArgs()) { TransArgs.setLAngleLoc(Old->getLAngleLoc()); @@ -5884,7 +5884,7 @@ TreeTransform::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old) // base (and therefore couldn't do the check) and a // nested-name-qualifier (and therefore could do the lookup). NamedDecl *FirstQualifierInScope = 0; - + return getDerived().RebuildUnresolvedMemberExpr(move(Base), BaseType, Old->getOperatorLoc(), @@ -5930,7 +5930,7 @@ TreeTransform::TransformObjCMessageExpr(ObjCMessageExpr *E) { OwningExprResult Arg = getDerived().TransformExpr(E->getArg(I)); if (Arg.isInvalid()) return SemaRef.ExprError(); - + ArgChanged = ArgChanged || Arg.get() != E->getArg(I); Args.push_back(Arg.takeAs()); } @@ -5941,7 +5941,7 @@ TreeTransform::TransformObjCMessageExpr(ObjCMessageExpr *E) { = getDerived().TransformType(E->getClassReceiverTypeInfo()); if (!ReceiverTypeInfo) return SemaRef.ExprError(); - + // If nothing changed, just retain the existing message send. if (!getDerived().AlwaysRebuild() && ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged) @@ -5968,7 +5968,7 @@ TreeTransform::TransformObjCMessageExpr(ObjCMessageExpr *E) { if (!getDerived().AlwaysRebuild() && Receiver.get() == E->getInstanceReceiver() && !ArgChanged) return SemaRef.Owned(E->Retain()); - + // Build a new instance message send. return getDerived().RebuildObjCMessageExpr(move(Receiver), E->getSelector(), @@ -5999,12 +5999,12 @@ TreeTransform::TransformObjCIvarRefExpr(ObjCIvarRefExpr *E) { return SemaRef.ExprError(); // We don't need to transform the ivar; it will never change. - + // If nothing changed, just retain the existing expression. if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase()) return SemaRef.Owned(E->Retain()); - + return getDerived().RebuildObjCIvarRefExpr(move(Base), E->getDecl(), E->getLocation(), E->isArrow(), E->isFreeIvar()); @@ -6017,14 +6017,14 @@ TreeTransform::TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { OwningExprResult Base = getDerived().TransformExpr(E->getBase()); if (Base.isInvalid()) return SemaRef.ExprError(); - + // We don't need to transform the property; it will never change. - + // If nothing changed, just retain the existing expression. if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase()) return SemaRef.Owned(E->Retain()); - + return getDerived().RebuildObjCPropertyRefExpr(move(Base), E->getProperty(), E->getLocation()); } @@ -6037,26 +6037,26 @@ TreeTransform::TransformObjCImplicitSetterGetterRefExpr( // dependent parts. Just retain the existing declaration. if (E->getInterfaceDecl()) return SemaRef.Owned(E->Retain()); - + // Transform the base expression. OwningExprResult Base = getDerived().TransformExpr(E->getBase()); if (Base.isInvalid()) return SemaRef.ExprError(); - + // We don't need to transform the getters/setters; they will never change. - + // If nothing changed, just retain the existing expression. if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase()) return SemaRef.Owned(E->Retain()); - + return getDerived().RebuildObjCImplicitSetterGetterRefExpr( E->getGetterMethod(), E->getType(), E->getSetterMethod(), E->getLocation(), move(Base)); - + } template @@ -6073,12 +6073,12 @@ TreeTransform::TransformObjCIsaExpr(ObjCIsaExpr *E) { OwningExprResult Base = getDerived().TransformExpr(E->getBase()); if (Base.isInvalid()) return SemaRef.ExprError(); - + // If nothing changed, just retain the existing expression. if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase()) return SemaRef.Owned(E->Retain()); - + return getDerived().RebuildObjCIsaExpr(move(Base), E->getIsaMemberLoc(), E->isArrow()); } @@ -6297,7 +6297,7 @@ QualType TreeTransform::RebuildUnresolvedUsingType(Decl *D) { // A valid resolved using typename decl points to exactly one type decl. assert(++Using->shadow_begin() == Using->shadow_end()); Ty = cast((*Using->shadow_begin())->getTargetDecl()); - + } else { assert(isa(D) && "UnresolvedUsingTypenameDecl transformed to non-using decl"); @@ -6422,7 +6422,7 @@ TreeTransform::RebuildTemplateName(NestedNameSpecifier *Qualifier, /*EnteringContext=*/false) .template getAsVal(); } - + template Sema::OwningExprResult TreeTransform::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, @@ -6516,7 +6516,7 @@ TreeTransform::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, } template -Sema::OwningExprResult +Sema::OwningExprResult TreeTransform::RebuildCXXPseudoDestructorExpr(ExprArg Base, SourceLocation OperatorLoc, bool isArrow, @@ -6536,7 +6536,7 @@ TreeTransform::RebuildCXXPseudoDestructorExpr(ExprArg Base, QualType BaseType = BaseE->getType(); if (BaseE->isTypeDependent() || Destroyed.getIdentifier() || (!isArrow && !BaseType->getAs()) || - (isArrow && BaseType->getAs() && + (isArrow && BaseType->getAs() && !BaseType->getAs()->getPointeeType() ->template getAs())){ // This pseudo-destructor expression is still a pseudo-destructor. @@ -6546,14 +6546,14 @@ TreeTransform::RebuildCXXPseudoDestructorExpr(ExprArg Base, Destroyed, /*FIXME?*/true); } - + TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo(); DeclarationName Name = SemaRef.Context.DeclarationNames.getCXXDestructorName( SemaRef.Context.getCanonicalType(DestroyedType->getType())); - + // FIXME: the ScopeType should be tacked onto SS. - + return getSema().BuildMemberReferenceExpr(move(Base), BaseType, OperatorLoc, isArrow, SS, /*FIXME: FirstQualifier*/ 0,