diff options
author | John McCall <rjmccall@apple.com> | 2010-08-23 06:44:23 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-08-23 06:44:23 +0000 |
commit | ca0408fb49c1370430672acf2d770b7151cf71de (patch) | |
tree | bec6c6e10a30ca0911d857c75bb7cfa883a18963 | |
parent | b6c504b9101251bcb364dd9becbb887c97db27d3 (diff) |
Sundry incremental steps towards killing off Action.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111795 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Parse/Parser.h | 42 | ||||
-rw-r--r-- | include/clang/Sema/Action.h | 49 | ||||
-rw-r--r-- | include/clang/Sema/AttributeList.h | 3 | ||||
-rw-r--r-- | include/clang/Sema/DeclSpec.h | 9 | ||||
-rw-r--r-- | include/clang/Sema/Ownership.h | 194 | ||||
-rw-r--r-- | include/clang/Sema/ParsedTemplate.h | 4 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 8 | ||||
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 10 | ||||
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 8 | ||||
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 27 | ||||
-rw-r--r-- | lib/Parse/ParseExprCXX.cpp | 9 | ||||
-rw-r--r-- | lib/Parse/ParseInit.cpp | 8 | ||||
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 10 | ||||
-rw-r--r-- | lib/Parse/ParsePragma.cpp | 2 | ||||
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 32 | ||||
-rw-r--r-- | lib/Parse/ParseTemplate.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaCXXCast.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 20 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 22 | ||||
-rw-r--r-- | lib/Sema/SemaInit.cpp | 23 | ||||
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 10 | ||||
-rw-r--r-- | lib/Sema/TreeTransform.h | 64 |
25 files changed, 283 insertions, 289 deletions
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index fd91acff7f..87e0b42a37 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -145,17 +145,17 @@ public: // Type forwarding. All of these are statically 'void*', but they may all be // different actual classes based on the actions in place. - typedef Action::ExprTy ExprTy; - typedef Action::StmtTy StmtTy; + typedef Expr ExprTy; + typedef Stmt StmtTy; typedef Action::DeclGroupPtrTy DeclGroupPtrTy; typedef Action::TypeTy TypeTy; - typedef Action::BaseTy BaseTy; - typedef Action::MemInitTy MemInitTy; - typedef Action::CXXScopeTy CXXScopeTy; - typedef Action::TemplateParamsTy TemplateParamsTy; + typedef CXXBaseSpecifier BaseTy; + typedef CXXBaseOrMemberInitializer MemInitTy; + typedef NestedNameSpecifier CXXScopeTy; + typedef TemplateParameterList TemplateParamsTy; typedef Action::TemplateTy TemplateTy; - typedef llvm::SmallVector<TemplateParamsTy *, 4> TemplateParameterLists; + typedef llvm::SmallVector<TemplateParameterList *, 4> TemplateParameterLists; typedef Action::ExprResult ExprResult; typedef Action::StmtResult StmtResult; @@ -172,20 +172,20 @@ public: /// Adorns a ExprResult with Actions to make it an OwningExprResult OwningExprResult Owned(ExprResult res) { - return OwningExprResult(Actions, res); + return OwningExprResult(res); } /// Adorns a StmtResult with Actions to make it an OwningStmtResult OwningStmtResult Owned(StmtResult res) { - return OwningStmtResult(Actions, res); + return OwningStmtResult(res); } - OwningExprResult ExprError() { return OwningExprResult(Actions, true); } - OwningStmtResult StmtError() { return OwningStmtResult(Actions, true); } + OwningExprResult ExprError() { return OwningExprResult(true); } + OwningStmtResult StmtError() { return OwningStmtResult(true); } OwningExprResult ExprError(const DiagnosticBuilder &) { return ExprError(); } OwningStmtResult StmtError(const DiagnosticBuilder &) { return StmtError(); } - OwningExprResult ExprEmpty() { return OwningExprResult(Actions, false); } + OwningExprResult ExprEmpty() { return OwningExprResult(false); } // Parsing methods. @@ -949,16 +949,17 @@ private: TypeTy *&CastTy, SourceRange &CastRange); - static const unsigned ExprListSize = 12; - typedef llvm::SmallVector<ExprTy*, ExprListSize> ExprListTy; - typedef llvm::SmallVector<SourceLocation, ExprListSize> CommaLocsTy; + typedef llvm::SmallVector<Expr*, 20> ExprListTy; + typedef llvm::SmallVector<SourceLocation, 20> CommaLocsTy; /// ParseExpressionList - Used for C/C++ (argument-)expression-list. - bool ParseExpressionList(ExprListTy &Exprs, CommaLocsTy &CommaLocs, - void (Action::*Completer)(Scope *S, void *Data, - ExprTy **Args, + bool ParseExpressionList(llvm::SmallVectorImpl<Expr*> &Exprs, + llvm::SmallVectorImpl<SourceLocation> &CommaLocs, + void (Action::*Completer)(Scope *S, + Expr *Data, + Expr **Args, unsigned NumArgs) = 0, - void *Data = 0); + Expr *Data = 0); /// ParenParseOption - Control what ParseParenExpression will parse. enum ParenParseOption { @@ -1040,7 +1041,8 @@ private: //===--------------------------------------------------------------------===// // C++ 5.3.4 and 5.3.5: C++ new and delete - bool ParseExpressionListOrTypeId(ExprListTy &Exprs, Declarator &D); + bool ParseExpressionListOrTypeId(llvm::SmallVectorImpl<Expr*> &Exprs, + Declarator &D); void ParseDirectNewDeclarator(Declarator &D); OwningExprResult ParseCXXNewExpression(bool UseGlobal, SourceLocation Start); OwningExprResult ParseCXXDeleteExpression(bool UseGlobal, diff --git a/include/clang/Sema/Action.h b/include/clang/Sema/Action.h index a574333e75..87cafafaad 100644 --- a/include/clang/Sema/Action.h +++ b/include/clang/Sema/Action.h @@ -31,6 +31,7 @@ namespace clang { class CXXScopeSpec; class Declarator; class AttributeList; + class TemplateParameterList; struct FieldDeclarator; // Parse. class Scope; @@ -84,23 +85,23 @@ public: typedef clang::StmtResult StmtResult; typedef clang::TypeResult TypeResult; typedef clang::BaseResult BaseResult; - typedef clang::MemInitResult MemInitResult; typedef clang::DeclResult DeclResult; + typedef clang::MemInitResult MemInitResult; /// Same, but with ownership. - typedef ASTOwningResult<&ActionBase::DeleteExpr> OwningExprResult; - typedef ASTOwningResult<&ActionBase::DeleteStmt> OwningStmtResult; + typedef ASTOwningResult<Expr*> OwningExprResult; + typedef ASTOwningResult<Stmt*> OwningStmtResult; // Note that these will replace ExprResult and StmtResult when the transition // is complete. /// Single expressions or statements as arguments. - typedef ASTOwningPtr<&ActionBase::DeleteExpr> ExprArg; - typedef ASTOwningPtr<&ActionBase::DeleteStmt> StmtArg; + typedef ASTOwningPtr<Expr*> ExprArg; + typedef ASTOwningPtr<Stmt*> StmtArg; /// Multiple expressions or statements as arguments. - typedef ASTMultiPtr<&ActionBase::DeleteExpr> MultiExprArg; - typedef ASTMultiPtr<&ActionBase::DeleteStmt> MultiStmtArg; - typedef ASTMultiPtr<&ActionBase::DeleteTemplateParams> MultiTemplateParamsArg; + typedef ASTMultiPtr<Expr*> MultiExprArg; + typedef ASTMultiPtr<Stmt*> MultiStmtArg; + typedef ASTMultiPtr<TemplateParameterList*> MultiTemplateParamsArg; class FullExprArg { public: @@ -143,14 +144,14 @@ public: // Utilities for Action implementations to return smart results. - OwningExprResult ExprError() { return OwningExprResult(*this, true); } - OwningStmtResult StmtError() { return OwningStmtResult(*this, true); } + OwningExprResult ExprError() { return OwningExprResult(true); } + OwningStmtResult StmtError() { return OwningStmtResult(true); } OwningExprResult ExprError(const DiagnosticBuilder&) { return ExprError(); } OwningStmtResult StmtError(const DiagnosticBuilder&) { return StmtError(); } - OwningExprResult ExprEmpty() { return OwningExprResult(*this, false); } - OwningStmtResult StmtEmpty() { return OwningStmtResult(*this, false); } + OwningExprResult ExprEmpty() { return OwningExprResult(false); } + OwningStmtResult StmtEmpty() { return OwningStmtResult(false); } /// Statistics. virtual void PrintStats() const {} @@ -709,8 +710,8 @@ public: IdentifierInfo *ClassName, llvm::SmallVectorImpl<Decl *> &Decls) {} virtual Decl *ActOnField(Scope *S, Decl *TagD, - SourceLocation DeclStart, - Declarator &D, ExprTy *BitfieldWidth) { + SourceLocation DeclStart, + Declarator &D, ExprTy *BitfieldWidth) { return 0; } @@ -783,9 +784,7 @@ public: virtual void ActOnForEachDeclStmt(DeclGroupPtrTy Decl) { } - virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr) { - return OwningStmtResult(*this, Expr->release()); - } + virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr) = 0; /// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension, /// which can specify an RHS value. The sub-statement of the case is @@ -2576,9 +2575,7 @@ public: SourceLocation LBracLoc, SourceLocation SelectorLoc, SourceLocation RBracLoc, - MultiExprArg Args) { - return OwningExprResult(*this); - } + MultiExprArg Args) = 0; /// \brief Parsed a message send to a class. /// @@ -2595,9 +2592,7 @@ public: SourceLocation LBracLoc, SourceLocation SelectorLoc, SourceLocation RBracLoc, - MultiExprArg Args) { - return OwningExprResult(*this); - } + MultiExprArg Args) = 0; /// \brief Parsed a message send to an object instance. /// @@ -2614,9 +2609,7 @@ public: SourceLocation LBracLoc, SourceLocation SelectorLoc, SourceLocation RBracLoc, - MultiExprArg Args) { - return OwningExprResult(*this); - } + MultiExprArg Args) = 0; virtual Decl *ActOnForwardClassDeclaration( SourceLocation AtClassLoc, @@ -2847,8 +2840,8 @@ public: /// \param Args the arguments to the function call (so far). /// /// \param NumArgs the number of arguments in \p Args. - virtual void CodeCompleteCall(Scope *S, ExprTy *Fn, - ExprTy **Args, unsigned NumArgs) { } + virtual void CodeCompleteCall(Scope *S, Expr *Fn, + Expr **Args, unsigned NumArgs) { } /// \brief Code completion for the initializer of a variable declaration. /// diff --git a/include/clang/Sema/AttributeList.h b/include/clang/Sema/AttributeList.h index dcb8d1fd67..c791502bd4 100644 --- a/include/clang/Sema/AttributeList.h +++ b/include/clang/Sema/AttributeList.h @@ -22,6 +22,7 @@ namespace clang { class IdentifierInfo; class Action; + class Expr; /// AttributeList - Represents GCC's __attribute__ declaration. There are /// 4 forms of this construct...they are: @@ -49,7 +50,7 @@ public: AttributeList(IdentifierInfo *AttrName, SourceLocation AttrLoc, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, IdentifierInfo *ParmName, SourceLocation ParmLoc, - ActionBase::ExprTy **args, unsigned numargs, + Expr **args, unsigned numargs, AttributeList *Next, bool declspec = false, bool cxx0x = false); ~AttributeList(); diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 3ae23d44b6..993ba2cf4a 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -30,6 +30,7 @@ namespace clang { class LangOptions; class Diagnostic; class IdentifierInfo; + class NestedNameSpecifier; class Preprocessor; class Declarator; struct TemplateIdAnnotation; @@ -47,7 +48,7 @@ namespace clang { /// The actual scope is described by getScopeRep(). class CXXScopeSpec { SourceRange Range; - void *ScopeRep; + NestedNameSpecifier *ScopeRep; public: CXXScopeSpec() : Range(), ScopeRep() { } @@ -59,7 +60,7 @@ public: SourceLocation getBeginLoc() const { return Range.getBegin(); } SourceLocation getEndLoc() const { return Range.getEnd(); } - ActionBase::CXXScopeTy *getScopeRep() const { return ScopeRep; } + NestedNameSpecifier *getScopeRep() const { return ScopeRep; } void setScopeRep(ActionBase::CXXScopeTy *S) { ScopeRep = S; } /// No scope specifier. @@ -799,7 +800,7 @@ struct DeclaratorChunk { /// This is the size of the array, or null if [] or [*] was specified. /// Since the parser is multi-purpose, and we don't want to impose a root /// expression class on all clients, NumElts is untyped. - ActionBase::ExprTy *NumElts; + Expr *NumElts; void destroy() {} }; @@ -1010,7 +1011,7 @@ struct DeclaratorChunk { /// getArray - Return a DeclaratorChunk for an array. /// static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, - bool isStar, void *NumElts, + bool isStar, Expr *NumElts, SourceLocation LBLoc, SourceLocation RBLoc) { DeclaratorChunk I; I.Kind = Array; diff --git a/include/clang/Sema/Ownership.h b/include/clang/Sema/Ownership.h index eceac5e43c..1877ddda40 100644 --- a/include/clang/Sema/Ownership.h +++ b/include/clang/Sema/Ownership.h @@ -23,7 +23,14 @@ namespace clang { class ActionBase; + class Attr; + class CXXBaseOrMemberInitializer; + class CXXBaseSpecifier; class Decl; + class Expr; + class NestedNameSpecifier; + class Stmt; + class TemplateParameterList; /// OpaquePtr - This is a very simple POD type that wraps a pointer that the /// Parser doesn't know about but that Sema or another client does. The UID @@ -186,7 +193,7 @@ namespace clang { // Determines whether the low bit of the result pointer for the // given UID is always zero. If so, ActionResult will use that bit // for it's "invalid" flag. - template<unsigned UID> + template<class Ptr> struct IsResultPtrLowBitFree { static const bool value = false; }; @@ -202,13 +209,13 @@ namespace clang { // what types are required to be identical for the actions. typedef OpaquePtr<1> DeclGroupPtrTy; typedef OpaquePtr<2> TemplateTy; - typedef void AttrTy; - typedef void BaseTy; - typedef void MemInitTy; - typedef void ExprTy; - typedef void StmtTy; - typedef void TemplateParamsTy; - typedef void CXXScopeTy; + typedef Attr AttrTy; + typedef CXXBaseSpecifier BaseTy; + typedef CXXBaseOrMemberInitializer MemInitTy; + typedef Expr ExprTy; + typedef Stmt StmtTy; + typedef TemplateParameterList TemplateParamsTy; + typedef NestedNameSpecifier CXXScopeTy; typedef void TypeTy; // FIXME: Change TypeTy to use OpaquePtr<N>. /// ActionResult - This structure is used while parsing/acting on @@ -216,19 +223,21 @@ namespace clang { /// the action, plus a sense of whether or not it is valid. /// When CompressInvalid is true, the "invalid" flag will be /// stored in the low bit of the Val pointer. - template<unsigned UID, - typename PtrTy = void*, - bool CompressInvalid = IsResultPtrLowBitFree<UID>::value> + template<class PtrTy, + bool CompressInvalid = IsResultPtrLowBitFree<PtrTy>::value> class ActionResult { PtrTy Val; bool Invalid; public: ActionResult(bool Invalid = false) : Val(PtrTy()), Invalid(Invalid) {} - template<typename ActualExprTy> - ActionResult(ActualExprTy val) : Val(val), Invalid(false) {} + ActionResult(PtrTy val) : Val(val), Invalid(false) {} ActionResult(const DiagnosticBuilder &) : Val(PtrTy()), Invalid(true) {} + // These two overloads prevent void* -> bool conversions. + ActionResult(const void *); + ActionResult(volatile void *); + PtrTy get() const { return Val; } void set(PtrTy V) { Val = V; } bool isInvalid() const { return Invalid; } @@ -242,8 +251,8 @@ namespace clang { // This ActionResult partial specialization places the "invalid" // flag into the low bit of the pointer. - template<unsigned UID, typename PtrTy> - class ActionResult<UID, PtrTy, true> { + template<typename PtrTy> + class ActionResult<PtrTy, true> { // A pointer whose low bit is 1 if this result is invalid, 0 // otherwise. uintptr_t PtrWithInvalid; @@ -252,20 +261,16 @@ namespace clang { ActionResult(bool Invalid = false) : PtrWithInvalid(static_cast<uintptr_t>(Invalid)) { } - template<typename ActualExprTy> - ActionResult(ActualExprTy *val) { - PtrTy V(val); - void *VP = PtrTraits::getAsVoidPointer(V); - PtrWithInvalid = reinterpret_cast<uintptr_t>(VP); - assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer"); - } - ActionResult(PtrTy V) { void *VP = PtrTraits::getAsVoidPointer(V); PtrWithInvalid = reinterpret_cast<uintptr_t>(VP); assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer"); } + // These two overloads prevent void* -> bool conversions. + ActionResult(const void *); + ActionResult(volatile void *); + ActionResult(const DiagnosticBuilder &) : PtrWithInvalid(0x01) { } PtrTy get() const { @@ -298,80 +303,68 @@ namespace clang { virtual void DeleteTemplateParams(TemplateParamsTy *P) {} }; - /// ASTDestroyer - The type of an AST node destruction function pointer. - typedef void (ActionBase::*ASTDestroyer)(void *); - - /// For the transition phase: translate from an ASTDestroyer to its - /// ActionResult UID. - template <ASTDestroyer Destroyer> struct DestroyerToUID; - template <> struct DestroyerToUID<&ActionBase::DeleteExpr> { - static const unsigned UID = 0; - }; - template <> struct DestroyerToUID<&ActionBase::DeleteStmt> { - static const unsigned UID = 1; - }; /// ASTOwningResult - A moveable smart pointer for AST nodes that also /// has an extra flag to indicate an additional success status. - template <ASTDestroyer Destroyer> class ASTOwningResult; + template <typename PtrTy> class ASTOwningResult; /// ASTMultiPtr - A moveable smart pointer to multiple AST nodes. Only owns /// the individual pointers, not the array holding them. - template <ASTDestroyer Destroyer> class ASTMultiPtr; + template <typename PtrTy> class ASTMultiPtr; /// Kept only as a type-safe wrapper for a void pointer. - template <ASTDestroyer Destroyer> - class ASTOwningPtr { - void *Node; + template <typename PtrTy> class ASTOwningPtr { + PtrTy Node; public: explicit ASTOwningPtr(ActionBase &) : Node(0) {} - ASTOwningPtr(ActionBase &, void *node) : Node(node) {} + ASTOwningPtr(ActionBase &, PtrTy node) : Node(node) {} + // Normal copying operators are defined implicitly. - ASTOwningPtr(const ASTOwningResult<Destroyer> &o); + ASTOwningPtr(const ASTOwningResult<PtrTy> &o); - ASTOwningPtr & operator =(void *raw) { + ASTOwningPtr & operator =(PtrTy raw) { Node = raw; return *this; } /// Access to the raw pointer. - void * get() const { return Node; } + PtrTy get() const { return Node; } /// Release the raw pointer. - void * take() { - return Node; - } + PtrTy take() { return Node; } /// Take outside ownership of the raw pointer and cast it down. - template<typename T> - T *takeAs() { + template<typename T> T *takeAs() { return static_cast<T*>(Node); } /// Alias for interface familiarity with unique_ptr. - void * release() { + PtrTy release() { return take(); } }; - template <ASTDestroyer Destroyer> - class ASTOwningResult { + template <class PtrTy> class ASTOwningResult { public: - typedef ActionBase::ActionResult<DestroyerToUID<Destroyer>::UID> DumbResult; + typedef ActionBase::ActionResult<PtrTy> DumbResult; private: DumbResult Result; public: - explicit ASTOwningResult(ActionBase &actions, bool invalid = false) + explicit ASTOwningResult(bool invalid = false) : Result(invalid) { } - ASTOwningResult(ActionBase &actions, void *node) : Result(node) { } - ASTOwningResult(ActionBase &actions, const DumbResult &res) : Result(res) { } + explicit ASTOwningResult(PtrTy node) : Result(node) { } + explicit ASTOwningResult(const DumbResult &res) : Result(res) { } // Normal copying semantics are defined implicitly. - ASTOwningResult(const ASTOwningPtr<Destroyer> &o) : Result(o.get()) { } + ASTOwningResult(const ASTOwningPtr<PtrTy> &o) : Result(o.get()) { } + + // These two overloads prevent void* -> bool conversions. + explicit ASTOwningResult(const void *); + explicit ASTOwningResult(volatile void *); /// Assignment from a raw pointer. Takes ownership - beware! - ASTOwningResult & operator =(void *raw) { + ASTOwningResult & operator =(PtrTy raw) { Result = raw; return *this; } @@ -383,7 +376,7 @@ namespace clang { } /// Access to the raw pointer. - void * get() const { return Result.get(); } + PtrTy get() const { return Result.get(); } bool isInvalid() const { return Result.isInvalid(); } @@ -392,7 +385,7 @@ namespace clang { bool isUsable() const { return !Result.isInvalid() && get(); } /// Take outside ownership of the raw pointer. - void * take() { + PtrTy take() { return Result.get(); } @@ -403,32 +396,32 @@ namespace clang { } /// Alias for interface familiarity with unique_ptr. - void * release() { return take(); } + PtrTy release() { return take(); } /// Pass ownership to a classical ActionResult. DumbResult result() { return Result; } }; - template <ASTDestroyer Destroyer> + template <class PtrTy> class ASTMultiPtr { - void **Nodes; + PtrTy *Nodes; unsigned Count; public: // Normal copying implicitly defined explicit ASTMultiPtr(ActionBase &) : Nodes(0), Count(0) {} - ASTMultiPtr(ActionBase &, void **nodes, unsigned count) + ASTMultiPtr(ActionBase &, PtrTy *nodes, unsigned count) : Nodes(nodes), Count(count) {} // Fake mover in Parse/AstGuard.h needs this: - ASTMultiPtr(void **nodes, unsigned count) : Nodes(nodes), Count(count) {} + ASTMultiPtr(PtrTy *nodes, unsigned count) : Nodes(nodes), Count(count) {} /// Access to the raw pointers. - void ** get() const { return Nodes; } + PtrTy *get() const { return Nodes; } /// Access to the count. unsigned size() const { return Count; } - void ** release() { + PtrTy *release() { return Nodes; } }; @@ -472,8 +465,8 @@ namespace clang { }; /// \brief A small vector that owns a set of AST nodes. - template <ASTDestroyer Destroyer, unsigned N = 8> - class ASTOwningVector : public llvm::SmallVector<void *, N> { + template <class PtrTy, unsigned N = 8> + class ASTOwningVector : public llvm::SmallVector<PtrTy, N> { ASTOwningVector(ASTOwningVector &); // do not implement ASTOwningVector &operator=(ASTOwningVector &); // do not implement @@ -481,60 +474,67 @@ namespace clang { explicit ASTOwningVector(ActionBase &Actions) { } - void **take() { + PtrTy *take() { return &this->front(); } - template<typename T> T **takeAs() { return (T**)take(); } + template<typename T> T **takeAs() { return reinterpret_cast<T**>(take()); } }; /// A SmallVector of statements, with stack size 32 (as that is the only one /// used.) - typedef ASTOwningVector<&ActionBase::DeleteStmt, 32> StmtVector; + typedef ASTOwningVector<Stmt*, 32> StmtVector; /// A SmallVector of expressions, with stack size 12 (the maximum used.) - typedef ASTOwningVector<&ActionBase::DeleteExpr, 12> ExprVector; + typedef ASTOwningVector<Expr*, 12> ExprVector; - template <ASTDestroyer Destroyer, unsigned N> inline - ASTMultiPtr<Destroyer> move_arg(ASTOwningVector<Destroyer, N> &vec) { - return ASTMultiPtr<Destroyer>(vec.take(), vec.size()); + template <class T, unsigned N> inline + ASTMultiPtr<T> move_arg(ASTOwningVector<T, N> &vec) { + return ASTMultiPtr<T>(vec.take(), vec.size()); } - template <ASTDestroyer Destroyer> inline - ASTOwningPtr<Destroyer>::ASTOwningPtr(const ASTOwningResult<Destroyer> &o) + template <class T> inline + ASTOwningPtr<T>::ASTOwningPtr(const ASTOwningResult<T> &o) : Node(o.get()) { } // These versions are hopefully no-ops. - template <ASTDestroyer Destroyer> inline - ASTOwningResult<Destroyer>& move(ASTOwningResult<Destroyer> &ptr) { + template <class T> inline + ASTOwningResult<T>& move(ASTOwningResult<T> &ptr) { return ptr; } - template <ASTDestroyer Destroyer> inline - ASTOwningPtr<Destroyer>& move(ASTOwningPtr<Destroyer> &ptr) { + template <class T> inline + ASTOwningPtr<T>& move(ASTOwningPtr<T> &ptr) { return ptr; } - template <ASTDestroyer Destroyer> inline - ASTMultiPtr<Destroyer>& move(ASTMultiPtr<Destroyer> &ptr) { + template <class T> inline + ASTMultiPtr<T>& move(ASTMultiPtr<T> &ptr) { return ptr; } // We can re-use the low bit of expression, statement, base, and // member-initializer pointers for the "invalid" flag of // ActionResult. - template<> struct IsResultPtrLowBitFree<0> { static const bool value = true;}; - template<> struct IsResultPtrLowBitFree<1> { static const bool value = true;}; - template<> struct IsResultPtrLowBitFree<3> { static const bool value = true;}; - template<> struct IsResultPtrLowBitFree<4> { static const bool value = true;}; - template<> struct IsResultPtrLowBitFree<5> { static const bool value = true;}; - - typedef ActionBase::ActionResult<0> ExprResult; - typedef ActionBase::ActionResult<1> StmtResult; - typedef ActionBase::ActionResult<2> TypeResult; - typedef ActionBase::ActionResult<3> BaseResult; - typedef ActionBase::ActionResult<4> MemInitResult; - - typedef ActionBase::ActionResult<5, Decl*> DeclResult; + template<> struct IsResultPtrLowBitFree<Expr*> { + static const bool value = true; + }; + template<> struct IsResultPtrLowBitFree<Stmt*> { + static const bool value = true; + }; + template<> struct IsResultPtrLowBitFree<CXXBaseSpecifier*> { + static const bool value = true; + }; + template<> struct IsResultPtrLowBitFree<CXXBaseOrMemberInitializer*> { + static const bool value = true; + }; + + typedef ActionBase::ActionResult<Expr*> ExprResult; + typedef ActionBase::ActionResult<Stmt*> StmtResult; + typedef ActionBase::ActionResult<void*> TypeResult; + typedef ActionBase::ActionResult<CXXBaseSpecifier*> BaseResult; + typedef ActionBase::ActionResult<CXXBaseOrMemberInitializer*> MemInitResult; + + typedef ActionBase::ActionResult<Decl*> DeclResult; } #endif diff --git a/include/clang/Sema/ParsedTemplate.h b/include/clang/Sema/ParsedTemplate.h index 8a3a96136e..c420404c90 100644 --- a/include/clang/Sema/ParsedTemplate.h +++ b/include/clang/Sema/ParsedTemplate.h @@ -70,9 +70,9 @@ namespace clang { } /// \brief Retrieve the non-type template argument's expression. - ActionBase::ExprTy *getAsExpr() const { + Expr *getAsExpr() const { assert(Kind == NonType && "Not a non-type template argument"); - return Arg; + return static_cast<Expr*>(Arg); } /// \brief Retrieve the template template argument's template name. diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 8a7ebf17f9..0bd672f5d1 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -688,17 +688,17 @@ public: OwningExprResult Owned(Expr* E) { assert(!E || E->isRetained()); - return OwningExprResult(*this, E); + return OwningExprResult(E); } OwningExprResult Owned(ExprResult R) { if (R.isInvalid()) return ExprError(); assert(!R.get() || ((Expr*) R.get())->isRetained()); - return OwningExprResult(*this, R.get()); + return OwningExprResult(R.get()); } OwningStmtResult Owned(Stmt* S) { assert(!S || S->isRetained()); - return OwningStmtResult(*this, S); + return OwningStmtResult(S); } virtual void ActOnEndOfTranslationUnit(); @@ -2398,7 +2398,7 @@ public: bool CompleteConstructorCall(CXXConstructorDecl *Constructor, MultiExprArg ArgsPtr, SourceLocation Loc, - ASTOwningVector<&ActionBase::DeleteExpr> &ConvertedArgs); + ASTOwningVector<Expr*> &ConvertedArgs); virtual TypeTy *getDestructorName(SourceLocation TildeLoc, IdentifierInfo &II, SourceLocation NameLoc, diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 2113ac4428..8a548cf517 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -258,7 +258,7 @@ AttributeList* Parser::ParseMicrosoftDeclSpec(AttributeList *CurrAttr) { // correctly. OwningExprResult ArgExpr(ParseAssignmentExpression()); if (!ArgExpr.isInvalid()) { - ExprTy* ExprList = ArgExpr.take(); + Expr *ExprList = ArgExpr.take(); CurrAttr = new AttributeList(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, SourceLocation(), &ExprList, 1, CurrAttr, true); @@ -900,7 +900,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, goto DoneWithDeclSpec; CXXScopeSpec SS; - SS.setScopeRep(Tok.getAnnotationValue()); + SS.setScopeRep((NestedNameSpecifier*) Tok.getAnnotationValue()); SS.setRange(Tok.getAnnotationRange()); // We are looking for a qualified typename. @@ -2052,7 +2052,7 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, Decl *EnumDecl) { SourceLocation IdentLoc = ConsumeToken(); SourceLocation EqualLoc; - OwningExprResult AssignedVal(Actions); + OwningExprResult AssignedVal; if (Tok.is(tok::equal)) { EqualLoc = ConsumeToken(); AssignedVal = ParseConstantExpression(); @@ -3283,7 +3283,7 @@ void Parser::ParseBracketDeclarator(Declarator &D) { } // Remember that we parsed the empty array type. - OwningExprResult NumElements(Actions); + OwningExprResult NumElements; D.AddTypeInfo(DeclaratorChunk::getArray(0, false, false, 0, StartLoc, EndLoc), EndLoc); @@ -3329 |