diff options
28 files changed, 263 insertions, 428 deletions
diff --git a/include/clang/Sema/Ownership.h b/include/clang/Sema/Ownership.h index fb9e368dde..84d55f4251 100644 --- a/include/clang/Sema/Ownership.h +++ b/include/clang/Sema/Ownership.h @@ -30,6 +30,7 @@ namespace clang { class DeclGroupRef; class Expr; class NestedNameSpecifier; + class ParsedTemplateArgument; class QualType; class Sema; class Stmt; @@ -112,96 +113,6 @@ namespace llvm { struct isPodLike<clang::OpaquePtr<T> > { static const bool value = true; }; } - - -// -------------------------- About Move Emulation -------------------------- // -// The smart pointer classes in this file attempt to emulate move semantics -// as they appear in C++0x with rvalue references. Since C++03 doesn't have -// rvalue references, some tricks are needed to get similar results. -// Move semantics in C++0x have the following properties: -// 1) "Moving" means transferring the value of an object to another object, -// similar to copying, but without caring what happens to the old object. -// In particular, this means that the new object can steal the old object's -// resources instead of creating a copy. -// 2) Since moving can modify the source object, it must either be explicitly -// requested by the user, or the modifications must be unnoticeable. -// 3) As such, C++0x moving is only allowed in three contexts: -// * By explicitly using std::move() to request it. -// * From a temporary object, since that object cannot be accessed -// afterwards anyway, thus making the state unobservable. -// * On function return, since the object is not observable afterwards. -// -// To sum up: moving from a named object should only be possible with an -// explicit std::move(), or on function return. Moving from a temporary should -// be implicitly done. Moving from a const object is forbidden. -// -// The emulation is not perfect, and has the following shortcomings: -// * move() is not in namespace std. -// * move() is required on function return. -// * There are difficulties with implicit conversions. -// * Microsoft's compiler must be given the /Za switch to successfully compile. -// -// -------------------------- Implementation -------------------------------- // -// The move emulation relies on the peculiar reference binding semantics of -// C++03: as a rule, a non-const reference may not bind to a temporary object, -// except for the implicit object parameter in a member function call, which -// can refer to a temporary even when not being const. -// The moveable object has five important functions to facilitate moving: -// * A private, unimplemented constructor taking a non-const reference to its -// own class. This constructor serves a two-fold purpose. -// - It prevents the creation of a copy constructor that takes a const -// reference. Temporaries would be able to bind to the argument of such a -// constructor, and that would be bad. -// - Named objects will bind to the non-const reference, but since it's -// private, this will fail to compile. This prevents implicit moving from -// named objects. -// There's also a copy assignment operator for the same purpose. -// * An implicit, non-const conversion operator to a special mover type. This -// type represents the rvalue reference of C++0x. Being a non-const member, -// its implicit this parameter can bind to temporaries. -// * A constructor that takes an object of this mover type. This constructor -// performs the actual move operation. There is an equivalent assignment -// operator. -// There is also a free move() function that takes a non-const reference to -// an object and returns a temporary. Internally, this function uses explicit -// constructor calls to move the value from the referenced object to the return -// value. -// -// There are now three possible scenarios of use. -// * Copying from a const object. Constructor overload resolution will find the -// non-const copy constructor, and the move constructor. The first is not -// viable because the const object cannot be bound to the non-const reference. -// The second fails because the conversion to the mover object is non-const. -// Moving from a const object fails as intended. -// * Copying from a named object. Constructor overload resolution will select -// the non-const copy constructor, but fail as intended, because this -// constructor is private. -// * Copying from a temporary. Constructor overload resolution cannot select -// the non-const copy constructor, because the temporary cannot be bound to -// the non-const reference. It thus selects the move constructor. The -// temporary can be bound to the implicit this parameter of the conversion -// operator, because of the special binding rule. Construction succeeds. -// Note that the Microsoft compiler, as an extension, allows binding -// temporaries against non-const references. The compiler thus selects the -// non-const copy constructor and fails, because the constructor is private. -// Passing /Za (disable extensions) disables this behaviour. -// The free move() function is used to move from a named object. -// -// Note that when passing an object of a different type (the classes below -// have OwningResult and OwningPtr, which should be mixable), you get a problem. -// Argument passing and function return use copy initialization rules. The -// effect of this is that, when the source object is not already of the target -// type, the compiler will first seek a way to convert the source object to the -// target type, and only then attempt to copy the resulting object. This means -// that when passing an OwningResult where an OwningPtr is expected, the -// compiler will first seek a conversion from OwningResult to OwningPtr, then -// copy the OwningPtr. The resulting conversion sequence is: -// OwningResult object -> ResultMover -> OwningResult argument to -// OwningPtr(OwningResult) -> OwningPtr -> PtrMover -> final OwningPtr -// This conversion sequence is too complex to be allowed. Thus the special -// move_* functions, which help the compiler out with some explicit -// conversions. - namespace clang { // Basic class DiagnosticBuilder; @@ -239,6 +150,7 @@ namespace clang { bool isUsable() const { return !Invalid && Val; } PtrTy get() const { return Val; } + // FIXME: Replace with get. PtrTy release() const { return Val; } PtrTy take() const { return Val; } template <typename T> T *takeAs() { return static_cast<T*>(get()); } @@ -282,6 +194,7 @@ namespace clang { void *VP = reinterpret_cast<void *>(PtrWithInvalid & ~0x01); return PtrTraits::getFromVoidPointer(VP); } + // FIXME: Replace with get. PtrTy take() const { return get(); } PtrTy release() const { return get(); } template <typename T> T *takeAs() { return static_cast<T*>(get()); } @@ -300,23 +213,21 @@ namespace clang { } }; - /// ASTMultiPtr - A moveable smart pointer to multiple AST nodes. Only owns - /// the individual pointers, not the array holding them. - template <typename PtrTy> class ASTMultiPtr; - + /// ASTMultiPtr - A pointer to multiple AST nodes. template <class PtrTy> class ASTMultiPtr { PtrTy *Nodes; unsigned Count; public: - // Normal copying implicitly defined ASTMultiPtr() : Nodes(0), Count(0) {} + ASTMultiPtr(SmallVectorImpl<PtrTy> &v) + : Nodes(v.data()), Count(v.size()) {} + ASTMultiPtr(PtrTy *nodes, unsigned count) : Nodes(nodes), Count(count) {} + // FIXME: Remove these. explicit ASTMultiPtr(Sema &) : Nodes(0), Count(0) {} ASTMultiPtr(Sema &, PtrTy *nodes, unsigned count) : Nodes(nodes), Count(count) {} - // Fake mover in Parse/AstGuard.h needs this: - ASTMultiPtr(PtrTy *nodes, unsigned count) : Nodes(nodes), Count(count) {} /// Access to the raw pointers. PtrTy *get() const { return Nodes; } @@ -324,47 +235,8 @@ namespace clang { /// Access to the count. unsigned size() const { return Count; } - PtrTy *release() { - return Nodes; - } - }; - - class ParsedTemplateArgument; - - class ASTTemplateArgsPtr { - ParsedTemplateArgument *Args; - mutable unsigned Count; - - public: - ASTTemplateArgsPtr(Sema &actions, ParsedTemplateArgument *args, - unsigned count) : - Args(args), Count(count) { } - - // FIXME: Lame, not-fully-type-safe emulation of 'move semantics'. - ASTTemplateArgsPtr(ASTTemplateArgsPtr &Other) : - Args(Other.Args), Count(Other.Count) { - } - - // FIXME: Lame, not-fully-type-safe emulation of 'move semantics'. - ASTTemplateArgsPtr& operator=(ASTTemplateArgsPtr &Other) { - Args = Other.Args; - Count = Other.Count; - return *this; - } - - ParsedTemplateArgument *getArgs() const { return Args; } - unsigned size() const { return Count; } - - void reset(ParsedTemplateArgument *args, unsigned count) { - Args = args; - Count = count; - } - - const ParsedTemplateArgument &operator[](unsigned Arg) const; - - ParsedTemplateArgument *release() const { - return Args; - } + /// Access to the elements. + const PtrTy &operator[](unsigned Arg) const { return Nodes[Arg]; } }; /// \brief A small vector that owns a set of AST nodes. @@ -397,22 +269,6 @@ namespace clang { /// A SmallVector of types. typedef ASTOwningVector<ParsedType, 12> TypeVector; - template <class T, unsigned N> inline - ASTMultiPtr<T> move_arg(ASTOwningVector<T, N> &vec) { - return ASTMultiPtr<T>(vec.take(), vec.size()); - } - - // These versions are hopefully no-ops. - template <class T, bool C> - inline ActionResult<T,C> move(ActionResult<T,C> &ptr) { - return ptr; - } - - template <class T> inline - ASTMultiPtr<T>& move(ASTMultiPtr<T> &ptr) { - return ptr; - } - // We can re-use the low bit of expression, statement, base, and // member-initializer pointers for the "invalid" flag of // ActionResult. @@ -438,11 +294,9 @@ namespace clang { typedef ActionResult<Decl*> DeclResult; typedef OpaquePtr<TemplateName> ParsedTemplateTy; - inline Expr *move(Expr *E) { return E; } - inline Stmt *move(Stmt *S) { return S; } - typedef ASTMultiPtr<Expr*> MultiExprArg; typedef ASTMultiPtr<Stmt*> MultiStmtArg; + typedef ASTMultiPtr<ParsedTemplateArgument> ASTTemplateArgsPtr; typedef ASTMultiPtr<ParsedType> MultiTypeArg; typedef ASTMultiPtr<TemplateParameterList*> MultiTemplateParamsArg; diff --git a/include/clang/Sema/ParsedTemplate.h b/include/clang/Sema/ParsedTemplate.h index 69080ad9b1..94db454a85 100644 --- a/include/clang/Sema/ParsedTemplate.h +++ b/include/clang/Sema/ParsedTemplate.h @@ -209,11 +209,6 @@ namespace clang { /// Retrieves the range of the given template parameter lists. SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params, unsigned NumParams); - - inline const ParsedTemplateArgument & - ASTTemplateArgsPtr::operator[](unsigned Arg) const { - return Args[Arg]; - } } #endif diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 9c4bbcdd54..996ce06a38 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -2437,7 +2437,7 @@ public: FullExprArg(const FullExprArg& Other) : E(Other.E) {} ExprResult release() { - return move(E); + return E; } Expr *get() const { return E; } diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp index abce27c3f8..f29fc65a39 100644 --- a/lib/Parse/ParseCXXInlineMethods.cpp +++ b/lib/Parse/ParseCXXInlineMethods.cpp @@ -42,10 +42,10 @@ Decl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, D.setFunctionDefinitionKind(DefinitionKind); if (D.getDeclSpec().isFriendSpecified()) FnD = Actions.ActOnFriendFunctionDecl(getCurScope(), D, - move(TemplateParams)); + TemplateParams); else { FnD = Actions.ActOnCXXMemberDeclarator(getCurScope(), AS, D, - move(TemplateParams), 0, + TemplateParams, 0, VS, ICIS_NoInit); if (FnD) { Actions.ProcessDeclAttributeList(getCurScope(), FnD, AccessAttrs, diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 85d3f5a7da..2638e12200 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1694,7 +1694,7 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(Declarator &D, ExprResult Initializer = Actions.ActOnParenListExpr(T.getOpenLocation(), T.getCloseLocation(), - move_arg(Exprs)); + Exprs); Actions.AddInitializerToDecl(ThisDecl, Initializer.take(), /*DirectInit=*/true, TypeContainsAuto); } diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 3dc96cf0d2..d8fcd5680c 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -2052,11 +2052,11 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, if (DS.isFriendSpecified()) { // TODO: handle initializers, bitfields, 'delete' ThisDecl = Actions.ActOnFriendFunctionDecl(getCurScope(), DeclaratorInfo, - move(TemplateParams)); + TemplateParams); } else { ThisDecl = Actions.ActOnCXXMemberDeclarator(getCurScope(), AS, DeclaratorInfo, - move(TemplateParams), + TemplateParams, BitfieldSize.release(), VS, HasInClassInit); if (AccessAttrs) diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 8d4668b954..6c4d6fbee8 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -179,7 +179,7 @@ static prec::Level getBinOpPrecedence(tok::TokenKind Kind, /// \endverbatim ExprResult Parser::ParseExpression(TypeCastState isTypeCast) { ExprResult LHS(ParseAssignmentExpression(isTypeCast)); - return ParseRHSOfBinaryExpression(move(LHS), prec::Comma); + return ParseRHSOfBinaryExpression(LHS, prec::Comma); } /// This routine is called when the '@' is seen and consumed. @@ -190,7 +190,7 @@ ExprResult Parser::ParseExpression(TypeCastState isTypeCast) { ExprResult Parser::ParseExpressionWithLeadingAt(SourceLocation AtLoc) { ExprResult LHS(ParseObjCAtExpression(AtLoc)); - return ParseRHSOfBinaryExpression(move(LHS), prec::Comma); + return ParseRHSOfBinaryExpression(LHS, prec::Comma); } /// This routine is called when a leading '__extension__' is seen and @@ -210,7 +210,7 @@ Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) { LHS = Actions.ActOnUnaryOp(getCurScope(), ExtLoc, tok::kw___extension__, LHS.take()); - return ParseRHSOfBinaryExpression(move(LHS), prec::Comma); + return ParseRHSOfBinaryExpression(LHS, prec::Comma); } /// \brief Parse an expr that doesn't include (top-level) commas. @@ -227,7 +227,7 @@ ExprResult Parser::ParseAssignmentExpression(TypeCastState isTypeCast) { ExprResult LHS = ParseCastExpression(/*isUnaryExpression=*/false, /*isAddressOfOperand=*/false, isTypeCast); - return ParseRHSOfBinaryExpression(move(LHS), prec::Assignment); + return ParseRHSOfBinaryExpression(LHS, prec::Assignment); } /// \brief Parse an assignment expression where part of an Objective-C message @@ -279,7 +279,7 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) { // because we are called recursively, or because the token is not a binop), // then we are done! if (NextTokPrec < MinPrec) - return move(LHS); + return LHS; // Consume the operator, saving the operator token for error reporting. Token OpToken = Tok; @@ -458,7 +458,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, isTypeCast); if (NotCastExpr) Diag(Tok, diag::err_expected_expression); - return move(Res); + return Res; } namespace { @@ -698,7 +698,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, case CastExpr: // We have parsed the cast-expression and no postfix-expr pieces are // following. - return move(Res); + return Res; } break; @@ -888,7 +888,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, Res = ParseCastExpression(!getLangOpts().CPlusPlus); if (!Res.isInvalid()) Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, Res.get()); - return move(Res); + return Res; } case tok::amp: { // unary-expression: '&' cast-expression // Special treatment because of member pointers @@ -896,7 +896,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, Res = ParseCastExpression(false, true); if (!Res.isInvalid()) Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, Res.get()); - return move(Res); + return Res; } case tok::star: // unary-expression: '*' cast-expression @@ -910,7 +910,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, Res = ParseCastExpression(false); if (!Res.isInvalid()) Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, Res.get()); - return move(Res); + return Res; } case tok::kw___extension__:{//unary-expression:'__extension__' cast-expr [GNU] @@ -920,7 +920,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, Res = ParseCastExpression(false); if (!Res.isInvalid()) Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, Res.get()); - return move(Res); + return Res; } case tok::kw__Alignof: // unary-expression: '_Alignof' '(' type-name ')' if (!getLangOpts().C11) @@ -946,7 +946,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, Tok.getLocation()); Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(), LD); ConsumeToken(); - return move(Res); + return Res; } case tok::kw_const_cast: case tok::kw_dynamic_cast: @@ -1132,7 +1132,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, if (!Result.isInvalid()) Result = Actions.ActOnNoexceptExpr(KeyLoc, T.getOpenLocation(), Result.take(), T.getCloseLocation()); - return move(Result); + return Result; } case tok::kw___is_abstract: // [GNU] unary-type-trait @@ -1270,7 +1270,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { switch (Tok.getKind()) { case tok::code_completion: if (InMessageExpression) - return move(LHS); + return LHS; Actions.CodeCompletePostfixExpression(getCurScope(), LHS); cutOffParsing(); @@ -1290,7 +1290,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { // Fall through; this isn't a message send. default: // Not a postfix-expression suffix. - return move(LHS); + return LHS; case tok::l_square: { // postfix-expression: p-e '[' expression ']' // If we have a array postfix expression that starts on a new line and // Objective-C is enabled, it is highly likely that the user forgot a @@ -1300,7 +1300,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { // expression and recover by pretending there is no suffix. if (getLangOpts().ObjC1 && Tok.isAtStartOfLine() && isSimpleObjCMessageExpression()) - return move(LHS); + return LHS; // Reject array indices starting with a lambda-expression. '[[' is // reserved for attributes. @@ -1372,7 +1372,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { if (!LHS.isInvalid()) { ExprResult ECResult = Actions.ActOnCUDAExecConfigExpr(getCurScope(), OpenLoc, - move_arg(ExecConfigExprs), + ExecConfigExprs, CloseLoc); if (ECResult.isInvalid()) LHS = ExprError(); @@ -1414,7 +1414,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { ArgExprs.size()-1 == CommaLocs.size())&& "Unexpected number of commas!"); LHS = Actions.ActOnCallExpr(getCurScope(), LHS.take(), Loc, - move_arg(ArgExprs), Tok.getLocation(), + ArgExprs, Tok.getLocation(), ExecConfig); PT.consumeClose(); } @@ -1583,7 +1583,7 @@ Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok, // If we get here, the operand to the typeof/sizeof/alignof was an expresion. isCastExpr = false; - return move(Operand); + return Operand; } @@ -1684,7 +1684,7 @@ ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() { /*isType=*/false, Operand.release(), CastRange); - return move(Operand); + return Operand; } /// ParseBuiltinPrimaryExpression @@ -1796,7 +1796,7 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() { Res = ParseExpression(); if (Res.isInvalid()) { SkipUntil(tok::r_paren); - return move(Res); + return Res; } Comps.back().U.E = Res.release(); @@ -1823,7 +1823,7 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() { ExprResult Cond(ParseAssignmentExpression()); if (Cond.isInvalid()) { SkipUntil(tok::r_paren); - return move(Cond); + return Cond; } if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "",tok::r_paren)) return ExprError(); @@ -1831,7 +1831,7 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() { ExprResult Expr1(ParseAssignmentExpression()); if (Expr1.isInvalid()) { SkipUntil(tok::r_paren); - return move(Expr1); + return Expr1; } if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "",tok::r_paren)) return ExprError(); @@ -1839,7 +1839,7 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() { ExprResult Expr2(ParseAssignmentExpression()); if (Expr2.isInvalid()) { SkipUntil(tok::r_paren); - return move(Expr2); + return Expr2; } if (Tok.isNot(tok::r_paren)) { Diag(Tok, diag::err_expected_rparen); @@ -2083,7 +2083,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, DeclaratorInfo, CastTy, RParenLoc, Result.take()); } - return move(Result); + return Result; } Diag(Tok, diag::err_expected_lbrace_in_compound_literal); @@ -2099,7 +2099,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, if (!ParseExpressionList(ArgExprs, CommaLocs)) { ExprType = SimpleExpr; Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(), - move_arg(ArgExprs)); + ArgExprs); } } else { InMessageExpressionRAIIObject InMessage(*this, false); @@ -2120,7 +2120,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, T.consumeClose(); RParenLoc = T.getCloseLocation(); - return move(Result); + return Result; } /// ParseCompoundLiteralExpression - We have parsed the parenthesized type-name @@ -2141,7 +2141,7 @@ Parser::ParseCompoundLiteralExpression(ParsedType Ty, ExprResult Result = ParseInitializer(); if (!Result.isInvalid() && Ty) return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, Result.take()); - return move(Result); + return Result; } /// ParseStringLiteralExpression - This handles the various token types that @@ -2263,7 +2263,7 @@ ExprResult Parser::ParseGenericSelectionExpression() { return Actions.ActOnGenericSelectionExpr(KeyLoc, DefaultLoc, T.getCloseLocation(), ControllingExpr.release(), - move_arg(Types), move_arg(Exprs)); + Types, Exprs); } /// ParseExpressionList - Used for C/C++ (argument-)expression-list. @@ -2450,7 +2450,7 @@ ExprResult Parser::ParseBlockLiteralExpression() { Result = Actions.ActOnBlockStmtExpr(CaretLoc, Stmt.take(), getCurScope()); else Actions.ActOnBlockError(CaretLoc, getCurScope()); - return move(Result); + return Result; } /// ParseObjCBoolLiteral - This handles the objective-c Boolean literals. diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index baad166814..c1823426f1 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -966,7 +966,7 @@ ExprResult Parser::ParseCXXCasts() { T.getOpenLocation(), Result.take(), T.getCloseLocation()); - return move(Result); + return Result; } /// ParseCXXTypeid - This handles the C++ typeid expression. @@ -1032,7 +1032,7 @@ ExprResult Parser::ParseCXXTypeid() { } } - return move(Result); + return Result; } /// ParseCXXUuidof - This handles the Microsoft C++ __uuidof expression. @@ -1080,7 +1080,7 @@ ExprResult Parser::ParseCXXUuidof() { } } - return move(Result); + return Result; } /// \brief Parse a C++ pseudo-destructor expression after the base, @@ -1202,7 +1202,7 @@ ExprResult Parser::ParseThrowExpression() { default: ExprResult Expr(ParseAssignmentExpression()); - if (Expr.isInvalid()) return move(Expr); + if (Expr.isInvalid()) return Expr; return Actions.ActOnCXXThrow(getCurScope(), ThrowLoc, Expr.take()); } } @@ -1271,7 +1271,7 @@ Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) { assert((Exprs.size() == 0 || Exprs.size()-1 == CommaLocs.size())&& "Unexpected number of commas!"); return Actions.ActOnCXXTypeConstructExpr(TypeRep, T.getOpenLocation(), - move_arg(Exprs), + Exprs, T.getCloseLocation()); } } @@ -2304,7 +2304,7 @@ Parser::ParseCXXNewExpression(bool UseGlobal, SourceLocation Start) { } Initializer = Actions.ActOnParenListExpr(ConstructorLParen, ConstructorRParen, - move_arg(ConstructorArgs)); + ConstructorArgs); } else if (Tok.is(tok::l_brace) && getLangOpts().CPlusPlus0x) { Diag(Tok.getLocation(), diag::warn_cxx98_compat_generalized_initializer_lists); @@ -2314,7 +2314,7 @@ Parser::ParseCXXNewExpression(bool UseGlobal, SourceLocation Start) { return Initializer; return Actions.ActOnCXXNew(Start, UseGlobal, PlacementLParen, - move_arg(PlacementArgs), PlacementRParen, + PlacementArgs, PlacementRParen, TypeIdParens, DeclaratorInfo, Initializer.take()); } @@ -2428,7 +2428,7 @@ Parser::ParseCXXDeleteExpression(bool UseGlobal, SourceLocation Start) { ExprResult Operand(ParseCastExpression(false)); if (Operand.isInvalid()) - return move(Operand); + return Operand; return Actions.ActOnCXXDelete(Start, UseGlobal, ArrayDelete, Operand.take()); } @@ -2810,7 +2810,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType, Result = Actions.ActOnCastExpr(getCurScope(), Tracker.getOpenLocation(), DeclaratorInfo, CastTy, Tracker.getCloseLocation(), Result.take()); - return move(Result); + return Result; } // Not a compound literal, and not followed by a cast-expression. @@ -2829,5 +2829,5 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType, } Tracker.consumeClose(); - return move(Result); + return Result; } diff --git a/lib/Parse/ParseInit.cpp b/lib/Parse/ParseInit.cpp index 1c349fddbd..3aadd26399 100644 --- a/lib/Parse/ParseInit.cpp +++ b/lib/Parse/ParseInit.cpp @@ -313,7 +313,7 @@ ExprResult Parser::ParseInitializerWithPotentialDesignator() { Idx = ParseAssignmentExpression(); if (Idx.isInvalid()) { SkipUntil(tok::r_square); - return move(Idx); + return Idx; } } @@ -341,7 +341,7 @@ ExprResult Parser::ParseInitializerWithPotentialDesignator() { ExprResult RHS(ParseConstantExpression()); if (RHS.isInvalid()) { SkipUntil(tok::r_square); - return move(RHS); + return RHS; } Desig.AddDesignator(Designator::getArrayRange(Idx.release(), RHS.release(), @@ -476,7 +476,7 @@ ExprResult Parser::ParseBraceInitializer() { bool closed = !T.consumeClose(); if (InitExprsOk && closed) - return Actions.ActOnInitList(LBraceLoc, move_arg(InitExprs), + return Actions.ActOnInitList(LBraceLoc, InitExprs, T.getCloseLocation()); return ExprError(); // an error occurred. diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index db35a386c3..1fd60a2663 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -1894,7 +1894,7 @@ StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { } return Actions.ActOnObjCAtTryStmt(atLoc, TryBody.take(), - move_arg(CatchStmts), + CatchStmts, FinallyStmt.take()); } @@ -2061,13 +2061,13 @@ ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) { ExprResult Lit(Actions.ActOnNumericConstant(Tok)); if (Lit.isInvalid()) { - return move(Lit); + return Lit; } ConsumeToken(); // Consume the literal token. |