Sundry incremental steps towards killing off Action.

llvm-svn: 111795
This commit is contained in:
John McCall 2010-08-23 06:44:23 +00:00
parent 65526f0190
commit 37ad551a25
25 changed files with 282 additions and 288 deletions

View File

@ -145,17 +145,17 @@ public:
// Type forwarding. All of these are statically 'void*', but they may all be // Type forwarding. All of these are statically 'void*', but they may all be
// different actual classes based on the actions in place. // different actual classes based on the actions in place.
typedef Action::ExprTy ExprTy; typedef Expr ExprTy;
typedef Action::StmtTy StmtTy; typedef Stmt StmtTy;
typedef Action::DeclGroupPtrTy DeclGroupPtrTy; typedef Action::DeclGroupPtrTy DeclGroupPtrTy;
typedef Action::TypeTy TypeTy; typedef Action::TypeTy TypeTy;
typedef Action::BaseTy BaseTy; typedef CXXBaseSpecifier BaseTy;
typedef Action::MemInitTy MemInitTy; typedef CXXBaseOrMemberInitializer MemInitTy;
typedef Action::CXXScopeTy CXXScopeTy; typedef NestedNameSpecifier CXXScopeTy;
typedef Action::TemplateParamsTy TemplateParamsTy; typedef TemplateParameterList TemplateParamsTy;
typedef Action::TemplateTy TemplateTy; typedef Action::TemplateTy TemplateTy;
typedef llvm::SmallVector<TemplateParamsTy *, 4> TemplateParameterLists; typedef llvm::SmallVector<TemplateParameterList *, 4> TemplateParameterLists;
typedef Action::ExprResult ExprResult; typedef Action::ExprResult ExprResult;
typedef Action::StmtResult StmtResult; typedef Action::StmtResult StmtResult;
@ -172,20 +172,20 @@ public:
/// Adorns a ExprResult with Actions to make it an OwningExprResult /// Adorns a ExprResult with Actions to make it an OwningExprResult
OwningExprResult Owned(ExprResult res) { OwningExprResult Owned(ExprResult res) {
return OwningExprResult(Actions, res); return OwningExprResult(res);
} }
/// Adorns a StmtResult with Actions to make it an OwningStmtResult /// Adorns a StmtResult with Actions to make it an OwningStmtResult
OwningStmtResult Owned(StmtResult res) { OwningStmtResult Owned(StmtResult res) {
return OwningStmtResult(Actions, res); return OwningStmtResult(res);
} }
OwningExprResult ExprError() { return OwningExprResult(Actions, true); } OwningExprResult ExprError() { return OwningExprResult(true); }
OwningStmtResult StmtError() { return OwningStmtResult(Actions, true); } OwningStmtResult StmtError() { return OwningStmtResult(true); }
OwningExprResult ExprError(const DiagnosticBuilder &) { return ExprError(); } OwningExprResult ExprError(const DiagnosticBuilder &) { return ExprError(); }
OwningStmtResult StmtError(const DiagnosticBuilder &) { return StmtError(); } OwningStmtResult StmtError(const DiagnosticBuilder &) { return StmtError(); }
OwningExprResult ExprEmpty() { return OwningExprResult(Actions, false); } OwningExprResult ExprEmpty() { return OwningExprResult(false); }
// Parsing methods. // Parsing methods.
@ -949,16 +949,17 @@ private:
TypeTy *&CastTy, TypeTy *&CastTy,
SourceRange &CastRange); SourceRange &CastRange);
static const unsigned ExprListSize = 12; typedef llvm::SmallVector<Expr*, 20> ExprListTy;
typedef llvm::SmallVector<ExprTy*, ExprListSize> ExprListTy; typedef llvm::SmallVector<SourceLocation, 20> CommaLocsTy;
typedef llvm::SmallVector<SourceLocation, ExprListSize> CommaLocsTy;
/// ParseExpressionList - Used for C/C++ (argument-)expression-list. /// ParseExpressionList - Used for C/C++ (argument-)expression-list.
bool ParseExpressionList(ExprListTy &Exprs, CommaLocsTy &CommaLocs, bool ParseExpressionList(llvm::SmallVectorImpl<Expr*> &Exprs,
void (Action::*Completer)(Scope *S, void *Data, llvm::SmallVectorImpl<SourceLocation> &CommaLocs,
ExprTy **Args, void (Action::*Completer)(Scope *S,
Expr *Data,
Expr **Args,
unsigned NumArgs) = 0, unsigned NumArgs) = 0,
void *Data = 0); Expr *Data = 0);
/// ParenParseOption - Control what ParseParenExpression will parse. /// ParenParseOption - Control what ParseParenExpression will parse.
enum ParenParseOption { enum ParenParseOption {
@ -1040,7 +1041,8 @@ private:
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// C++ 5.3.4 and 5.3.5: C++ new and delete // 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); void ParseDirectNewDeclarator(Declarator &D);
OwningExprResult ParseCXXNewExpression(bool UseGlobal, SourceLocation Start); OwningExprResult ParseCXXNewExpression(bool UseGlobal, SourceLocation Start);
OwningExprResult ParseCXXDeleteExpression(bool UseGlobal, OwningExprResult ParseCXXDeleteExpression(bool UseGlobal,

View File

@ -31,6 +31,7 @@ namespace clang {
class CXXScopeSpec; class CXXScopeSpec;
class Declarator; class Declarator;
class AttributeList; class AttributeList;
class TemplateParameterList;
struct FieldDeclarator; struct FieldDeclarator;
// Parse. // Parse.
class Scope; class Scope;
@ -84,23 +85,23 @@ public:
typedef clang::StmtResult StmtResult; typedef clang::StmtResult StmtResult;
typedef clang::TypeResult TypeResult; typedef clang::TypeResult TypeResult;
typedef clang::BaseResult BaseResult; typedef clang::BaseResult BaseResult;
typedef clang::MemInitResult MemInitResult;
typedef clang::DeclResult DeclResult; typedef clang::DeclResult DeclResult;
typedef clang::MemInitResult MemInitResult;
/// Same, but with ownership. /// Same, but with ownership.
typedef ASTOwningResult<&ActionBase::DeleteExpr> OwningExprResult; typedef ASTOwningResult<Expr*> OwningExprResult;
typedef ASTOwningResult<&ActionBase::DeleteStmt> OwningStmtResult; typedef ASTOwningResult<Stmt*> OwningStmtResult;
// Note that these will replace ExprResult and StmtResult when the transition // Note that these will replace ExprResult and StmtResult when the transition
// is complete. // is complete.
/// Single expressions or statements as arguments. /// Single expressions or statements as arguments.
typedef ASTOwningPtr<&ActionBase::DeleteExpr> ExprArg; typedef ASTOwningPtr<Expr*> ExprArg;
typedef ASTOwningPtr<&ActionBase::DeleteStmt> StmtArg; typedef ASTOwningPtr<Stmt*> StmtArg;
/// Multiple expressions or statements as arguments. /// Multiple expressions or statements as arguments.
typedef ASTMultiPtr<&ActionBase::DeleteExpr> MultiExprArg; typedef ASTMultiPtr<Expr*> MultiExprArg;
typedef ASTMultiPtr<&ActionBase::DeleteStmt> MultiStmtArg; typedef ASTMultiPtr<Stmt*> MultiStmtArg;
typedef ASTMultiPtr<&ActionBase::DeleteTemplateParams> MultiTemplateParamsArg; typedef ASTMultiPtr<TemplateParameterList*> MultiTemplateParamsArg;
class FullExprArg { class FullExprArg {
public: public:
@ -143,14 +144,14 @@ public:
// Utilities for Action implementations to return smart results. // Utilities for Action implementations to return smart results.
OwningExprResult ExprError() { return OwningExprResult(*this, true); } OwningExprResult ExprError() { return OwningExprResult(true); }
OwningStmtResult StmtError() { return OwningStmtResult(*this, true); } OwningStmtResult StmtError() { return OwningStmtResult(true); }
OwningExprResult ExprError(const DiagnosticBuilder&) { return ExprError(); } OwningExprResult ExprError(const DiagnosticBuilder&) { return ExprError(); }
OwningStmtResult StmtError(const DiagnosticBuilder&) { return StmtError(); } OwningStmtResult StmtError(const DiagnosticBuilder&) { return StmtError(); }
OwningExprResult ExprEmpty() { return OwningExprResult(*this, false); } OwningExprResult ExprEmpty() { return OwningExprResult(false); }
OwningStmtResult StmtEmpty() { return OwningStmtResult(*this, false); } OwningStmtResult StmtEmpty() { return OwningStmtResult(false); }
/// Statistics. /// Statistics.
virtual void PrintStats() const {} virtual void PrintStats() const {}
@ -783,9 +784,7 @@ public:
virtual void ActOnForEachDeclStmt(DeclGroupPtrTy Decl) { virtual void ActOnForEachDeclStmt(DeclGroupPtrTy Decl) {
} }
virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr) { virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr) = 0;
return OwningStmtResult(*this, Expr->release());
}
/// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension, /// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension,
/// which can specify an RHS value. The sub-statement of the case is /// which can specify an RHS value. The sub-statement of the case is
@ -2576,9 +2575,7 @@ public:
SourceLocation LBracLoc, SourceLocation LBracLoc,
SourceLocation SelectorLoc, SourceLocation SelectorLoc,
SourceLocation RBracLoc, SourceLocation RBracLoc,
MultiExprArg Args) { MultiExprArg Args) = 0;
return OwningExprResult(*this);
}
/// \brief Parsed a message send to a class. /// \brief Parsed a message send to a class.
/// ///
@ -2595,9 +2592,7 @@ public:
SourceLocation LBracLoc, SourceLocation LBracLoc,
SourceLocation SelectorLoc, SourceLocation SelectorLoc,
SourceLocation RBracLoc, SourceLocation RBracLoc,
MultiExprArg Args) { MultiExprArg Args) = 0;
return OwningExprResult(*this);
}
/// \brief Parsed a message send to an object instance. /// \brief Parsed a message send to an object instance.
/// ///
@ -2614,9 +2609,7 @@ public:
SourceLocation LBracLoc, SourceLocation LBracLoc,
SourceLocation SelectorLoc, SourceLocation SelectorLoc,
SourceLocation RBracLoc, SourceLocation RBracLoc,
MultiExprArg Args) { MultiExprArg Args) = 0;
return OwningExprResult(*this);
}
virtual Decl *ActOnForwardClassDeclaration( virtual Decl *ActOnForwardClassDeclaration(
SourceLocation AtClassLoc, SourceLocation AtClassLoc,
@ -2847,8 +2840,8 @@ public:
/// \param Args the arguments to the function call (so far). /// \param Args the arguments to the function call (so far).
/// ///
/// \param NumArgs the number of arguments in \p Args. /// \param NumArgs the number of arguments in \p Args.
virtual void CodeCompleteCall(Scope *S, ExprTy *Fn, virtual void CodeCompleteCall(Scope *S, Expr *Fn,
ExprTy **Args, unsigned NumArgs) { } Expr **Args, unsigned NumArgs) { }
/// \brief Code completion for the initializer of a variable declaration. /// \brief Code completion for the initializer of a variable declaration.
/// ///

View File

@ -22,6 +22,7 @@
namespace clang { namespace clang {
class IdentifierInfo; class IdentifierInfo;
class Action; class Action;
class Expr;
/// AttributeList - Represents GCC's __attribute__ declaration. There are /// AttributeList - Represents GCC's __attribute__ declaration. There are
/// 4 forms of this construct...they are: /// 4 forms of this construct...they are:
@ -49,7 +50,7 @@ public:
AttributeList(IdentifierInfo *AttrName, SourceLocation AttrLoc, AttributeList(IdentifierInfo *AttrName, SourceLocation AttrLoc,
IdentifierInfo *ScopeName, SourceLocation ScopeLoc, IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
IdentifierInfo *ParmName, SourceLocation ParmLoc, IdentifierInfo *ParmName, SourceLocation ParmLoc,
ActionBase::ExprTy **args, unsigned numargs, Expr **args, unsigned numargs,
AttributeList *Next, bool declspec = false, bool cxx0x = false); AttributeList *Next, bool declspec = false, bool cxx0x = false);
~AttributeList(); ~AttributeList();

View File

@ -30,6 +30,7 @@ namespace clang {
class LangOptions; class LangOptions;
class Diagnostic; class Diagnostic;
class IdentifierInfo; class IdentifierInfo;
class NestedNameSpecifier;
class Preprocessor; class Preprocessor;
class Declarator; class Declarator;
struct TemplateIdAnnotation; struct TemplateIdAnnotation;
@ -47,7 +48,7 @@ namespace clang {
/// The actual scope is described by getScopeRep(). /// The actual scope is described by getScopeRep().
class CXXScopeSpec { class CXXScopeSpec {
SourceRange Range; SourceRange Range;
void *ScopeRep; NestedNameSpecifier *ScopeRep;
public: public:
CXXScopeSpec() : Range(), ScopeRep() { } CXXScopeSpec() : Range(), ScopeRep() { }
@ -59,7 +60,7 @@ public:
SourceLocation getBeginLoc() const { return Range.getBegin(); } SourceLocation getBeginLoc() const { return Range.getBegin(); }
SourceLocation getEndLoc() const { return Range.getEnd(); } SourceLocation getEndLoc() const { return Range.getEnd(); }
ActionBase::CXXScopeTy *getScopeRep() const { return ScopeRep; } NestedNameSpecifier *getScopeRep() const { return ScopeRep; }
void setScopeRep(ActionBase::CXXScopeTy *S) { ScopeRep = S; } void setScopeRep(ActionBase::CXXScopeTy *S) { ScopeRep = S; }
/// No scope specifier. /// No scope specifier.
@ -799,7 +800,7 @@ struct DeclaratorChunk {
/// This is the size of the array, or null if [] or [*] was specified. /// 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 /// Since the parser is multi-purpose, and we don't want to impose a root
/// expression class on all clients, NumElts is untyped. /// expression class on all clients, NumElts is untyped.
ActionBase::ExprTy *NumElts; Expr *NumElts;
void destroy() {} void destroy() {}
}; };
@ -1010,7 +1011,7 @@ struct DeclaratorChunk {
/// getArray - Return a DeclaratorChunk for an array. /// getArray - Return a DeclaratorChunk for an array.
/// ///
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic,
bool isStar, void *NumElts, bool isStar, Expr *NumElts,
SourceLocation LBLoc, SourceLocation RBLoc) { SourceLocation LBLoc, SourceLocation RBLoc) {
DeclaratorChunk I; DeclaratorChunk I;
I.Kind = Array; I.Kind = Array;

View File

@ -23,7 +23,14 @@
namespace clang { namespace clang {
class ActionBase; class ActionBase;
class Attr;
class CXXBaseOrMemberInitializer;
class CXXBaseSpecifier;
class Decl; class Decl;
class Expr;
class NestedNameSpecifier;
class Stmt;
class TemplateParameterList;
/// OpaquePtr - This is a very simple POD type that wraps a pointer that the /// 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 /// 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 // Determines whether the low bit of the result pointer for the
// given UID is always zero. If so, ActionResult will use that bit // given UID is always zero. If so, ActionResult will use that bit
// for it's "invalid" flag. // for it's "invalid" flag.
template<unsigned UID> template<class Ptr>
struct IsResultPtrLowBitFree { struct IsResultPtrLowBitFree {
static const bool value = false; static const bool value = false;
}; };
@ -202,13 +209,13 @@ namespace clang {
// what types are required to be identical for the actions. // what types are required to be identical for the actions.
typedef OpaquePtr<1> DeclGroupPtrTy; typedef OpaquePtr<1> DeclGroupPtrTy;
typedef OpaquePtr<2> TemplateTy; typedef OpaquePtr<2> TemplateTy;
typedef void AttrTy; typedef Attr AttrTy;
typedef void BaseTy; typedef CXXBaseSpecifier BaseTy;
typedef void MemInitTy; typedef CXXBaseOrMemberInitializer MemInitTy;
typedef void ExprTy; typedef Expr ExprTy;
typedef void StmtTy; typedef Stmt StmtTy;
typedef void TemplateParamsTy; typedef TemplateParameterList TemplateParamsTy;
typedef void CXXScopeTy; typedef NestedNameSpecifier CXXScopeTy;
typedef void TypeTy; // FIXME: Change TypeTy to use OpaquePtr<N>. typedef void TypeTy; // FIXME: Change TypeTy to use OpaquePtr<N>.
/// ActionResult - This structure is used while parsing/acting on /// 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. /// the action, plus a sense of whether or not it is valid.
/// When CompressInvalid is true, the "invalid" flag will be /// When CompressInvalid is true, the "invalid" flag will be
/// stored in the low bit of the Val pointer. /// stored in the low bit of the Val pointer.
template<unsigned UID, template<class PtrTy,
typename PtrTy = void*, bool CompressInvalid = IsResultPtrLowBitFree<PtrTy>::value>
bool CompressInvalid = IsResultPtrLowBitFree<UID>::value>
class ActionResult { class ActionResult {
PtrTy Val; PtrTy Val;
bool Invalid; bool Invalid;
public: public:
ActionResult(bool Invalid = false) : Val(PtrTy()), Invalid(Invalid) {} ActionResult(bool Invalid = false) : Val(PtrTy()), Invalid(Invalid) {}
template<typename ActualExprTy> ActionResult(PtrTy val) : Val(val), Invalid(false) {}
ActionResult(ActualExprTy val) : Val(val), Invalid(false) {}
ActionResult(const DiagnosticBuilder &) : Val(PtrTy()), Invalid(true) {} 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; } PtrTy get() const { return Val; }
void set(PtrTy V) { Val = V; } void set(PtrTy V) { Val = V; }
bool isInvalid() const { return Invalid; } bool isInvalid() const { return Invalid; }
@ -242,8 +251,8 @@ namespace clang {
// This ActionResult partial specialization places the "invalid" // This ActionResult partial specialization places the "invalid"
// flag into the low bit of the pointer. // flag into the low bit of the pointer.
template<unsigned UID, typename PtrTy> template<typename PtrTy>
class ActionResult<UID, PtrTy, true> { class ActionResult<PtrTy, true> {
// A pointer whose low bit is 1 if this result is invalid, 0 // A pointer whose low bit is 1 if this result is invalid, 0
// otherwise. // otherwise.
uintptr_t PtrWithInvalid; uintptr_t PtrWithInvalid;
@ -252,20 +261,16 @@ namespace clang {
ActionResult(bool Invalid = false) ActionResult(bool Invalid = false)
: PtrWithInvalid(static_cast<uintptr_t>(Invalid)) { } : 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) { ActionResult(PtrTy V) {
void *VP = PtrTraits::getAsVoidPointer(V); void *VP = PtrTraits::getAsVoidPointer(V);
PtrWithInvalid = reinterpret_cast<uintptr_t>(VP); PtrWithInvalid = reinterpret_cast<uintptr_t>(VP);
assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer"); 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) { } ActionResult(const DiagnosticBuilder &) : PtrWithInvalid(0x01) { }
PtrTy get() const { PtrTy get() const {
@ -298,80 +303,68 @@ namespace clang {
virtual void DeleteTemplateParams(TemplateParamsTy *P) {} 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 /// ASTOwningResult - A moveable smart pointer for AST nodes that also
/// has an extra flag to indicate an additional success status. /// 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 /// ASTMultiPtr - A moveable smart pointer to multiple AST nodes. Only owns
/// the individual pointers, not the array holding them. /// 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. /// Kept only as a type-safe wrapper for a void pointer.
template <ASTDestroyer Destroyer> template <typename PtrTy> class ASTOwningPtr {
class ASTOwningPtr { PtrTy Node;
void *Node;
public: public:
explicit ASTOwningPtr(ActionBase &) : Node(0) {} 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 & operator =(void *raw) { // Normal copying operators are defined implicitly.
ASTOwningPtr(const ASTOwningResult<PtrTy> &o);
ASTOwningPtr & operator =(PtrTy raw) {
Node = raw; Node = raw;
return *this; return *this;
} }
/// Access to the raw pointer. /// Access to the raw pointer.
void * get() const { return Node; } PtrTy get() const { return Node; }
/// Release the raw pointer. /// Release the raw pointer.
void * take() { PtrTy take() { return Node; }
return Node;
}
/// Take outside ownership of the raw pointer and cast it down. /// Take outside ownership of the raw pointer and cast it down.
template<typename T> template<typename T> T *takeAs() {
T *takeAs() {
return static_cast<T*>(Node); return static_cast<T*>(Node);
} }
/// Alias for interface familiarity with unique_ptr. /// Alias for interface familiarity with unique_ptr.
void * release() { PtrTy release() {
return take(); return take();
} }
}; };
template <ASTDestroyer Destroyer> template <class PtrTy> class ASTOwningResult {
class ASTOwningResult {
public: public:
typedef ActionBase::ActionResult<DestroyerToUID<Destroyer>::UID> DumbResult; typedef ActionBase::ActionResult<PtrTy> DumbResult;
private: private:
DumbResult Result; DumbResult Result;
public: public:
explicit ASTOwningResult(ActionBase &actions, bool invalid = false) explicit ASTOwningResult(bool invalid = false)
: Result(invalid) { } : Result(invalid) { }
ASTOwningResult(ActionBase &actions, void *node) : Result(node) { } explicit ASTOwningResult(PtrTy node) : Result(node) { }
ASTOwningResult(ActionBase &actions, const DumbResult &res) : Result(res) { } explicit ASTOwningResult(const DumbResult &res) : Result(res) { }
// Normal copying semantics are defined implicitly. // 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! /// Assignment from a raw pointer. Takes ownership - beware!
ASTOwningResult & operator =(void *raw) { ASTOwningResult & operator =(PtrTy raw) {
Result = raw; Result = raw;
return *this; return *this;
} }
@ -383,7 +376,7 @@ namespace clang {
} }
/// Access to the raw pointer. /// Access to the raw pointer.
void * get() const { return Result.get(); } PtrTy get() const { return Result.get(); }
bool isInvalid() const { return Result.isInvalid(); } bool isInvalid() const { return Result.isInvalid(); }
@ -392,7 +385,7 @@ namespace clang {
bool isUsable() const { return !Result.isInvalid() && get(); } bool isUsable() const { return !Result.isInvalid() && get(); }
/// Take outside ownership of the raw pointer. /// Take outside ownership of the raw pointer.
void * take() { PtrTy take() {
return Result.get(); return Result.get();
} }
@ -403,32 +396,32 @@ namespace clang {
} }
/// Alias for interface familiarity with unique_ptr. /// Alias for interface familiarity with unique_ptr.
void * release() { return take(); } PtrTy release() { return take(); }
/// Pass ownership to a classical ActionResult. /// Pass ownership to a classical ActionResult.
DumbResult result() { return Result; } DumbResult result() { return Result; }
}; };
template <ASTDestroyer Destroyer> template <class PtrTy>
class ASTMultiPtr { class ASTMultiPtr {
void **Nodes; PtrTy *Nodes;
unsigned Count; unsigned Count;
public: public:
// Normal copying implicitly defined // Normal copying implicitly defined
explicit ASTMultiPtr(ActionBase &) : Nodes(0), Count(0) {} explicit ASTMultiPtr(ActionBase &) : Nodes(0), Count(0) {}
ASTMultiPtr(ActionBase &, void **nodes, unsigned count) ASTMultiPtr(ActionBase &, PtrTy *nodes, unsigned count)
: Nodes(nodes), Count(count) {} : Nodes(nodes), Count(count) {}
// Fake mover in Parse/AstGuard.h needs this: // 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. /// Access to the raw pointers.
void ** get() const { return Nodes; } PtrTy *get() const { return Nodes; }
/// Access to the count. /// Access to the count.
unsigned size() const { return Count; } unsigned size() const { return Count; }
void ** release() { PtrTy *release() {
return Nodes; return Nodes;
} }
}; };
@ -472,8 +465,8 @@ namespace clang {
}; };
/// \brief A small vector that owns a set of AST nodes. /// \brief A small vector that owns a set of AST nodes.
template <ASTDestroyer Destroyer, unsigned N = 8> template <class PtrTy, unsigned N = 8>
class ASTOwningVector : public llvm::SmallVector<void *, N> { class ASTOwningVector : public llvm::SmallVector<PtrTy, N> {
ASTOwningVector(ASTOwningVector &); // do not implement ASTOwningVector(ASTOwningVector &); // do not implement
ASTOwningVector &operator=(ASTOwningVector &); // do not implement ASTOwningVector &operator=(ASTOwningVector &); // do not implement
@ -481,60 +474,67 @@ namespace clang {
explicit ASTOwningVector(ActionBase &Actions) explicit ASTOwningVector(ActionBase &Actions)
{ } { }
void **take() { PtrTy *take() {
return &this->front(); 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 /// A SmallVector of statements, with stack size 32 (as that is the only one
/// used.) /// used.)
typedef ASTOwningVector<&ActionBase::DeleteStmt, 32> StmtVector; typedef ASTOwningVector<Stmt*, 32> StmtVector;
/// A SmallVector of expressions, with stack size 12 (the maximum used.) /// 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 template <class T, unsigned N> inline
ASTMultiPtr<Destroyer> move_arg(ASTOwningVector<Destroyer, N> &vec) { ASTMultiPtr<T> move_arg(ASTOwningVector<T, N> &vec) {
return ASTMultiPtr<Destroyer>(vec.take(), vec.size()); return ASTMultiPtr<T>(vec.take(), vec.size());
} }
template <ASTDestroyer Destroyer> inline template <class T> inline
ASTOwningPtr<Destroyer>::ASTOwningPtr(const ASTOwningResult<Destroyer> &o) ASTOwningPtr<T>::ASTOwningPtr(const ASTOwningResult<T> &o)
: Node(o.get()) { } : Node(o.get()) { }
// These versions are hopefully no-ops. // These versions are hopefully no-ops.
template <ASTDestroyer Destroyer> inline template <class T> inline
ASTOwningResult<Destroyer>& move(ASTOwningResult<Destroyer> &ptr) { ASTOwningResult<T>& move(ASTOwningResult<T> &ptr) {
return ptr; return ptr;
} }
template <ASTDestroyer Destroyer> inline template <class T> inline
ASTOwningPtr<Destroyer>& move(ASTOwningPtr<Destroyer> &ptr) { ASTOwningPtr<T>& move(ASTOwningPtr<T> &ptr) {
return ptr; return ptr;
} }
template <ASTDestroyer Destroyer> inline template <class T> inline
ASTMultiPtr<Destroyer>& move(ASTMultiPtr<Destroyer> &ptr) { ASTMultiPtr<T>& move(ASTMultiPtr<T> &ptr) {
return ptr; return ptr;
} }
// We can re-use the low bit of expression, statement, base, and // We can re-use the low bit of expression, statement, base, and
// member-initializer pointers for the "invalid" flag of // member-initializer pointers for the "invalid" flag of
// ActionResult. // ActionResult.
template<> struct IsResultPtrLowBitFree<0> { static const bool value = true;}; template<> struct IsResultPtrLowBitFree<Expr*> {
template<> struct IsResultPtrLowBitFree<1> { static const bool value = true;}; 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<Stmt*> {
template<> struct IsResultPtrLowBitFree<5> { static const bool value = true;}; 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<0> ExprResult; typedef ActionBase::ActionResult<Expr*> ExprResult;
typedef ActionBase::ActionResult<1> StmtResult; typedef ActionBase::ActionResult<Stmt*> StmtResult;
typedef ActionBase::ActionResult<2> TypeResult; typedef ActionBase::ActionResult<void*> TypeResult;
typedef ActionBase::ActionResult<3> BaseResult; typedef ActionBase::ActionResult<CXXBaseSpecifier*> BaseResult;
typedef ActionBase::ActionResult<4> MemInitResult; typedef ActionBase::ActionResult<CXXBaseOrMemberInitializer*> MemInitResult;
typedef ActionBase::ActionResult<5, Decl*> DeclResult; typedef ActionBase::ActionResult<Decl*> DeclResult;
} }
#endif #endif

View File

@ -70,9 +70,9 @@ namespace clang {
} }
/// \brief Retrieve the non-type template argument's expression. /// \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"); 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. /// \brief Retrieve the template template argument's template name.

View File

@ -688,17 +688,17 @@ public:
OwningExprResult Owned(Expr* E) { OwningExprResult Owned(Expr* E) {
assert(!E || E->isRetained()); assert(!E || E->isRetained());
return OwningExprResult(*this, E); return OwningExprResult(E);
} }
OwningExprResult Owned(ExprResult R) { OwningExprResult Owned(ExprResult R) {
if (R.isInvalid()) if (R.isInvalid())
return ExprError(); return ExprError();
assert(!R.get() || ((Expr*) R.get())->isRetained()); assert(!R.get() || ((Expr*) R.get())->isRetained());
return OwningExprResult(*this, R.get()); return OwningExprResult(R.get());
} }
OwningStmtResult Owned(Stmt* S) { OwningStmtResult Owned(Stmt* S) {
assert(!S || S->isRetained()); assert(!S || S->isRetained());
return OwningStmtResult(*this, S); return OwningStmtResult(S);
} }
virtual void ActOnEndOfTranslationUnit(); virtual void ActOnEndOfTranslationUnit();
@ -2398,7 +2398,7 @@ public:
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, bool CompleteConstructorCall(CXXConstructorDecl *Constructor,
MultiExprArg ArgsPtr, MultiExprArg ArgsPtr,
SourceLocation Loc, SourceLocation Loc,
ASTOwningVector<&ActionBase::DeleteExpr> &ConvertedArgs); ASTOwningVector<Expr*> &ConvertedArgs);
virtual TypeTy *getDestructorName(SourceLocation TildeLoc, virtual TypeTy *getDestructorName(SourceLocation TildeLoc,
IdentifierInfo &II, SourceLocation NameLoc, IdentifierInfo &II, SourceLocation NameLoc,

View File

@ -258,7 +258,7 @@ AttributeList* Parser::ParseMicrosoftDeclSpec(AttributeList *CurrAttr) {
// correctly. // correctly.
OwningExprResult ArgExpr(ParseAssignmentExpression()); OwningExprResult ArgExpr(ParseAssignmentExpression());
if (!ArgExpr.isInvalid()) { if (!ArgExpr.isInvalid()) {
ExprTy* ExprList = ArgExpr.take(); Expr *ExprList = ArgExpr.take();
CurrAttr = new AttributeList(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, CurrAttr = new AttributeList(AttrName, AttrNameLoc, 0, AttrNameLoc, 0,
SourceLocation(), &ExprList, 1, SourceLocation(), &ExprList, 1,
CurrAttr, true); CurrAttr, true);
@ -900,7 +900,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
goto DoneWithDeclSpec; goto DoneWithDeclSpec;
CXXScopeSpec SS; CXXScopeSpec SS;
SS.setScopeRep(Tok.getAnnotationValue()); SS.setScopeRep((NestedNameSpecifier*) Tok.getAnnotationValue());
SS.setRange(Tok.getAnnotationRange()); SS.setRange(Tok.getAnnotationRange());
// We are looking for a qualified typename. // We are looking for a qualified typename.
@ -2052,7 +2052,7 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, Decl *EnumDecl) {
SourceLocation IdentLoc = ConsumeToken(); SourceLocation IdentLoc = ConsumeToken();
SourceLocation EqualLoc; SourceLocation EqualLoc;
OwningExprResult AssignedVal(Actions); OwningExprResult AssignedVal;
if (Tok.is(tok::equal)) { if (Tok.is(tok::equal)) {
EqualLoc = ConsumeToken(); EqualLoc = ConsumeToken();
AssignedVal = ParseConstantExpression(); AssignedVal = ParseConstantExpression();
@ -3283,7 +3283,7 @@ void Parser::ParseBracketDeclarator(Declarator &D) {
} }
// Remember that we parsed the empty array type. // Remember that we parsed the empty array type.
OwningExprResult NumElements(Actions); OwningExprResult NumElements;
D.AddTypeInfo(DeclaratorChunk::getArray(0, false, false, 0, D.AddTypeInfo(DeclaratorChunk::getArray(0, false, false, 0,
StartLoc, EndLoc), StartLoc, EndLoc),
EndLoc); EndLoc);
@ -3329,7 +3329,7 @@ void Parser::ParseBracketDeclarator(Declarator &D) {
// Handle "direct-declarator [ type-qual-list[opt] * ]". // Handle "direct-declarator [ type-qual-list[opt] * ]".
bool isStar = false; bool isStar = false;
OwningExprResult NumElements(Actions); OwningExprResult NumElements;
// Handle the case where we have '[*]' as the array size. However, a leading // Handle the case where we have '[*]' as the array size. However, a leading
// star could be the start of an expression, for example 'X[*p + 4]'. Verify // star could be the start of an expression, for example 'X[*p + 4]'. Verify

View File

@ -1070,7 +1070,7 @@ void Parser::ParseBaseClause(Decl *ClassDecl) {
ConsumeToken(); ConsumeToken();
// Build up an array of parsed base specifiers. // Build up an array of parsed base specifiers.
llvm::SmallVector<BaseTy *, 8> BaseInfo; llvm::SmallVector<CXXBaseSpecifier *, 8> BaseInfo;
while (true) { while (true) {
// Parse a base-specifier. // Parse a base-specifier.
@ -1406,8 +1406,8 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
// member-declarator-list ',' member-declarator // member-declarator-list ',' member-declarator
llvm::SmallVector<Decl *, 8> DeclsInGroup; llvm::SmallVector<Decl *, 8> DeclsInGroup;
OwningExprResult BitfieldSize(Actions); OwningExprResult BitfieldSize;
OwningExprResult Init(Actions); OwningExprResult Init;
bool Deleted = false; bool Deleted = false;
while (1) { while (1) {
@ -1706,7 +1706,7 @@ void Parser::ParseConstructorInitializer(Decl *ConstructorDecl) {
SourceLocation ColonLoc = ConsumeToken(); SourceLocation ColonLoc = ConsumeToken();
llvm::SmallVector<MemInitTy*, 4> MemInitializers; llvm::SmallVector<CXXBaseOrMemberInitializer*, 4> MemInitializers;
bool AnyErrors = false; bool AnyErrors = false;
do { do {

View File

@ -200,7 +200,7 @@ Parser::ParseExpressionWithLeadingAt(SourceLocation AtLoc) {
/// process of disambiguating between an expression and a declaration. /// process of disambiguating between an expression and a declaration.
Parser::OwningExprResult Parser::OwningExprResult
Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) { Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) {
OwningExprResult LHS(Actions, true); OwningExprResult LHS(true);
{ {
// Silence extension warnings in the sub-expression // Silence extension warnings in the sub-expression
ExtensionRAIIObject O(Diags); ExtensionRAIIObject O(Diags);
@ -290,7 +290,7 @@ Parser::ParseRHSOfBinaryExpression(OwningExprResult LHS, prec::Level MinPrec) {
ConsumeToken(); ConsumeToken();
// Special case handling for the ternary operator. // Special case handling for the ternary operator.
OwningExprResult TernaryMiddle(Actions, true); OwningExprResult TernaryMiddle(true);
if (NextTokPrec == prec::Conditional) { if (NextTokPrec == prec::Conditional) {
if (Tok.isNot(tok::colon)) { if (Tok.isNot(tok::colon)) {
// Don't parse FOO:BAR as if it were a typo for FOO::BAR. // Don't parse FOO:BAR as if it were a typo for FOO::BAR.
@ -357,7 +357,7 @@ Parser::ParseRHSOfBinaryExpression(OwningExprResult LHS, prec::Level MinPrec) {
// Therefore we need some special-casing here. // Therefore we need some special-casing here.
// Also note that the third operand of the conditional operator is // Also note that the third operand of the conditional operator is
// an assignment-expression in C++. // an assignment-expression in C++.
OwningExprResult RHS(Actions); OwningExprResult RHS;
if (getLang().CPlusPlus && NextTokPrec <= prec::Conditional) if (getLang().CPlusPlus && NextTokPrec <= prec::Conditional)
RHS = ParseAssignmentExpression(); RHS = ParseAssignmentExpression();
else else
@ -549,7 +549,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
bool isAddressOfOperand, bool isAddressOfOperand,
bool &NotCastExpr, bool &NotCastExpr,
TypeTy *TypeOfCast) { TypeTy *TypeOfCast) {
OwningExprResult Res(Actions); OwningExprResult Res;
tok::TokenKind SavedKind = Tok.getKind(); tok::TokenKind SavedKind = Tok.getKind();
NotCastExpr = false; NotCastExpr = false;
@ -1127,7 +1127,7 @@ Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok,
OpTok.is(tok::kw___alignof) || OpTok.is(tok::kw_alignof)) && OpTok.is(tok::kw___alignof) || OpTok.is(tok::kw_alignof)) &&
"Not a typeof/sizeof/alignof expression!"); "Not a typeof/sizeof/alignof expression!");
OwningExprResult Operand(Actions); OwningExprResult Operand;
// If the operand doesn't start with an '(', it must be an expression. // If the operand doesn't start with an '(', it must be an expression.
if (Tok.isNot(tok::l_paren)) { if (Tok.isNot(tok::l_paren)) {
@ -1241,7 +1241,7 @@ Parser::OwningExprResult Parser::ParseSizeofAlignofExpression() {
/// [GNU] offsetof-member-designator '[' expression ']' /// [GNU] offsetof-member-designator '[' expression ']'
/// ///
Parser::OwningExprResult Parser::ParseBuiltinPrimaryExpression() { Parser::OwningExprResult Parser::ParseBuiltinPrimaryExpression() {
OwningExprResult Res(Actions); OwningExprResult Res;
const IdentifierInfo *BuiltinII = Tok.getIdentifierInfo(); const IdentifierInfo *BuiltinII = Tok.getIdentifierInfo();
tok::TokenKind T = Tok.getKind(); tok::TokenKind T = Tok.getKind();
@ -1428,7 +1428,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
assert(Tok.is(tok::l_paren) && "Not a paren expr!"); assert(Tok.is(tok::l_paren) && "Not a paren expr!");
GreaterThanIsOperatorScope G(GreaterThanIsOperator, true); GreaterThanIsOperatorScope G(GreaterThanIsOperator, true);
SourceLocation OpenLoc = ConsumeParen(); SourceLocation OpenLoc = ConsumeParen();
OwningExprResult Result(Actions, true); OwningExprResult Result(true);
bool isAmbiguousTypeId; bool isAmbiguousTypeId;
CastTy = 0; CastTy = 0;
@ -1479,7 +1479,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
// Note that this doesn't parse the subsequent cast-expression, it just // Note that this doesn't parse the subsequent cast-expression, it just
// returns the parsed type to the callee. // returns the parsed type to the callee.
if (stopIfCastExpr) if (stopIfCastExpr)
return OwningExprResult(Actions); return OwningExprResult();
// Reject the cast of super idiom in ObjC. // Reject the cast of super idiom in ObjC.
if (Tok.is(tok::identifier) && getLang().ObjC1 && if (Tok.is(tok::identifier) && getLang().ObjC1 &&
@ -1585,12 +1585,13 @@ Parser::OwningExprResult Parser::ParseStringLiteralExpression() {
/// [C++] assignment-expression /// [C++] assignment-expression
/// [C++] expression-list , assignment-expression /// [C++] expression-list , assignment-expression
/// ///
bool Parser::ParseExpressionList(ExprListTy &Exprs, CommaLocsTy &CommaLocs, bool Parser::ParseExpressionList(llvm::SmallVectorImpl<Expr*> &Exprs,
llvm::SmallVectorImpl<SourceLocation> &CommaLocs,
void (Action::*Completer)(Scope *S, void (Action::*Completer)(Scope *S,
void *Data, Expr *Data,
ExprTy **Args, Expr **Args,
unsigned NumArgs), unsigned NumArgs),
void *Data) { Expr *Data) {
while (1) { while (1) {
if (Tok.is(tok::code_completion)) { if (Tok.is(tok::code_completion)) {
if (Completer) if (Completer)
@ -1723,7 +1724,7 @@ Parser::OwningExprResult Parser::ParseBlockLiteralExpression() {
} }
OwningExprResult Result(Actions, true); OwningExprResult Result(true);
if (!Tok.is(tok::l_brace)) { if (!Tok.is(tok::l_brace)) {
// Saw something like: ^expr // Saw something like: ^expr
Diag(Tok, diag::err_expected_expression); Diag(Tok, diag::err_expected_expression);

View File

@ -64,7 +64,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
"Call sites of this function should be guarded by checking for C++"); "Call sites of this function should be guarded by checking for C++");
if (Tok.is(tok::annot_cxxscope)) { if (Tok.is(tok::annot_cxxscope)) {
SS.setScopeRep(Tok.getAnnotationValue()); SS.setScopeRep(static_cast<NestedNameSpecifier*>(Tok.getAnnotationValue()));
SS.setRange(Tok.getAnnotationRange()); SS.setRange(Tok.getAnnotationRange());
ConsumeToken(); ConsumeToken();
return false; return false;
@ -507,7 +507,7 @@ Parser::OwningExprResult Parser::ParseCXXTypeid() {
"typeid")) "typeid"))
return ExprError(); return ExprError();
OwningExprResult Result(Actions); OwningExprResult Result;
if (isTypeIdInParens()) { if (isTypeIdInParens()) {
TypeResult Ty = ParseTypeName(); TypeResult Ty = ParseTypeName();
@ -1698,7 +1698,8 @@ void Parser::ParseDirectNewDeclarator(Declarator &D) {
/// new-placement: /// new-placement:
/// '(' expression-list ')' /// '(' expression-list ')'
/// ///
bool Parser::ParseExpressionListOrTypeId(ExprListTy &PlacementArgs, bool Parser::ParseExpressionListOrTypeId(
llvm::SmallVectorImpl<Expr*> &PlacementArgs,
Declarator &D) { Declarator &D) {
// The '(' was already consumed. // The '(' was already consumed.
if (isTypeIdInParens()) { if (isTypeIdInParens()) {
@ -1809,7 +1810,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
assert(ExprType == CastExpr && "Compound literals are not ambiguous!"); assert(ExprType == CastExpr && "Compound literals are not ambiguous!");
assert(isTypeIdInParens() && "Not a type-id!"); assert(isTypeIdInParens() && "Not a type-id!");
OwningExprResult Result(Actions, true); OwningExprResult Result(true);
CastTy = 0; CastTy = 0;
// We need to disambiguate a very ugly part of the C++ syntax: // We need to disambiguate a very ugly part of the C++ syntax:

View File

@ -137,7 +137,7 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
// [4][foo bar] -> obsolete GNU designation with objc message send. // [4][foo bar] -> obsolete GNU designation with objc message send.
// //
SourceLocation StartLoc = ConsumeBracket(); SourceLocation StartLoc = ConsumeBracket();
OwningExprResult Idx(Actions); OwningExprResult Idx;
// If Objective-C is enabled and this is a typename (class message // If Objective-C is enabled and this is a typename (class message
// send) or send to 'super', parse this as a message send // send) or send to 'super', parse this as a message send
@ -175,7 +175,7 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
// whether we have a message send or an array designator; just // whether we have a message send or an array designator; just
// adopt the expression for further analysis below. // adopt the expression for further analysis below.
// FIXME: potentially-potentially evaluated expression above? // FIXME: potentially-potentially evaluated expression above?
Idx = OwningExprResult(Actions, TypeOrExpr); Idx = OwningExprResult(static_cast<Expr*>(TypeOrExpr));
} else if (getLang().ObjC1 && Tok.is(tok::identifier)) { } else if (getLang().ObjC1 && Tok.is(tok::identifier)) {
IdentifierInfo *II = Tok.getIdentifierInfo(); IdentifierInfo *II = Tok.getIdentifierInfo();
SourceLocation IILoc = Tok.getLocation(); SourceLocation IILoc = Tok.getLocation();
@ -330,7 +330,7 @@ Parser::OwningExprResult Parser::ParseBraceInitializer() {
// If we know that this cannot be a designation, just parse the nested // If we know that this cannot be a designation, just parse the nested
// initializer directly. // initializer directly.
OwningExprResult SubElt(Actions); OwningExprResult SubElt;
if (MayBeDesignationStart(Tok.getKind(), PP)) if (MayBeDesignationStart(Tok.getKind(), PP))
SubElt = ParseInitializerWithPotentialDesignator(); SubElt = ParseInitializerWithPotentialDesignator();
else else

View File

@ -1458,7 +1458,7 @@ Decl *Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) {
/// throw expression[opt]; /// throw expression[opt];
/// ///
Parser::OwningStmtResult Parser::ParseObjCThrowStmt(SourceLocation atLoc) { Parser::OwningStmtResult Parser::ParseObjCThrowStmt(SourceLocation atLoc) {
OwningExprResult Res(Actions); OwningExprResult Res;
ConsumeToken(); // consume throw ConsumeToken(); // consume throw
if (Tok.isNot(tok::semi)) { if (Tok.isNot(tok::semi)) {
Res = ParseExpression(); Res = ParseExpression();
@ -1529,7 +1529,7 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
return StmtError(); return StmtError();
} }
StmtVector CatchStmts(Actions); StmtVector CatchStmts(Actions);
OwningStmtResult FinallyStmt(Actions); OwningStmtResult FinallyStmt;
ParseScope TryScope(this, Scope::DeclScope); ParseScope TryScope(this, Scope::DeclScope);
OwningStmtResult TryBody(ParseCompoundStatementBody()); OwningStmtResult TryBody(ParseCompoundStatementBody());
TryScope.Exit(); TryScope.Exit();
@ -1574,7 +1574,7 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
else // Skip over garbage, until we get to ')'. Eat the ')'. else // Skip over garbage, until we get to ')'. Eat the ')'.
SkipUntil(tok::r_paren, true, false); SkipUntil(tok::r_paren, true, false);
OwningStmtResult CatchBody(Actions, true); OwningStmtResult CatchBody(true);
if (Tok.is(tok::l_brace)) if (Tok.is(tok::l_brace))
CatchBody = ParseCompoundStatementBody(); CatchBody = ParseCompoundStatementBody();
else else
@ -1600,7 +1600,7 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
ConsumeToken(); // consume finally ConsumeToken(); // consume finally
ParseScope FinallyScope(this, Scope::DeclScope); ParseScope FinallyScope(this, Scope::DeclScope);
OwningStmtResult FinallyBody(Actions, true); OwningStmtResult FinallyBody(true);
if (Tok.is(tok::l_brace)) if (Tok.is(tok::l_brace))
FinallyBody = ParseCompoundStatementBody(); FinallyBody = ParseCompoundStatementBody();
else else
@ -1874,7 +1874,7 @@ Parser::OwningExprResult Parser::ParseObjCMessageExpression() {
if (IsExpr) if (IsExpr)
return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), 0, return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), 0,
OwningExprResult(Actions, TypeOrExpr)); OwningExprResult(static_cast<Expr*>(TypeOrExpr)));
return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(),
TypeOrExpr, ExprArg(Actions)); TypeOrExpr, ExprArg(Actions));

View File

@ -87,7 +87,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, Token &PackTok) {
Action::PragmaPackKind Kind = Action::PPK_Default; Action::PragmaPackKind Kind = Action::PPK_Default;
IdentifierInfo *Name = 0; IdentifierInfo *Name = 0;
Action::OwningExprResult Alignment(Actions); Action::OwningExprResult Alignment;
SourceLocation LParenLoc = Tok.getLocation(); SourceLocation LParenLoc = Tok.getLocation();
PP.Lex(Tok); PP.Lex(Tok);
if (Tok.is(tok::numeric_constant)) { if (Tok.is(tok::numeric_constant)) {

View File

@ -76,7 +76,7 @@ using namespace clang;
Parser::OwningStmtResult Parser::OwningStmtResult
Parser::ParseStatementOrDeclaration(bool OnlyStatement) { Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
const char *SemiError = 0; const char *SemiError = 0;
OwningStmtResult Res(Actions); OwningStmtResult Res;
ParenBraceBracketBalancer BalancerRAIIObj(*this); ParenBraceBracketBalancer BalancerRAIIObj(*this);
@ -272,7 +272,7 @@ Parser::OwningStmtResult Parser::ParseCaseStatement(AttributeList *Attr) {
// TopLevelCase - This is the highest level we have parsed. 'case 1' in the // TopLevelCase - This is the highest level we have parsed. 'case 1' in the
// example above. // example above.
OwningStmtResult TopLevelCase(Actions, true); OwningStmtResult TopLevelCase(true);
// DeepestParsedCaseStmt - This is the deepest statement we have parsed, which // DeepestParsedCaseStmt - This is the deepest statement we have parsed, which
// gets updated each time a new case is parsed, and whose body is unset so // gets updated each time a new case is parsed, and whose body is unset so
@ -301,7 +301,7 @@ Parser::OwningStmtResult Parser::ParseCaseStatement(AttributeList *Attr) {
// GNU case range extension. // GNU case range extension.
SourceLocation DotDotDotLoc; SourceLocation DotDotDotLoc;
OwningExprResult RHS(Actions); OwningExprResult RHS;
if (Tok.is(tok::ellipsis)) { if (Tok.is(tok::ellipsis)) {
Diag(Tok, diag::ext_gnu_case_range); Diag(Tok, diag::ext_gnu_case_range);
DotDotDotLoc = ConsumeToken(); DotDotDotLoc = ConsumeToken();
@ -336,7 +336,7 @@ Parser::OwningStmtResult Parser::ParseCaseStatement(AttributeList *Attr) {
} else { } else {
// If this is the first case statement we parsed, it becomes TopLevelCase. // If this is the first case statement we parsed, it becomes TopLevelCase.
// Otherwise we link it into the current chain. // Otherwise we link it into the current chain.
StmtTy *NextDeepest = Case.get(); Stmt *NextDeepest = Case.get();
if (TopLevelCase.isInvalid()) if (TopLevelCase.isInvalid())
TopLevelCase = move(Case); TopLevelCase = move(Case);
else else
@ -350,7 +350,7 @@ Parser::OwningStmtResult Parser::ParseCaseStatement(AttributeList *Attr) {
assert(!TopLevelCase.isInvalid() && "Should have parsed at least one case!"); assert(!TopLevelCase.isInvalid() && "Should have parsed at least one case!");
// If we found a non-case statement, start by parsing it. // If we found a non-case statement, start by parsing it.
OwningStmtResult SubStmt(Actions); OwningStmtResult SubStmt;
if (Tok.isNot(tok::r_brace)) { if (Tok.isNot(tok::r_brace)) {
SubStmt = ParseStatement(); SubStmt = ParseStatement();
@ -468,7 +468,7 @@ Parser::OwningStmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
typedef StmtVector StmtsTy; typedef StmtVector StmtsTy;
StmtsTy Stmts(Actions); StmtsTy Stmts(Actions);
while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) { while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) {
OwningStmtResult R(Actions); OwningStmtResult R;
if (Tok.isNot(tok::kw___extension__)) { if (Tok.isNot(tok::kw___extension__)) {
R = ParseStatementOrDeclaration(false); R = ParseStatementOrDeclaration(false);
} else { } else {
@ -611,7 +611,7 @@ Parser::OwningStmtResult Parser::ParseIfStatement(AttributeList *Attr) {
ParseScope IfScope(this, Scope::DeclScope | Scope::ControlScope, C99orCXX); ParseScope IfScope(this, Scope::DeclScope | Scope::ControlScope, C99orCXX);
// Parse the condition. // Parse the condition.
OwningExprResult CondExp(Actions); OwningExprResult CondExp;
Decl *CondVar = 0; Decl *CondVar = 0;
if (ParseParenExprOrCondition(CondExp, CondVar, IfLoc, true)) if (ParseParenExprOrCondition(CondExp, CondVar, IfLoc, true))
return StmtError(); return StmtError();
@ -649,7 +649,7 @@ Parser::OwningStmtResult Parser::ParseIfStatement(AttributeList *Attr) {
// If it has an else, parse it. // If it has an else, parse it.
SourceLocation ElseLoc; SourceLocation ElseLoc;
SourceLocation ElseStmtLoc; SourceLocation ElseStmtLoc;
OwningStmtResult ElseStmt(Actions); OwningStmtResult ElseStmt;
if (Tok.is(tok::kw_else)) { if (Tok.is(tok::kw_else)) {
ElseLoc = ConsumeToken(); ElseLoc = ConsumeToken();
@ -737,7 +737,7 @@ Parser::OwningStmtResult Parser::ParseSwitchStatement(AttributeList *Attr) {
ParseScope SwitchScope(this, ScopeFlags); ParseScope SwitchScope(this, ScopeFlags);
// Parse the condition. // Parse the condition.
OwningExprResult Cond(Actions); OwningExprResult Cond;
Decl *CondVar = 0; Decl *CondVar = 0;
if (ParseParenExprOrCondition(Cond, CondVar, SwitchLoc, false)) if (ParseParenExprOrCondition(Cond, CondVar, SwitchLoc, false))
return StmtError(); return StmtError();
@ -827,7 +827,7 @@ Parser::OwningStmtResult Parser::ParseWhileStatement(AttributeList *Attr) {
ParseScope WhileScope(this, ScopeFlags); ParseScope WhileScope(this, ScopeFlags);
// Parse the condition. // Parse the condition.
OwningExprResult Cond(Actions); OwningExprResult Cond;
Decl *CondVar = 0; Decl *CondVar = 0;
if (ParseParenExprOrCondition(Cond, CondVar, WhileLoc, true)) if (ParseParenExprOrCondition(Cond, CondVar, WhileLoc, true))
return StmtError(); return StmtError();
@ -982,13 +982,13 @@ Parser::OwningStmtResult Parser::ParseForStatement(AttributeList *Attr) {
ParseScope ForScope(this, ScopeFlags); ParseScope ForScope(this, ScopeFlags);
SourceLocation LParenLoc = ConsumeParen(); SourceLocation LParenLoc = ConsumeParen();
OwningExprResult Value(Actions); OwningExprResult Value;
bool ForEach = false; bool ForEach = false;
OwningStmtResult FirstPart(Actions); OwningStmtResult FirstPart;
bool SecondPartIsInvalid = false; bool SecondPartIsInvalid = false;
FullExprArg SecondPart(Actions); FullExprArg SecondPart(Actions);
OwningExprResult Collection(Actions); OwningExprResult Collection;
FullExprArg ThirdPart(Actions); FullExprArg ThirdPart(Actions);
Decl *SecondVar = 0; Decl *SecondVar = 0;
@ -1051,7 +1051,7 @@ Parser::OwningStmtResult Parser::ParseForStatement(AttributeList *Attr) {
if (Tok.is(tok::semi)) { // for (...;; if (Tok.is(tok::semi)) { // for (...;;
// no second part. // no second part.
} else { } else {
OwningExprResult Second(Actions); OwningExprResult Second;
if (getLang().CPlusPlus) if (getLang().CPlusPlus)
ParseCXXCondition(Second, SecondVar, ForLoc, true); ParseCXXCondition(Second, SecondVar, ForLoc, true);
else { else {
@ -1132,7 +1132,7 @@ Parser::OwningStmtResult Parser::ParseGotoStatement(AttributeList *Attr) {
assert(Tok.is(tok::kw_goto) && "Not a goto stmt!"); assert(Tok.is(tok::kw_goto) && "Not a goto stmt!");
SourceLocation GotoLoc = ConsumeToken(); // eat the 'goto'. SourceLocation GotoLoc = ConsumeToken(); // eat the 'goto'.
OwningStmtResult Res(Actions); OwningStmtResult Res;
if (Tok.is(tok::identifier)) { if (Tok.is(tok::identifier)) {
Res = Actions.ActOnGotoStmt(GotoLoc, Tok.getLocation(), Res = Actions.ActOnGotoStmt(GotoLoc, Tok.getLocation(),
Tok.getIdentifierInfo()); Tok.getIdentifierInfo());
@ -1193,7 +1193,7 @@ Parser::OwningStmtResult Parser::ParseReturnStatement(AttributeList *Attr) {
assert(Tok.is(tok::kw_return) && "Not a return stmt!"); assert(Tok.is(tok::kw_return) && "Not a return stmt!");
SourceLocation ReturnLoc = ConsumeToken(); // eat the 'return'. SourceLocation ReturnLoc = ConsumeToken(); // eat the 'return'.
OwningExprResult R(Actions); OwningExprResult R;
if (Tok.isNot(tok::semi)) { if (Tok.isNot(tok::semi)) {
if (Tok.is(tok::code_completion)) { if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteReturn(getCurScope()); Actions.CodeCompleteReturn(getCurScope());

View File

@ -601,7 +601,7 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) {
// Per C++0x [basic.scope.pdecl]p9, we parse the default argument before // Per C++0x [basic.scope.pdecl]p9, we parse the default argument before
// we introduce the template parameter into the local scope. // we introduce the template parameter into the local scope.
SourceLocation EqualLoc; SourceLocation EqualLoc;
OwningExprResult DefaultArg(Actions); OwningExprResult DefaultArg;
if (Tok.is(tok::equal)) { if (Tok.is(tok::equal)) {
EqualLoc = ConsumeToken(); EqualLoc = ConsumeToken();

View File

@ -967,7 +967,7 @@ TryStaticImplicitCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
Sema::OwningExprResult Result Sema::OwningExprResult Result
= InitSeq.Perform(Self, Entity, InitKind, = InitSeq.Perform(Self, Entity, InitKind,
Action::MultiExprArg(Self, (void**)&SrcExpr, 1)); Action::MultiExprArg(Self, &SrcExpr, 1));
if (Result.isInvalid()) { if (Result.isInvalid()) {
msg = 0; msg = 0;
return TC_Failed; return TC_Failed;

View File

@ -4136,7 +4136,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, ExprArg init, bool DirectInit) {
} else if (!VDecl->isInvalidDecl()) { } else if (!VDecl->isInvalidDecl()) {
InitializationSequence InitSeq(*this, Entity, Kind, &Init, 1); InitializationSequence InitSeq(*this, Entity, Kind, &Init, 1);
OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind, OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind,
MultiExprArg(*this, (void**)&Init, 1), MultiExprArg(*this, &Init, 1),
&DclT); &DclT);
if (Result.isInvalid()) { if (Result.isInvalid()) {
VDecl->setInvalidDecl(); VDecl->setInvalidDecl();
@ -4207,7 +4207,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, ExprArg init, bool DirectInit) {
if (!VDecl->isInvalidDecl()) { if (!VDecl->isInvalidDecl()) {
InitializationSequence InitSeq(*this, Entity, Kind, &Init, 1); InitializationSequence InitSeq(*this, Entity, Kind, &Init, 1);
OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind, OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind,
MultiExprArg(*this, (void**)&Init, 1), MultiExprArg(*this, &Init, 1),
&DclT); &DclT);
if (Result.isInvalid()) { if (Result.isInvalid()) {
VDecl->setInvalidDecl(); VDecl->setInvalidDecl();

View File

@ -129,7 +129,7 @@ Sema::SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
EqualLoc); EqualLoc);
InitializationSequence InitSeq(*this, Entity, Kind, &Arg, 1); InitializationSequence InitSeq(*this, Entity, Kind, &Arg, 1);
OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind, OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind,
MultiExprArg(*this, (void**)&Arg, 1)); MultiExprArg(*this, &Arg, 1));
if (Result.isInvalid()) if (Result.isInvalid())
return true; return true;
Arg = Result.takeAs<Expr>(); Arg = Result.takeAs<Expr>();
@ -1325,7 +1325,7 @@ Sema::BuildMemberInitializer(FieldDecl *Member, Expr **Args,
OwningExprResult MemberInit = OwningExprResult MemberInit =
InitSeq.Perform(*this, MemberEntity, Kind, InitSeq.Perform(*this, MemberEntity, Kind,
MultiExprArg(*this, (void**)Args, NumArgs), 0); MultiExprArg(*this, Args, NumArgs), 0);
if (MemberInit.isInvalid()) if (MemberInit.isInvalid())
return true; return true;
@ -1457,7 +1457,7 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo,
OwningExprResult BaseInit = OwningExprResult BaseInit =
InitSeq.Perform(*this, BaseEntity, Kind, InitSeq.Perform(*this, BaseEntity, Kind,
MultiExprArg(*this, (void**)Args, NumArgs), 0); MultiExprArg(*this, Args, NumArgs), 0);
if (BaseInit.isInvalid()) if (BaseInit.isInvalid())
return true; return true;
@ -1515,7 +1515,7 @@ BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
= InitializedEntity::InitializeBase(SemaRef.Context, BaseSpec, = InitializedEntity::InitializeBase(SemaRef.Context, BaseSpec,
IsInheritedVirtualBase); IsInheritedVirtualBase);
Sema::OwningExprResult BaseInit(SemaRef); Sema::OwningExprResult BaseInit;
switch (ImplicitInitKind) { switch (ImplicitInitKind) {
case IIK_Default: { case IIK_Default: {
@ -1553,7 +1553,7 @@ BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
&CopyCtorArg, 1); &CopyCtorArg, 1);
BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind,
Sema::MultiExprArg(SemaRef, Sema::MultiExprArg(SemaRef,
(void**)&CopyCtorArg, 1)); &CopyCtorArg, 1));
break; break;
} }
@ -1674,7 +1674,7 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
Sema::OwningExprResult MemberInit Sema::OwningExprResult MemberInit
= InitSeq.Perform(SemaRef, Entities.back(), InitKind, = InitSeq.Perform(SemaRef, Entities.back(), InitKind,
Sema::MultiExprArg(SemaRef, (void**)&CopyCtorArgE, 1)); Sema::MultiExprArg(SemaRef, &CopyCtorArgE, 1));
MemberInit = SemaRef.MaybeCreateCXXExprWithTemporaries(move(MemberInit)); MemberInit = SemaRef.MaybeCreateCXXExprWithTemporaries(move(MemberInit));
if (MemberInit.isInvalid()) if (MemberInit.isInvalid())
return true; return true;
@ -4927,7 +4927,7 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
// which they were declared in the class definition. // which they were declared in the class definition.
// The statements that form the synthesized function body. // The statements that form the synthesized function body.
ASTOwningVector<&ActionBase::DeleteStmt> Statements(*this); ASTOwningVector<Stmt*> Statements(*this);
// The parameter for the "other" object, which we are copying from. // The parameter for the "other" object, which we are copying from.
ParmVarDecl *Other = CopyAssignOperator->getParamDecl(0); ParmVarDecl *Other = CopyAssignOperator->getParamDecl(0);
@ -5132,7 +5132,7 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
assert(BuiltinMemCpyRef && "Builtin reference cannot fail"); assert(BuiltinMemCpyRef && "Builtin reference cannot fail");
} }
ASTOwningVector<&ActionBase::DeleteExpr> CallArgs(*this); ASTOwningVector<Expr*> CallArgs(*this);
CallArgs.push_back(To.takeAs<Expr>()); CallArgs.push_back(To.takeAs<Expr>());
CallArgs.push_back(From.takeAs<Expr>()); CallArgs.push_back(From.takeAs<Expr>());
CallArgs.push_back(new (Context) IntegerLiteral(Size, SizeType, Loc)); CallArgs.push_back(new (Context) IntegerLiteral(Size, SizeType, Loc));
@ -5602,7 +5602,7 @@ bool
Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor,
MultiExprArg ArgsPtr, MultiExprArg ArgsPtr,
SourceLocation Loc, SourceLocation Loc,
ASTOwningVector<&ActionBase::DeleteExpr> &ConvertedArgs) { ASTOwningVector<Expr*> &ConvertedArgs) {
// FIXME: This duplicates a lot of code from Sema::ConvertArgumentsForCall. // FIXME: This duplicates a lot of code from Sema::ConvertArgumentsForCall.
unsigned NumArgs = ArgsPtr.size(); unsigned NumArgs = ArgsPtr.size();
Expr **Args = (Expr **)ArgsPtr.get(); Expr **Args = (Expr **)ArgsPtr.get();
@ -6139,7 +6139,7 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
SourceLocation()); SourceLocation());
InitializationSequence InitSeq(*this, Entity, Kind, &ExDeclRef, 1); InitializationSequence InitSeq(*this, Entity, Kind, &ExDeclRef, 1);
OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind, OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind,
MultiExprArg(*this, (void**)&ExDeclRef, 1)); MultiExprArg(*this, &ExDeclRef, 1));
if (Result.isInvalid()) if (Result.isInvalid())
Invalid = true; Invalid = true;
else else

View File

@ -3344,7 +3344,7 @@ Sema::OwningExprResult Sema::ActOnMemberAccessExpr(Scope *S, ExprArg BaseArg,
BaseArg = MaybeConvertParenListExprToParenExpr(S, move(BaseArg)); BaseArg = MaybeConvertParenListExprToParenExpr(S, move(BaseArg));
Expr *Base = BaseArg.takeAs<Expr>(); Expr *Base = BaseArg.takeAs<Expr>();
OwningExprResult Result(*this); OwningExprResult Result;
if (Base->getType()->isDependentType() || Name.isDependentName() || if (Base->getType()->isDependentType() || Name.isDependentName() ||
isDependentScopeSpecifier(SS)) { isDependentScopeSpecifier(SS)) {
Result = ActOnDependentMemberExpr(ExprArg(*this, Base), Base->getType(), Result = ActOnDependentMemberExpr(ExprArg(*this, Base), Base->getType(),
@ -3417,7 +3417,7 @@ Sema::OwningExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc,
InitializationSequence InitSeq(*this, Entity, Kind, &ResultE, 1); InitializationSequence InitSeq(*this, Entity, Kind, &ResultE, 1);
Result = InitSeq.Perform(*this, Entity, Kind, Result = InitSeq.Perform(*this, Entity, Kind,
MultiExprArg(*this, (void**)&ResultE, 1)); MultiExprArg(*this, &ResultE, 1));
if (Result.isInvalid()) if (Result.isInvalid())
return ExprError(); return ExprError();
@ -3841,7 +3841,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
/*IsCStyleCast=*/true); /*IsCStyleCast=*/true);
InitializationSequence InitSeq(*this, Entity, Kind, &literalExpr, 1); InitializationSequence InitSeq(*this, Entity, Kind, &literalExpr, 1);
OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind, OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind,
MultiExprArg(*this, (void**)&literalExpr, 1), MultiExprArg(*this, &literalExpr, 1),
&literalType); &literalType);
if (Result.isInvalid()) if (Result.isInvalid())
return ExprError(); return ExprError();
@ -4108,7 +4108,7 @@ Sema::MaybeConvertParenListExprToParenExpr(Scope *S, ExprArg EA) {
if (!E) if (!E)
return Owned(expr); return Owned(expr);
OwningExprResult Result(*this, E->getExpr(0)); OwningExprResult Result(E->getExpr(0));
for (unsigned i = 1, e = E->getNumExprs(); i != e && !Result.isInvalid(); ++i) for (unsigned i = 1, e = E->getNumExprs(); i != e && !Result.isInvalid(); ++i)
Result = ActOnBinOp(S, E->getExprLoc(), tok::comma, move(Result), Result = ActOnBinOp(S, E->getExprLoc(), tok::comma, move(Result),

View File

@ -780,7 +780,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
CXXConstructorDecl *Constructor = 0; CXXConstructorDecl *Constructor = 0;
Expr **ConsArgs = (Expr**)ConstructorArgs.get(); Expr **ConsArgs = (Expr**)ConstructorArgs.get();
unsigned NumConsArgs = ConstructorArgs.size(); unsigned NumConsArgs = ConstructorArgs.size();
ASTOwningVector<&ActionBase::DeleteExpr> ConvertedConstructorArgs(*this); ASTOwningVector<Expr*> ConvertedConstructorArgs(*this);
// Array 'new' can't have any initializers. // Array 'new' can't have any initializers.
if (NumConsArgs && (ResultType->isArrayType() || ArraySize)) { if (NumConsArgs && (ResultType->isArrayType() || ArraySize)) {
@ -1592,10 +1592,10 @@ static Sema::OwningExprResult BuildCXXCastArgument(Sema &S,
switch (Kind) { switch (Kind) {
default: assert(0 && "Unhandled cast kind!"); default: assert(0 && "Unhandled cast kind!");
case CastExpr::CK_ConstructorConversion: { case CastExpr::CK_ConstructorConversion: {
ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(S); ASTOwningVector<Expr*> ConstructorArgs(S);
if (S.CompleteConstructorCall(cast<CXXConstructorDecl>(Method), if (S.CompleteConstructorCall(cast<CXXConstructorDecl>(Method),
Sema::MultiExprArg(S, (void **)&From, 1), Sema::MultiExprArg(S, &From, 1),
CastLoc, ConstructorArgs)) CastLoc, ConstructorArgs))
return S.ExprError(); return S.ExprError();
@ -1723,9 +1723,9 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
// FIXME: When can ToType be a reference type? // FIXME: When can ToType be a reference type?
assert(!ToType->isReferenceType()); assert(!ToType->isReferenceType());
if (SCS.Second == ICK_Derived_To_Base) { if (SCS.Second == ICK_Derived_To_Base) {
ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(*this); ASTOwningVector<Expr*> ConstructorArgs(*this);
if (CompleteConstructorCall(cast<CXXConstructorDecl>(SCS.CopyConstructor), if (CompleteConstructorCall(cast<CXXConstructorDecl>(SCS.CopyConstructor),
MultiExprArg(*this, (void **)&From, 1), MultiExprArg(*this, &From, 1),
/*FIXME:ConstructLoc*/SourceLocation(), /*FIXME:ConstructLoc*/SourceLocation(),
ConstructorArgs)) ConstructorArgs))
return true; return true;
@ -1741,7 +1741,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
OwningExprResult FromResult = OwningExprResult FromResult =
BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(), BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(),
ToType, SCS.CopyConstructor, ToType, SCS.CopyConstructor,
MultiExprArg(*this, (void**)&From, 1)); MultiExprArg(*this, &From, 1));
if (FromResult.isInvalid()) if (FromResult.isInvalid())
return true; return true;
@ -2187,7 +2187,7 @@ static bool ConvertForConditional(Sema &Self, Expr *&E, QualType T) {
SourceLocation()); SourceLocation());
InitializationSequence InitSeq(Self, Entity, Kind, &E, 1); InitializationSequence InitSeq(Self, Entity, Kind, &E, 1);
Sema::OwningExprResult Result = InitSeq.Perform(Self, Entity, Kind, Sema::OwningExprResult Result = InitSeq.Perform(Self, Entity, Kind,
Sema::MultiExprArg(Self, (void **)&E, 1)); Sema::MultiExprArg(Self, &E, 1));
if (Result.isInvalid()) if (Result.isInvalid())
return true; return true;
@ -2569,14 +2569,14 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc,
// Convert E1 to Composite1 // Convert E1 to Composite1
OwningExprResult E1Result OwningExprResult E1Result
= E1ToC1.Perform(*this, Entity1, Kind, MultiExprArg(*this,(void**)&E1,1)); = E1ToC1.Perform(*this, Entity1, Kind, MultiExprArg(*this,&E1,1));
if (E1Result.isInvalid()) if (E1Result.isInvalid())
return QualType(); return QualType();
E1 = E1Result.takeAs<Expr>(); E1 = E1Result.takeAs<Expr>();
// Convert E2 to Composite1 // Convert E2 to Composite1
OwningExprResult E2Result OwningExprResult E2Result
= E2ToC1.Perform(*this, Entity1, Kind, MultiExprArg(*this,(void**)&E2,1)); = E2ToC1.Perform(*this, Entity1, Kind, MultiExprArg(*this,&E2,1));
if (E2Result.isInvalid()) if (E2Result.isInvalid())
return QualType(); return QualType();
E2 = E2Result.takeAs<Expr>(); E2 = E2Result.takeAs<Expr>();
@ -2594,14 +2594,14 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc,
// Convert E1 to Composite2 // Convert E1 to Composite2
OwningExprResult E1Result OwningExprResult E1Result
= E1ToC2.Perform(*this, Entity2, Kind, MultiExprArg(*this, (void**)&E1, 1)); = E1ToC2.Perform(*this, Entity2, Kind, MultiExprArg(*this, &E1, 1));
if (E1Result.isInvalid()) if (E1Result.isInvalid())
return QualType(); return QualType();
E1 = E1Result.takeAs<Expr>(); E1 = E1Result.takeAs<Expr>();
// Convert E2 to Composite2 // Convert E2 to Composite2
OwningExprResult E2Result OwningExprResult E2Result
= E2ToC2.Perform(*this, Entity2, Kind, MultiExprArg(*this, (void**)&E2, 1)); = E2ToC2.Perform(*this, Entity2, Kind, MultiExprArg(*this, &E2, 1));
if (E2Result.isInvalid()) if (E2Result.isInvalid())
return QualType(); return QualType();
E2 = E2Result.takeAs<Expr>(); E2 = E2Result.takeAs<Expr>();

View File

@ -680,7 +680,7 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity,
if (Seq) { if (Seq) {
Sema::OwningExprResult Result = Sema::OwningExprResult Result =
Seq.Perform(SemaRef, Entity, Kind, Seq.Perform(SemaRef, Entity, Kind,
Sema::MultiExprArg(SemaRef, (void **)&expr, 1)); Sema::MultiExprArg(SemaRef, &expr, 1));
if (Result.isInvalid()) if (Result.isInvalid())
hadError = true; hadError = true;
@ -3411,7 +3411,7 @@ static Sema::OwningExprResult CopyObject(Sema &S,
} }
CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(Best->Function); CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(Best->Function);
ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(S); ASTOwningVector<Expr*> ConstructorArgs(S);
CurInit.release(); // Ownership transferred into MultiExprArg, below. CurInit.release(); // Ownership transferred into MultiExprArg, below.
S.CheckConstructorAccess(Loc, Constructor, Entity, S.CheckConstructorAccess(Loc, Constructor, Entity,
@ -3447,9 +3447,7 @@ static Sema::OwningExprResult CopyObject(Sema &S,
// constructor call (we might have derived-to-base conversions, or // constructor call (we might have derived-to-base conversions, or
// the copy constructor may have default arguments). // the copy constructor may have default arguments).
if (S.CompleteConstructorCall(Constructor, if (S.CompleteConstructorCall(Constructor,
Sema::MultiExprArg(S, Sema::MultiExprArg(S, &CurInitExpr, 1),
(void **)&CurInitExpr,
1),
Loc, ConstructorArgs)) Loc, ConstructorArgs))
return S.ExprError(); return S.ExprError();
@ -3530,7 +3528,7 @@ InitializationSequence::Perform(Sema &S,
} }
if (Kind.getKind() == InitializationKind::IK_Copy || Kind.isExplicitCast()) if (Kind.getKind() == InitializationKind::IK_Copy || Kind.isExplicitCast())
return Sema::OwningExprResult(S, Args.release()[0]); return Sema::OwningExprResult(Args.release()[0]);
if (Args.size() == 0) if (Args.size() == 0)
return S.Owned((Expr *)0); return S.Owned((Expr *)0);
@ -3579,7 +3577,7 @@ InitializationSequence::Perform(Sema &S,
case SK_StringInit: case SK_StringInit:
case SK_ObjCObjectConversion: case SK_ObjCObjectConversion:
assert(Args.size() == 1); assert(Args.size() == 1);
CurInit = Sema::OwningExprResult(S, ((Expr **)(Args.get()))[0]->Retain()); CurInit = Sema::OwningExprResult(((Expr **)(Args.get()))[0]->Retain());
if (CurInit.isInvalid()) if (CurInit.isInvalid())
return S.ExprError(); return S.ExprError();
break; break;
@ -3703,16 +3701,14 @@ InitializationSequence::Perform(Sema &S,
bool IsLvalue = false; bool IsLvalue = false;
if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(Fn)) { if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(Fn)) {
// Build a call to the selected constructor. // Build a call to the selected constructor.
ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(S); ASTOwningVector<Expr*> ConstructorArgs(S);
SourceLocation Loc = CurInitExpr->getLocStart(); SourceLocation Loc = CurInitExpr->getLocStart();
CurInit.release(); // Ownership transferred into MultiExprArg, below. CurInit.release(); // Ownership transferred into MultiExprArg, below.
// Determine the arguments required to actually perform the constructor // Determine the arguments required to actually perform the constructor
// call. // call.
if (S.CompleteConstructorCall(Constructor, if (S.CompleteConstructorCall(Constructor,
Sema::MultiExprArg(S, Sema::MultiExprArg(S, &CurInitExpr, 1),
(void **)&CurInitExpr,
1),
Loc, ConstructorArgs)) Loc, ConstructorArgs))
return S.ExprError(); return S.ExprError();
@ -3838,7 +3834,7 @@ InitializationSequence::Perform(Sema &S,
= cast<CXXConstructorDecl>(Step->Function.Function); = cast<CXXConstructorDecl>(Step->Function.Function);
// Build a call to the selected constructor. // Build a call to the selected constructor.
ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(S); ASTOwningVector<Expr*> ConstructorArgs(S);
SourceLocation Loc = (Kind.isCopyInit() && Kind.getEqualLoc().isValid()) SourceLocation Loc = (Kind.isCopyInit() && Kind.getEqualLoc().isValid())
? Kind.getEqualLoc() ? Kind.getEqualLoc()
: Kind.getLocation(); : Kind.getLocation();
@ -4464,6 +4460,5 @@ Sema::PerformCopyInitialization(const InitializedEntity &Entity,
EqualLoc); EqualLoc);
InitializationSequence Seq(*this, Entity, Kind, &InitE, 1); InitializationSequence Seq(*this, Entity, Kind, &InitE, 1);
Init.release(); Init.release();
return Seq.Perform(*this, Entity, Kind, return Seq.Perform(*this, Entity, Kind, MultiExprArg(*this, &InitE, 1));
MultiExprArg(*this, (void**)&InitE, 1));
} }

View File

@ -6556,7 +6556,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
// an expression with non-empty lookup results, which should never // an expression with non-empty lookup results, which should never
// end up here. // end up here.
return SemaRef.ActOnCallExpr(/*Scope*/ 0, move(NewFn), LParenLoc, return SemaRef.ActOnCallExpr(/*Scope*/ 0, move(NewFn), LParenLoc,
Sema::MultiExprArg(SemaRef, (void**) Args, NumArgs), Sema::MultiExprArg(SemaRef, Args, NumArgs),
CommaLocs, RParenLoc); CommaLocs, RParenLoc);
} }

View File

@ -253,7 +253,7 @@ static bool InstantiateInitializationArguments(Sema &SemaRef,
Expr **Args, unsigned NumArgs, Expr **Args, unsigned NumArgs,
const MultiLevelTemplateArgumentList &TemplateArgs, const MultiLevelTemplateArgumentList &TemplateArgs,
llvm::SmallVectorImpl<SourceLocation> &FakeCommaLocs, llvm::SmallVectorImpl<SourceLocation> &FakeCommaLocs,
ASTOwningVector<&ActionBase::DeleteExpr> &InitArgs) { ASTOwningVector<Expr*> &InitArgs) {
for (unsigned I = 0; I != NumArgs; ++I) { for (unsigned I = 0; I != NumArgs; ++I) {
// When we hit the first defaulted argument, break out of the loop: // When we hit the first defaulted argument, break out of the loop:
// we don't pass those default arguments on. // we don't pass those default arguments on.
@ -292,7 +292,7 @@ static bool InstantiateInitializer(Sema &S, Expr *Init,
const MultiLevelTemplateArgumentList &TemplateArgs, const MultiLevelTemplateArgumentList &TemplateArgs,
SourceLocation &LParenLoc, SourceLocation &LParenLoc,
llvm::SmallVector<SourceLocation, 4> &CommaLocs, llvm::SmallVector<SourceLocation, 4> &CommaLocs,
ASTOwningVector<&ActionBase::DeleteExpr> &NewArgs, ASTOwningVector<Expr*> &NewArgs,
SourceLocation &RParenLoc) { SourceLocation &RParenLoc) {
NewArgs.clear(); NewArgs.clear();
LParenLoc = SourceLocation(); LParenLoc = SourceLocation();
@ -421,7 +421,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
// Instantiate the initializer. // Instantiate the initializer.
SourceLocation LParenLoc, RParenLoc; SourceLocation LParenLoc, RParenLoc;
llvm::SmallVector<SourceLocation, 4> CommaLocs; llvm::SmallVector<SourceLocation, 4> CommaLocs;
ASTOwningVector<&ActionBase::DeleteExpr> InitArgs(SemaRef); ASTOwningVector<Expr*> InitArgs(SemaRef);
if (!InstantiateInitializer(SemaRef, D->getInit(), TemplateArgs, LParenLoc, if (!InstantiateInitializer(SemaRef, D->getInit(), TemplateArgs, LParenLoc,
CommaLocs, InitArgs, RParenLoc)) { CommaLocs, InitArgs, RParenLoc)) {
// Attach the initializer to the declaration. // Attach the initializer to the declaration.
@ -591,7 +591,7 @@ Decl *TemplateDeclInstantiator::VisitStaticAssertDecl(StaticAssertDecl *D) {
if (InstantiatedAssertExpr.isInvalid()) if (InstantiatedAssertExpr.isInvalid())
return 0; return 0;
OwningExprResult Message(SemaRef, D->getMessage()); OwningExprResult Message(D->getMessage());
D->getMessage()->Retain(); D->getMessage()->Retain();
return SemaRef.ActOnStaticAssertDeclaration(D->getLocation(), return SemaRef.ActOnStaticAssertDeclaration(D->getLocation(),
move(InstantiatedAssertExpr), move(InstantiatedAssertExpr),
@ -2251,7 +2251,7 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New,
CXXBaseOrMemberInitializer *Init = *Inits; CXXBaseOrMemberInitializer *Init = *Inits;
SourceLocation LParenLoc, RParenLoc; SourceLocation LParenLoc, RParenLoc;
ASTOwningVector<&ActionBase::DeleteExpr> NewArgs(*this); ASTOwningVector<Expr*> NewArgs(*this);
llvm::SmallVector<SourceLocation, 4> CommaLocs; llvm::SmallVector<SourceLocation, 4> CommaLocs;
// Instantiate the initializer. // Instantiate the initializer.

View File

@ -1510,7 +1510,7 @@ public:
SourceLocation LParenLoc, SourceLocation LParenLoc,
ExprArg SubExpr, ExprArg SubExpr,
SourceLocation RParenLoc) { SourceLocation RParenLoc) {
void *Sub = SubExpr.takeAs<Expr>(); Expr *Sub = SubExpr.get();
return getSema().ActOnCXXTypeConstructExpr(TypeRange, return getSema().ActOnCXXTypeConstructExpr(TypeRange,
TInfo->getType().getAsOpaquePtr(), TInfo->getType().getAsOpaquePtr(),
LParenLoc, LParenLoc,
@ -1687,7 +1687,7 @@ public:
MultiExprArg Args, MultiExprArg Args,
bool RequiresZeroInit, bool RequiresZeroInit,
CXXConstructExpr::ConstructionKind ConstructKind) { CXXConstructExpr::ConstructionKind ConstructKind) {
ASTOwningVector<&ActionBase::DeleteExpr> ConvertedArgs(SemaRef); ASTOwningVector<Expr*> ConvertedArgs(SemaRef);
if (getSema().CompleteConstructorCall(Constructor, move(Args), Loc, if (getSema().CompleteConstructorCall(Constructor, move(Args), Loc,
ConvertedArgs)) ConvertedArgs))
return getSema().ExprError(); return getSema().ExprError();
@ -3469,7 +3469,7 @@ Sema::OwningStmtResult
TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S, TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S,
bool IsStmtExpr) { bool IsStmtExpr) {
bool SubStmtChanged = false; bool SubStmtChanged = false;
ASTOwningVector<&ActionBase::DeleteStmt> Statements(getSema()); ASTOwningVector<Stmt*> Statements(getSema());
for (CompoundStmt::body_iterator B = S->body_begin(), BEnd = S->body_end(); for (CompoundStmt::body_iterator B = S->body_begin(), BEnd = S->body_end();
B != BEnd; ++B) { B != BEnd; ++B) {
OwningStmtResult Result = getDerived().TransformStmt(*B); OwningStmtResult Result = getDerived().TransformStmt(*B);
@ -3493,7 +3493,7 @@ TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S,
template<typename Derived> template<typename Derived>
Sema::OwningStmtResult Sema::OwningStmtResult
TreeTransform<Derived>::TransformCaseStmt(CaseStmt *S) { TreeTransform<Derived>::TransformCaseStmt(CaseStmt *S) {
OwningExprResult LHS(SemaRef), RHS(SemaRef); OwningExprResult LHS, RHS;
{ {
// The case value expressions are not potentially evaluated. // The case value expressions are not potentially evaluated.
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated); EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
@ -3559,7 +3559,7 @@ template<typename Derived>
Sema::OwningStmtResult Sema::OwningStmtResult
TreeTransform<Derived>::TransformIfStmt(IfStmt *S) { TreeTransform<Derived>::TransformIfStmt(IfStmt *S) {
// Transform the condition // Transform the condition
OwningExprResult Cond(SemaRef); OwningExprResult Cond;
VarDecl *ConditionVar = 0; VarDecl *ConditionVar = 0;
if (S->getConditionVariable()) { if (S->getConditionVariable()) {
ConditionVar ConditionVar
@ -3617,7 +3617,7 @@ template<typename Derived>
Sema::OwningStmtResult Sema::OwningStmtResult
TreeTransform<Derived>::TransformSwitchStmt(SwitchStmt *S) { TreeTransform<Derived>::TransformSwitchStmt(SwitchStmt *S) {
// Transform the condition. // Transform the condition.
OwningExprResult Cond(SemaRef); OwningExprResult Cond;
VarDecl *ConditionVar = 0; VarDecl *ConditionVar = 0;
if (S->getConditionVariable()) { if (S->getConditionVariable()) {
ConditionVar ConditionVar
@ -3655,7 +3655,7 @@ template<typename Derived>
Sema::OwningStmtResult Sema::OwningStmtResult
TreeTransform<Derived>::TransformWhileStmt(WhileStmt *S) { TreeTransform<Derived>::TransformWhileStmt(WhileStmt *S) {
// Transform the condition // Transform the condition
OwningExprResult Cond(SemaRef); OwningExprResult Cond;
VarDecl *ConditionVar = 0; VarDecl *ConditionVar = 0;
if (S->getConditionVariable()) { if (S->getConditionVariable()) {
ConditionVar ConditionVar
@ -3733,7 +3733,7 @@ TreeTransform<Derived>::TransformForStmt(ForStmt *S) {
return SemaRef.StmtError(); return SemaRef.StmtError();
// Transform the condition // Transform the condition
OwningExprResult Cond(SemaRef); OwningExprResult Cond;
VarDecl *ConditionVar = 0; VarDecl *ConditionVar = 0;
if (S->getConditionVariable()) { if (S->getConditionVariable()) {
ConditionVar ConditionVar
@ -3874,12 +3874,12 @@ template<typename Derived>
Sema::OwningStmtResult Sema::OwningStmtResult
TreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) { TreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) {
ASTOwningVector<&ActionBase::DeleteExpr> Constraints(getSema()); ASTOwningVector<Expr*> Constraints(getSema());
ASTOwningVector<&ActionBase::DeleteExpr> Exprs(getSema()); ASTOwningVector<Expr*> Exprs(getSema());
llvm::SmallVector<IdentifierInfo *, 4> Names; llvm::SmallVector<IdentifierInfo *, 4> Names;
OwningExprResult AsmString(SemaRef); OwningExprResult AsmString;
ASTOwningVector<&ActionBase::DeleteExpr> Clobbers(getSema()); ASTOwningVector<Expr*> Clobbers(getSema());
bool ExprsChanged = false; bool ExprsChanged = false;
@ -3954,7 +3954,7 @@ TreeTransform<Derived>::TransformObjCAtTryStmt(ObjCAtTryStmt *S) {
// Transform the @catch statements (if present). // Transform the @catch statements (if present).
bool AnyCatchChanged = false; bool AnyCatchChanged = false;
ASTOwningVector<&ActionBase::DeleteStmt> CatchStmts(SemaRef); ASTOwningVector<Stmt*> CatchStmts(SemaRef);
for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) { for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
OwningStmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I)); OwningStmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
if (Catch.isInvalid()) if (Catch.isInvalid())
@ -3965,7 +3965,7 @@ TreeTransform<Derived>::TransformObjCAtTryStmt(ObjCAtTryStmt *S) {
} }
// Transform the @finally statement (if present). // Transform the @finally statement (if present).
OwningStmtResult Finally(SemaRef); OwningStmtResult Finally;
if (S->getFinallyStmt()) { if (S->getFinallyStmt()) {
Finally = getDerived().TransformStmt(S->getFinallyStmt()); Finally = getDerived().TransformStmt(S->getFinallyStmt());
if (Finally.isInvalid()) if (Finally.isInvalid())
@ -4041,7 +4041,7 @@ TreeTransform<Derived>::TransformObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
template<typename Derived> template<typename Derived>
Sema::OwningStmtResult Sema::OwningStmtResult
TreeTransform<Derived>::TransformObjCAtThrowStmt(ObjCAtThrowStmt *S) { TreeTransform<Derived>::TransformObjCAtThrowStmt(ObjCAtThrowStmt *S) {
OwningExprResult Operand(SemaRef); OwningExprResult Operand;
if (S->getThrowExpr()) { if (S->getThrowExpr()) {
Operand = getDerived().TransformExpr(S->getThrowExpr()); Operand = getDerived().TransformExpr(S->getThrowExpr());
if (Operand.isInvalid()) if (Operand.isInvalid())
@ -4167,7 +4167,7 @@ TreeTransform<Derived>::TransformCXXTryStmt(CXXTryStmt *S) {
// Transform the handlers. // Transform the handlers.
bool HandlerChanged = false; bool HandlerChanged = false;
ASTOwningVector<&ActionBase::DeleteStmt> Handlers(SemaRef); ASTOwningVector<Stmt*> Handlers(SemaRef);
for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) { for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
OwningStmtResult Handler OwningStmtResult Handler
= getDerived().TransformCXXCatchStmt(S->getHandler(I)); = getDerived().TransformCXXCatchStmt(S->getHandler(I));
@ -4393,7 +4393,7 @@ TreeTransform<Derived>::TransformSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
E->getSourceRange()); E->getSourceRange());
} }
Sema::OwningExprResult SubExpr(SemaRef); Sema::OwningExprResult SubExpr;
{ {
// C++0x [expr.sizeof]p1: // C++0x [expr.sizeof]p1:
// The operand is either an expression, which is an unevaluated operand // The operand is either an expression, which is an unevaluated operand
@ -4446,7 +4446,7 @@ TreeTransform<Derived>::TransformCallExpr(CallExpr *E) {
// Transform arguments. // Transform arguments.
bool ArgChanged = false; bool ArgChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr> Args(SemaRef); ASTOwningVector<Expr*> Args(SemaRef);
llvm::SmallVector<SourceLocation, 4> FakeCommaLocs; llvm::SmallVector<SourceLocation, 4> FakeCommaLocs;
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) { for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
OwningExprResult Arg = getDerived().TransformExpr(E->getArg(I)); OwningExprResult Arg = getDerived().TransformExpr(E->getArg(I));
@ -4700,7 +4700,7 @@ Sema::OwningExprResult
TreeTransform<Derived>::TransformInitListExpr(InitListExpr *E) { TreeTransform<Derived>::TransformInitListExpr(InitListExpr *E) {
bool InitChanged = false; bool InitChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr, 4> Inits(SemaRef); ASTOwningVector<Expr*, 4> Inits(SemaRef);
for (unsigned I = 0, N = E->getNumInits(); I != N; ++I) { for (unsigned I = 0, N = E->getNumInits(); I != N; ++I) {
OwningExprResult Init = getDerived().TransformExpr(E->getInit(I)); OwningExprResult Init = getDerived().TransformExpr(E->getInit(I));
if (Init.isInvalid()) if (Init.isInvalid())
@ -4728,7 +4728,7 @@ TreeTransform<Derived>::TransformDesignatedInitExpr(DesignatedInitExpr *E) {
return SemaRef.ExprError(); return SemaRef.ExprError();
// transform the designators. // transform the designators.
ASTOwningVector<&ActionBase::DeleteExpr, 4> ArrayExprs(SemaRef); ASTOwningVector<Expr*, 4> ArrayExprs(SemaRef);
bool ExprChanged = false; bool ExprChanged = false;
for (DesignatedInitExpr::designators_iterator D = E->designators_begin(), for (DesignatedInitExpr::designators_iterator D = E->designators_begin(),
DEnd = E->designators_end(); DEnd = E->designators_end();
@ -4828,7 +4828,7 @@ template<typename Derived>
Sema::OwningExprResult Sema::OwningExprResult
TreeTransform<Derived>::TransformParenListExpr(ParenListExpr *E) { TreeTransform<Derived>::TransformParenListExpr(ParenListExpr *E) {
bool ArgumentChanged = false; bool ArgumentChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr, 4> Inits(SemaRef); ASTOwningVector<Expr*, 4> Inits(SemaRef);
for (unsigned I = 0, N = E->getNumExprs(); I != N; ++I) { for (unsigned I = 0, N = E->getNumExprs(); I != N; ++I) {
OwningExprResult Init = getDerived().TransformExpr(E->getExpr(I)); OwningExprResult Init = getDerived().TransformExpr(E->getExpr(I));
if (Init.isInvalid()) if (Init.isInvalid())
@ -4954,7 +4954,7 @@ TreeTransform<Derived>::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
static_cast<Expr *>(Object.get())->getLocEnd()); static_cast<Expr *>(Object.get())->getLocEnd());
// Transform the call arguments. // Transform the call arguments.
ASTOwningVector<&ActionBase::DeleteExpr> Args(SemaRef); ASTOwningVector<Expr*> Args(SemaRef);
llvm::SmallVector<SourceLocation, 4> FakeCommaLocs; llvm::SmallVector<SourceLocation, 4> FakeCommaLocs;
for (unsigned I = 1, N = E->getNumArgs(); I != N; ++I) { for (unsigned I = 1, N = E->getNumArgs(); I != N; ++I) {
if (getDerived().DropCallArgument(E->getArg(I))) if (getDerived().DropCallArgument(E->getArg(I)))
@ -5004,7 +5004,7 @@ TreeTransform<Derived>::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
if (First.isInvalid()) if (First.isInvalid())
return SemaRef.ExprError(); return SemaRef.ExprError();
OwningExprResult Second(SemaRef); OwningExprResult Second;
if (E->getNumArgs() == 2) { if (E->getNumArgs() == 2) {
Second = getDerived().TransformExpr(E->getArg(1)); Second = getDerived().TransformExpr(E->getArg(1));
if (Second.isInvalid()) if (Second.isInvalid())
@ -5266,7 +5266,7 @@ TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) {
// Transform the placement arguments (if any). // Transform the placement arguments (if any).
bool ArgumentChanged = false; bool ArgumentChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr> PlacementArgs(SemaRef); ASTOwningVector<Expr*> PlacementArgs(SemaRef);
for (unsigned I = 0, N = E->getNumPlacementArgs(); I != N; ++I) { for (unsigned I = 0, N = E->getNumPlacementArgs(); I != N; ++I) {
OwningExprResult Arg = getDerived().TransformExpr(E->getPlacementArg(I)); OwningExprResult Arg = getDerived().TransformExpr(E->getPlacementArg(I));
if (Arg.isInvalid()) if (Arg.isInvalid())
@ -5277,7 +5277,7 @@ TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) {
} }
// transform the constructor arguments (if any). // transform the constructor arguments (if any).
ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(SemaRef); ASTOwningVector<Expr*> ConstructorArgs(SemaRef);
for (unsigned I = 0, N = E->getNumConstructorArgs(); I != N; ++I) { for (unsigned I = 0, N = E->getNumConstructorArgs(); I != N; ++I) {
if (getDerived().DropCallArgument(E->getConstructorArg(I))) if (getDerived().DropCallArgument(E->getConstructorArg(I)))
break; break;
@ -5660,7 +5660,7 @@ TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) {
return SemaRef.ExprError(); return SemaRef.ExprError();
bool ArgumentChanged = false; bool ArgumentChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr> Args(SemaRef); ASTOwningVector<Expr*> Args(SemaRef);
for (CXXConstructExpr::arg_iterator Arg = E->arg_begin(), for (CXXConstructExpr::arg_iterator Arg = E->arg_begin(),
ArgEnd = E->arg_end(); ArgEnd = E->arg_end();
Arg != ArgEnd; ++Arg) { Arg != ArgEnd; ++Arg) {
@ -5743,7 +5743,7 @@ TreeTransform<Derived>::TransformCXXTemporaryObjectExpr(
return SemaRef.ExprError(); return SemaRef.ExprError();
bool ArgumentChanged = false; bool ArgumentChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr> Args(SemaRef); ASTOwningVector<Expr*> Args(SemaRef);
Args.reserve(E->getNumArgs()); Args.reserve(E->getNumArgs());
for (CXXTemporaryObjectExpr::arg_iterator Arg = E->arg_begin(), for (CXXTemporaryObjectExpr::arg_iterator Arg = E->arg_begin(),
ArgEnd = E->arg_end(); ArgEnd = E->arg_end();
@ -5795,7 +5795,7 @@ TreeTransform<Derived>::TransformCXXUnresolvedConstructExpr(
return SemaRef.ExprError(); return SemaRef.ExprError();
bool ArgumentChanged = false; bool ArgumentChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr> Args(SemaRef); ASTOwningVector<Expr*> Args(SemaRef);
llvm::SmallVector<SourceLocation, 8> FakeCommaLocs; llvm::SmallVector<SourceLocation, 8> FakeCommaLocs;
for (CXXUnresolvedConstructExpr::arg_iterator Arg = E->arg_begin(), for (CXXUnresolvedConstructExpr::arg_iterator Arg = E->arg_begin(),
ArgEnd = E->arg_end(); ArgEnd = E->arg_end();
@ -5829,7 +5829,7 @@ Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXDependentScopeMemberExpr( TreeTransform<Derived>::TransformCXXDependentScopeMemberExpr(
CXXDependentScopeMemberExpr *E) { CXXDependentScopeMemberExpr *E) {
// Transform the base of the expression. // Transform the base of the expression.
OwningExprResult Base(SemaRef, (Expr*) 0); OwningExprResult Base((Expr*) 0);
Expr *OldBase; Expr *OldBase;
QualType BaseType; QualType BaseType;
QualType ObjectType; QualType ObjectType;
@ -5926,7 +5926,7 @@ template<typename Derived>
Sema::OwningExprResult Sema::OwningExprResult
TreeTransform<Derived>::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old) { TreeTransform<Derived>::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old) {
// Transform the base of the expression. // Transform the base of the expression.
OwningExprResult Base(SemaRef, (Expr*) 0); OwningExprResult Base((Expr*) 0);
QualType BaseType; QualType BaseType;
if (!Old->isImplicitAccess()) { if (!Old->isImplicitAccess()) {
Base = getDerived().TransformExpr(Old->getBase()); Base = getDerived().TransformExpr(Old->getBase());
@ -6049,7 +6049,7 @@ Sema::OwningExprResult
TreeTransform<Derived>::TransformObjCMessageExpr(ObjCMessageExpr *E) { TreeTransform<Derived>::TransformObjCMessageExpr(ObjCMessageExpr *E) {
// Transform arguments. // Transform arguments.
bool ArgChanged = false; bool ArgChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr> Args(SemaRef); ASTOwningVector<Expr*> Args(SemaRef);
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) { for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
OwningExprResult Arg = getDerived().TransformExpr(E->getArg(I)); OwningExprResult Arg = getDerived().TransformExpr(E->getArg(I));
if (Arg.isInvalid()) if (Arg.isInvalid())
@ -6211,7 +6211,7 @@ template<typename Derived>
Sema::OwningExprResult Sema::OwningExprResult
TreeTransform<Derived>::TransformShuffleVectorExpr(ShuffleVectorExpr *E) { TreeTransform<Derived>::TransformShuffleVectorExpr(ShuffleVectorExpr *E) {
bool ArgumentChanged = false; bool ArgumentChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr> SubExprs(SemaRef); ASTOwningVector<Expr*> SubExprs(SemaRef);
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I) { for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I) {
OwningExprResult SubExpr = getDerived().TransformExpr(E->getExpr(I)); OwningExprResult SubExpr = getDerived().TransformExpr(E->getExpr(I));
if (SubExpr.isInvalid()) if (SubExpr.isInvalid())