[cfe-commits] r60809 - in /cfe/trunk: include/clang/Parse/Ownership.h include/clang/Parse/Parser.h lib/Parse/ParseDecl.cpp lib/Parse/ParseDeclCXX.cpp lib/Parse/ParseExpr.cpp lib/Parse/ParseExprCXX.cpp lib/Parse/ParseInit.cpp lib/Parse/ParseObjc.cpp lib/Parse/ParsePragma.cpp lib/Parse/ParseStmt.cpp lib/Parse/Parser.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Tue Dec 9 16:02:53 PST 2008


Author: cornedbee
Date: Tue Dec  9 18:02:53 2008
New Revision: 60809

URL: http://llvm.org/viewvc/llvm-project?rev=60809&view=rev
Log:
Modify the move emulation according to the excellent design of Howard Hinnant. Makes for much nicer syntax when smart pointers are used consistently. Also, start converting internal argument passing of Parser to smart pointers.

Modified:
    cfe/trunk/include/clang/Parse/Ownership.h
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/lib/Parse/ParseExprCXX.cpp
    cfe/trunk/lib/Parse/ParseInit.cpp
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/lib/Parse/ParsePragma.cpp
    cfe/trunk/lib/Parse/ParseStmt.cpp
    cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/include/clang/Parse/Ownership.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Ownership.h?rev=60809&r1=60808&r2=60809&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Ownership.h (original)
+++ cfe/trunk/include/clang/Parse/Ownership.h Tue Dec  9 18:02:53 2008
@@ -83,50 +83,49 @@
   /// the individual pointers, not the array holding them.
   template <ASTDestroyer Destroyer> class ASTMultiPtr;
 
-  /// Move emulation helper for ASTOwningResult
-  template <ASTDestroyer Destroyer>
-  class ASTResultMover
-  {
-    ASTOwningResult<Destroyer> &Moved;
-
-  public:
-    ASTResultMover(ASTOwningResult<Destroyer> &moved) : Moved(moved) {}
-
-    ASTOwningResult<Destroyer> * operator ->() { return &Moved; }
+  namespace moving {
+    /// Move emulation helper for ASTOwningResult. NEVER EVER use this class
+    /// directly if you don't know what you're doing.
+    template <ASTDestroyer Destroyer>
+    class ASTResultMover
+    {
+      ASTOwningResult<Destroyer> &Moved;
 
-    // For the transition phase.
-    operator void*();
+    public:
+      ASTResultMover(ASTOwningResult<Destroyer> &moved) : Moved(moved) {}
 
-    // For the transition phase.
-    operator ActionBase::ActionResult<DestroyerToUID<Destroyer>::UID>();
-  };
+      ASTOwningResult<Destroyer> * operator ->() { return &Moved; }
+    };
 
-  /// Move emulation helper for ASTOwningPtr
-  template <ASTDestroyer Destroyer>
-  class ASTPtrMover
-  {
-    ASTOwningPtr<Destroyer> &Moved;
+    /// Move emulation helper for ASTOwningPtr. NEVER EVER use this class
+    /// directly if you don't know what you're doing.
+    template <ASTDestroyer Destroyer>
+    class ASTPtrMover
+    {
+      ASTOwningPtr<Destroyer> &Moved;
 
-  public:
-    ASTPtrMover(ASTOwningPtr<Destroyer> &moved) : Moved(moved) {}
+    public:
+      ASTPtrMover(ASTOwningPtr<Destroyer> &moved) : Moved(moved) {}
 
-    ASTOwningPtr<Destroyer> * operator ->() { return &Moved; }
+      ASTOwningPtr<Destroyer> * operator ->() { return &Moved; }
+    };
 
-    operator void*();
-  };
+    /// Move emulation helper for ASTMultiPtr. NEVER EVER use this class
+    /// directly if you don't know what you're doing.
+    template <ASTDestroyer Destroyer>
+    class ASTMultiMover
+    {
+      ASTMultiPtr<Destroyer> &Moved;
 
-  /// Move emulation helper for ASTMultiPtr
-  template <ASTDestroyer Destroyer>
-  class ASTMultiMover
-  {
-    ASTMultiPtr<Destroyer> &Moved;
+    public:
+      ASTMultiMover(ASTMultiPtr<Destroyer> &moved) : Moved(moved) {}
 
-  public:
-    ASTMultiMover(ASTMultiPtr<Destroyer> &moved) : Moved(moved) {}
+      ASTMultiPtr<Destroyer> * operator ->() { return &Moved; }
 
-    /// Reset the moved object's internal structures.
-    void release();
-  };
+      /// Reset the moved object's internal structures.
+      void release();
+    };
+  }
 
   template <ASTDestroyer Destroyer>
   class ASTOwningResult
@@ -135,11 +134,11 @@
     void *Node;
     bool Invalid;
 
-    friend class ASTResultMover<Destroyer>;
+    friend class moving::ASTResultMover<Destroyer>;
     friend class ASTOwningPtr<Destroyer>;
 
-    ASTOwningResult(const ASTOwningResult&); // DO NOT IMPLEMENT
-    ASTOwningResult& operator =(const ASTOwningResult&); // DO NOT IMPLEMENT
+    ASTOwningResult(ASTOwningResult&); // DO NOT IMPLEMENT
+    ASTOwningResult& operator =(ASTOwningResult&); // DO NOT IMPLEMENT
 
     void destroy() {
       if (Node) {
@@ -148,12 +147,6 @@
       }
     }
 
-    void * take() {
-      if (Invalid)
-        return 0;
-      return Node;
-    }
-
   public:
     typedef ActionBase::ActionResult<DestroyerToUID<Destroyer>::UID> DumbResult;
 
@@ -170,13 +163,13 @@
     ASTOwningResult(ActionBase &actions, const DumbResult &res)
       : Actions(&actions), Node(res.Val), Invalid(res.isInvalid) {}
     /// Move from another owning result
-    ASTOwningResult(ASTResultMover<Destroyer> mover)
+    ASTOwningResult(moving::ASTResultMover<Destroyer> mover)
       : Actions(mover->Actions), Node(mover->take()), Invalid(mover->Invalid) {}
     /// Move from an owning pointer
-    ASTOwningResult(ASTPtrMover<Destroyer> mover);
+    ASTOwningResult(moving::ASTPtrMover<Destroyer> mover);
 
     /// Move assignment from another owning result
-    ASTOwningResult & operator =(ASTResultMover<Destroyer> mover) {
+    ASTOwningResult & operator =(moving::ASTResultMover<Destroyer> mover) {
       Actions = mover->Actions;
       Node = mover->take();
       Invalid = mover->Invalid;
@@ -184,7 +177,7 @@
     }
 
     /// Move assignment from an owning ptr
-    ASTOwningResult & operator =(ASTPtrMover<Destroyer> mover);
+    ASTOwningResult & operator =(moving::ASTPtrMover<Destroyer> mover);
 
     /// Assignment from a raw pointer. Takes ownership - beware!
     ASTOwningResult & operator =(void *raw)
@@ -214,9 +207,30 @@
     /// valid and non-null.
     bool isUsable() const { return !Invalid && Node; }
 
+    /// Take outside ownership of the raw pointer.
+    void * take() {
+      if (Invalid)
+        return 0;
+      void *tmp = Node;
+      Node = 0;
+      return tmp;
+    }
+
+    /// Alias for interface familiarity with unique_ptr.
+    void * release() {
+      return take();
+    }
+
+    /// Pass ownership to a classical ActionResult.
+    DumbResult result() {
+      if (Invalid)
+        return true;
+      return Node;
+    }
+
     /// Move hook
-    ASTResultMover<Destroyer> move() {
-      return ASTResultMover<Destroyer>(*this);
+    operator moving::ASTResultMover<Destroyer>() {
+      return moving::ASTResultMover<Destroyer>(*this);
     }
   };
 
@@ -226,11 +240,11 @@
     ActionBase *Actions;
     void *Node;
 
-    friend class ASTPtrMover<Destroyer>;
+    friend class moving::ASTPtrMover<Destroyer>;
     friend class ASTOwningResult<Destroyer>;
 
-    ASTOwningPtr(const ASTOwningPtr&); // DO NOT IMPLEMENT
-    ASTOwningPtr& operator =(const ASTOwningPtr&); // DO NOT IMPLEMENT
+    ASTOwningPtr(ASTOwningPtr&); // DO NOT IMPLEMENT
+    ASTOwningPtr& operator =(ASTOwningPtr&); // DO NOT IMPLEMENT
 
     void destroy() {
       if (Node) {
@@ -245,20 +259,20 @@
     ASTOwningPtr(ActionBase &actions, void *node)
       : Actions(&actions), Node(node) {}
     /// Move from another owning pointer
-    ASTOwningPtr(ASTPtrMover<Destroyer> mover)
+    ASTOwningPtr(moving::ASTPtrMover<Destroyer> mover)
       : Actions(mover->Actions), Node(mover->take()) {}
     /// Move from an owning result
-    ASTOwningPtr(ASTResultMover<Destroyer> mover);
+    ASTOwningPtr(moving::ASTResultMover<Destroyer> mover);
 
     /// Move assignment from another owning pointer
-    ASTOwningPtr & operator =(ASTPtrMover<Destroyer> mover) {
+    ASTOwningPtr & operator =(moving::ASTPtrMover<Destroyer> mover) {
       Actions = mover->Actions;
       Node = mover->take();
       return *this;
     }
 
     /// Move assignment from an owning result
-    ASTOwningPtr & operator =(ASTResultMover<Destroyer> mover);
+    ASTOwningPtr & operator =(moving::ASTResultMover<Destroyer> mover);
 
     /// Assignment from a raw pointer. Takes ownership - beware!
     ASTOwningPtr & operator =(void *raw)
@@ -271,9 +285,21 @@
     /// Access to the raw pointer.
     void * get() const { return Node; }
 
+    /// Release the raw pointer.
+    void * take() {
+      void *tmp = Node;
+      Node = 0;
+      return tmp;
+    }
+
+    /// Alias for interface familiarity with unique_ptr.
+    void * release() {
+      return take();
+    }
+
     /// Move hook
-    ASTPtrMover<Destroyer> move() {
-      return ASTPtrMover<Destroyer>(*this);
+    operator moving::ASTPtrMover<Destroyer>() {
+      return moving::ASTPtrMover<Destroyer>(*this);
     }
   };
 
@@ -284,9 +310,9 @@
     void **Nodes;
     unsigned Count;
 
-    friend class ASTMultiMover<Destroyer>;
+    friend class moving::ASTMultiMover<Destroyer>;
 
-    ASTMultiPtr(const ASTMultiPtr&); // DO NOT IMPLEMENT
+    ASTMultiPtr(ASTMultiPtr&); // DO NOT IMPLEMENT
     // Reference member prevents copy assignment.
 
     void destroy() {
@@ -303,15 +329,14 @@
     ASTMultiPtr(ActionBase &actions, void **nodes, unsigned count)
       : Actions(actions), Nodes(nodes), Count(count) {}
     /// Move constructor
-    ASTMultiPtr(ASTMultiMover<Destroyer> mover)
+    ASTMultiPtr(moving::ASTMultiMover<Destroyer> mover)
       : Actions(mover->Actions), Nodes(mover->Nodes), Count(mover->Count) {
-      mover->Nodes = 0;
-      mover->Count = 0;
+      mover.release();
     }
 
     /// Move assignment
-    ASTMultiPtr & operator =(ASTMultiMover<Destroyer> mover) {
-      Actions = mover->Actions;
+    ASTMultiPtr & operator =(moving::ASTMultiMover<Destroyer> mover) {
+      destroy();
       Nodes = mover->Nodes;
       Count = mover->Count;
       mover.release();
@@ -325,45 +350,27 @@
     unsigned size() const { return Count; }
 
     /// Move hook
-    ASTMultiMover<Destroyer> move() {
-      return ASTMultiMover<Destroyer>(*this);
+    operator moving::ASTMultiMover<Destroyer>() {
+      return moving::ASTMultiMover<Destroyer>(*this);
     }
   };
 
   // Out-of-line implementations due to definition dependencies
 
   template <ASTDestroyer Destroyer> inline
-  ASTResultMover<Destroyer>::operator void*() {
-    return Moved.take();
-  }
-
-  template <ASTDestroyer Destroyer> inline
-  ASTResultMover<Destroyer>::operator
-                    ActionBase::ActionResult<DestroyerToUID<Destroyer>::UID>()
-  {
-    if(Moved.isInvalid())
-      return true;
-    return Moved.take();
-  }
-
-  template <ASTDestroyer Destroyer> inline
-  ASTPtrMover<Destroyer>::operator void*() {
-    return Moved.take();
-  }
-
-  template <ASTDestroyer Destroyer> inline
-  void ASTMultiMover<Destroyer>::release() {
+  void moving::ASTMultiMover<Destroyer>::release() {
     Moved.Nodes = 0;
     Moved.Count = 0;
   }
 
   template <ASTDestroyer Destroyer> inline
-  ASTOwningResult<Destroyer>::ASTOwningResult(ASTPtrMover<Destroyer> mover)
+  ASTOwningResult<Destroyer>::ASTOwningResult(
+                                          moving::ASTPtrMover<Destroyer> mover)
     : Actions(mover->Actions), Node(mover->take()), Invalid(false) {}
 
   template <ASTDestroyer Destroyer> inline
   ASTOwningResult<Destroyer> &
-  ASTOwningResult<Destroyer>::operator =(ASTPtrMover<Destroyer> mover) {
+  ASTOwningResult<Destroyer>::operator =(moving::ASTPtrMover<Destroyer> mover) {
     Actions = mover->Actions;
     Node = mover->take();
     Invalid = false;
@@ -371,17 +378,34 @@
   }
 
   template <ASTDestroyer Destroyer> inline
-  ASTOwningPtr<Destroyer>::ASTOwningPtr(ASTResultMover<Destroyer> mover)
+  ASTOwningPtr<Destroyer>::ASTOwningPtr(moving::ASTResultMover<Destroyer> mover)
     : Actions(mover->Actions), Node(mover->take()) {
   }
 
   template <ASTDestroyer Destroyer> inline
   ASTOwningPtr<Destroyer> &
-  ASTOwningPtr<Destroyer>::operator =(ASTResultMover<Destroyer> mover) {
+  ASTOwningPtr<Destroyer>::operator =(moving::ASTResultMover<Destroyer> mover) {
     Actions = mover->Actions;
     Node = mover->take();
     return *this;
   }
+
+  // Move overloads.
+
+  template <ASTDestroyer Destroyer> inline
+  ASTOwningResult<Destroyer> move(ASTOwningResult<Destroyer> &ptr) {
+    return ASTOwningResult<Destroyer>(moving::ASTResultMover<Destroyer>(ptr));
+  }
+
+  template <ASTDestroyer Destroyer> inline
+  ASTOwningPtr<Destroyer> move(ASTOwningPtr<Destroyer> &ptr) {
+    return ASTOwningPtr<Destroyer>(moving::ASTPtrMover<Destroyer>(ptr));
+  }
+
+  template <ASTDestroyer Destroyer> inline
+  ASTMultiPtr<Destroyer> move(ASTMultiPtr<Destroyer> &ptr) {
+    return ASTMultiPtr<Destroyer>(moving::ASTMultiMover<Destroyer>(ptr));
+  }
 }
 
 #endif

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=60809&r1=60808&r2=60809&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Dec  9 18:02:53 2008
@@ -379,8 +379,8 @@
   DeclTy *ParseDeclarationOrFunctionDefinition();
   DeclTy *ParseFunctionDefinition(Declarator &D);
   void ParseKNRParamDeclarations(Declarator &D);
-  ExprResult ParseSimpleAsm();
-  ExprResult ParseAsmStringLiteral();
+  OwningExprResult ParseSimpleAsm();
+  OwningExprResult ParseAsmStringLiteral();
 
   // Objective-C External Declarations
   DeclTy *ParseObjCAtDirectives(); 

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=60809&r1=60808&r2=60809&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Dec  9 18:02:53 2008
@@ -132,7 +132,7 @@
                 SkipUntil(tok::r_paren);
                 break;
               } else {
-                ArgExprs.push_back(ArgExpr.move());
+                ArgExprs.push_back(ArgExpr.release());
               }
               if (Tok.isNot(tok::comma))
                 break;
@@ -164,7 +164,7 @@
                 SkipUntil(tok::r_paren);
                 break;
               } else {
-                ArgExprs.push_back(ArgExpr.move());
+                ArgExprs.push_back(ArgExpr.release());
               }
               if (Tok.isNot(tok::comma))
                 break;
@@ -270,13 +270,13 @@
   while (1) {
     // If a simple-asm-expr is present, parse it.
     if (Tok.is(tok::kw_asm)) {
-      OwningExprResult AsmLabel(Actions, ParseSimpleAsm());
+      OwningExprResult AsmLabel(ParseSimpleAsm());
       if (AsmLabel.isInvalid()) {
         SkipUntil(tok::semi);
         return 0;
       }
       
-      D.setAsmLabel(AsmLabel.move());
+      D.setAsmLabel(AsmLabel.release());
     }
     
     // If attributes are present, parse them.
@@ -294,7 +294,7 @@
         SkipUntil(tok::semi);
         return 0;
       }
-      Actions.AddInitializerToDecl(LastDeclInGroup, Init.move());
+      Actions.AddInitializerToDecl(LastDeclInGroup, Init.release());
     } else if (Tok.is(tok::l_paren)) {
       // Parse C++ direct initializer: '(' expression-list ')'
       SourceLocation LParenLoc = ConsumeParen();
@@ -846,7 +846,7 @@
       if (Res.isInvalid())
         SkipUntil(tok::semi, true, true);
       else
-        DeclaratorInfo.BitfieldSize = Res.move();
+        DeclaratorInfo.BitfieldSize = Res.release();
     }
     
     // If attributes exist after the declarator, parse them.
@@ -1087,7 +1087,7 @@
                                                       LastEnumConstDecl,
                                                       IdentLoc, Ident,
                                                       EqualLoc,
-                                                      AssignedVal.move());
+                                                      AssignedVal.release());
     EnumConstantDecls.push_back(EnumConstDecl);
     LastEnumConstDecl = EnumConstDecl;
     
@@ -1802,7 +1802,7 @@
         } else {
           // Inform the actions module about the default argument
           Actions.ActOnParamDefaultArgument(Param, EqualLoc,
-                                            DefArgResult.move());
+                                            DefArgResult.release());
         }
       }
       
@@ -1973,7 +1973,7 @@
   // Remember that we parsed a pointer type, and remember the type-quals.
   D.AddTypeInfo(DeclaratorChunk::getArray(DS.getTypeQualifiers(),
                                           StaticLoc.isValid(), isStar,
-                                          NumElements.move(), StartLoc));
+                                          NumElements.release(), StartLoc));
 }
 
 /// [GNU]   typeof-specifier:
@@ -2000,7 +2000,7 @@
     const char *PrevSpec = 0;
     // Check for duplicate type specifiers.
     if (DS.SetTypeSpecType(DeclSpec::TST_typeofExpr, StartLoc, PrevSpec, 
-                           Result.move()))
+                           Result.release()))
       Diag(StartLoc, diag::err_invalid_decl_spec_combination) << PrevSpec;
 
     // FIXME: Not accurate, the range gets one token more than it should.
@@ -2035,7 +2035,7 @@
     const char *PrevSpec = 0;
     // Check for duplicate type specifiers (e.g. "int typeof(int)").
     if (DS.SetTypeSpecType(DeclSpec::TST_typeofExpr, StartLoc, PrevSpec, 
-                           Result.move()))
+                           Result.release()))
       Diag(StartLoc, diag::err_invalid_decl_spec_combination) << PrevSpec;
   }
   DS.SetRangeEnd(RParenLoc);

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=60809&r1=60808&r2=60809&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Dec  9 18:02:53 2008
@@ -529,8 +529,8 @@
     // See Sema::ActOnCXXMemberDeclarator for details.
     LastDeclInGroup = Actions.ActOnCXXMemberDeclarator(CurScope, AS,
                                                        DeclaratorInfo,
-                                                       BitfieldSize.move(),
-                                                       Init.move(),
+                                                       BitfieldSize.release(),
+                                                       Init.release(),
                                                        LastDeclInGroup);
 
     // If we don't have a comma, it is either the end of the list (a ';')

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=60809&r1=60808&r2=60809&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue Dec  9 18:02:53 2008
@@ -174,9 +174,9 @@
     return ParseThrowExpression();
 
   OwningExprResult LHS(Actions, ParseCastExpression(false));
-  if (LHS.isInvalid()) return LHS.move();
+  if (LHS.isInvalid()) return LHS.result();
   
-  return ParseRHSOfBinaryExpression(LHS.move(), prec::Comma);
+  return ParseRHSOfBinaryExpression(LHS.result(), prec::Comma);
 }
 
 /// This routine is called when the '@' is seen and consumed. 
@@ -186,9 +186,9 @@
 ///
 Parser::ExprResult Parser::ParseExpressionWithLeadingAt(SourceLocation AtLoc) {
   OwningExprResult LHS(Actions, ParseObjCAtExpression(AtLoc));
-  if (LHS.isInvalid()) return LHS.move();
+  if (LHS.isInvalid()) return LHS.result();
 
-  return ParseRHSOfBinaryExpression(LHS.move(), prec::Comma);
+  return ParseRHSOfBinaryExpression(LHS.result(), prec::Comma);
 }
 
 /// ParseAssignmentExpression - Parse an expr that doesn't include commas.
@@ -198,9 +198,9 @@
     return ParseThrowExpression();
 
   OwningExprResult LHS(Actions, ParseCastExpression(false));
-  if (LHS.isInvalid()) return LHS.move();
+  if (LHS.isInvalid()) return LHS.result();
   
-  return ParseRHSOfBinaryExpression(LHS.move(), prec::Assignment);
+  return ParseRHSOfBinaryExpression(LHS.result(), prec::Assignment);
 }
 
 /// ParseAssignmentExprWithObjCMessageExprStart - Parse an assignment expression
@@ -219,18 +219,18 @@
   OwningExprResult R(Actions, ParseObjCMessageExpressionBody(LBracLoc, NameLoc,
                                                              ReceiverName,
                                                              ReceiverExpr));
-  if (R.isInvalid()) return R.move();
-  R = ParsePostfixExpressionSuffix(R.move());
-  if (R.isInvalid()) return R.move();
-  return ParseRHSOfBinaryExpression(R.move(), 2);
+  if (R.isInvalid()) return R.result();
+  R = ParsePostfixExpressionSuffix(R.result());
+  if (R.isInvalid()) return R.result();
+  return ParseRHSOfBinaryExpression(R.result(), 2);
 }
 
 
 Parser::ExprResult Parser::ParseConstantExpression() {
   OwningExprResult LHS(Actions, ParseCastExpression(false));
-  if (LHS.isInvalid()) return LHS.move();
+  if (LHS.isInvalid()) return LHS.result();
   
-  return ParseRHSOfBinaryExpression(LHS.move(), prec::Conditional);
+  return ParseRHSOfBinaryExpression(LHS.result(), prec::Conditional);
 }
 
 /// ParseRHSOfBinaryExpression - Parse a binary expression that starts with
@@ -246,7 +246,7 @@
     // because we are called recursively, or because the token is not a binop),
     // then we are done!
     if (NextTokPrec < MinPrec)
-      return LHS.move();
+      return LHS.result();
 
     // Consume the operator, saving the operator token for error reporting.
     Token OpToken = Tok;
@@ -262,7 +262,7 @@
         // 'logical-OR-expression' as we might expect.
         TernaryMiddle = ParseExpression();
         if (TernaryMiddle.isInvalid())
-          return TernaryMiddle.move();
+          return TernaryMiddle.result();
       } else {
         // Special case handling of "X ? Y : Z" where Y is empty:
         //   logical-OR-expression '?' ':' conditional-expression   [GNU]
@@ -283,7 +283,7 @@
     // Parse another leaf here for the RHS of the operator.
     OwningExprResult RHS(Actions, ParseCastExpression(false));
     if (RHS.isInvalid())
-      return RHS.move();
+      return RHS.result();
 
     // Remember the precedence of this operator and get the precedence of the
     // operator immediately to the right of the RHS.
@@ -303,9 +303,9 @@
       // is okay, to bind exactly as tightly.  For example, compile A=B=C=D as
       // A=(B=(C=D)), where each paren is a level of recursion here.
       // The function takes ownership of the RHS.
-      RHS = ParseRHSOfBinaryExpression(RHS.move(), ThisPrec + !isRightAssoc);
+      RHS = ParseRHSOfBinaryExpression(RHS.result(), ThisPrec + !isRightAssoc);
       if (RHS.isInvalid())
-        return RHS.move();
+        return RHS.result();
 
       NextTokPrec = getBinOpPrecedence(Tok.getKind());
     }
@@ -314,12 +314,13 @@
     if (!LHS.isInvalid()) {
       // Combine the LHS and RHS into the LHS (e.g. build AST).
       if (TernaryMiddle.isInvalid())
-        LHS = Actions.ActOnBinOp(CurScope, OpToken.getLocation(), 
-                                 OpToken.getKind(), LHS.move(), RHS.move());
+        LHS = Actions.ActOnBinOp(CurScope, OpToken.getLocation(),
+                                 OpToken.getKind(), LHS.release(),
+                                 RHS.release());
       else
         LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
-                                         LHS.move(), TernaryMiddle.move(),
-                                         RHS.move());
+                                         LHS.release(), TernaryMiddle.release(),
+                                         RHS.release());
     }
   }
 }
@@ -443,7 +444,7 @@
     SourceLocation LParenLoc = Tok.getLocation();
     SourceLocation RParenLoc;
     Res = ParseParenExpression(ParenExprType, CastTy, RParenLoc);
-    if (Res.isInvalid()) return Res.move();
+    if (Res.isInvalid()) return Res.result();
     
     switch (ParenExprType) {
     case SimpleExpr:   break;    // Nothing else to do.
@@ -458,12 +459,13 @@
       // TODO: For cast expression with CastTy.
       Res = ParseCastExpression(false);
       if (!Res.isInvalid())
-        Res = Actions.ActOnCastExpr(LParenLoc, CastTy, RParenLoc, Res.move());
-      return Res.move();
+        Res = Actions.ActOnCastExpr(LParenLoc, CastTy, RParenLoc,
+                                    Res.release());
+      return Res.result();
     }
 
     // These can be followed by postfix-expr pieces.
-    return ParsePostfixExpressionSuffix(Res.move());
+    return ParsePostfixExpressionSuffix(Res.result());
   }
 
     // primary-expression
@@ -475,7 +477,7 @@
     ConsumeToken();
     
     // These can be followed by postfix-expr pieces.
-    return ParsePostfixExpressionSuffix(Res.move());
+    return ParsePostfixExpressionSuffix(Res.result());
 
   case tok::kw_true:
   case tok::kw_false:
@@ -493,26 +495,26 @@
     SourceLocation L = ConsumeToken();
     Res = Actions.ActOnIdentifierExpr(CurScope, L, II, Tok.is(tok::l_paren));
     // These can be followed by postfix-expr pieces.
-    return ParsePostfixExpressionSuffix(Res.move());
+    return ParsePostfixExpressionSuffix(Res.result());
   }
   case tok::char_constant:     // constant: character-constant
     Res = Actions.ActOnCharacterConstant(Tok);
     ConsumeToken();
     // These can be followed by postfix-expr pieces.
-    return ParsePostfixExpressionSuffix(Res.move());
+    return ParsePostfixExpressionSuffix(Res.result());
   case tok::kw___func__:       // primary-expression: __func__ [C99 6.4.2.2]
   case tok::kw___FUNCTION__:   // primary-expression: __FUNCTION__ [GNU]
   case tok::kw___PRETTY_FUNCTION__:  // primary-expression: __P..Y_F..N__ [GNU]
     Res = Actions.ActOnPredefinedExpr(Tok.getLocation(), SavedKind);
     ConsumeToken();
     // These can be followed by postfix-expr pieces.
-    return ParsePostfixExpressionSuffix(Res.move());
+    return ParsePostfixExpressionSuffix(Res.result());
   case tok::string_literal:    // primary-expression: string-literal
   case tok::wide_string_literal:
     Res = ParseStringLiteralExpression();
-    if (Res.isInvalid()) return Res.move();
+    if (Res.isInvalid()) return Res.result();
     // This can be followed by postfix-expr pieces (e.g. "foo"[1]).
-    return ParsePostfixExpressionSuffix(Res.move());
+    return ParsePostfixExpressionSuffix(Res.result());
   case tok::kw___builtin_va_arg:
   case tok::kw___builtin_offsetof:
   case tok::kw___builtin_choose_expr:
@@ -527,8 +529,8 @@
     SourceLocation SavedLoc = ConsumeToken();
     Res = ParseCastExpression(true);
     if (!Res.isInvalid())
-      Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.move());
-    return Res.move();
+      Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.release());
+    return Res.result();
   }
   case tok::amp:           // unary-expression: '&' cast-expression
   case tok::star:          // unary-expression: '*' cast-expression
@@ -541,8 +543,8 @@
     SourceLocation SavedLoc = ConsumeToken();
     Res = ParseCastExpression(false);
     if (!Res.isInvalid())
-      Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.move());
-    return Res.move();
+      Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.release());
+    return Res.result();
   }
 
   case tok::kw___extension__:{//unary-expression:'__extension__' cast-expr [GNU]
@@ -551,8 +553,8 @@
     SourceLocation SavedLoc = ConsumeToken();
     Res = ParseCastExpression(false);
     if (!Res.isInvalid())
-      Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.move());
-    return Res.move();
+      Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.release());
+    return Res.result();
   }
   case tok::kw_sizeof:     // unary-expression: 'sizeof' unary-expression
                            // unary-expression: 'sizeof' '(' type-name ')'
@@ -567,12 +569,12 @@
       Diag(Tok, diag::err_expected_ident);
       return ExprResult(true);
     }
-    
+
     Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
     Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(),
                                  Tok.getIdentifierInfo());
     ConsumeToken();
-    return Res.move();
+    return Res.result();
   }
   case tok::kw_const_cast:
   case tok::kw_dynamic_cast:
@@ -580,15 +582,15 @@
   case tok::kw_static_cast:
     Res = ParseCXXCasts();
     // These can be followed by postfix-expr pieces.
-    return ParsePostfixExpressionSuffix(Res.move());
+    return ParsePostfixExpressionSuffix(Res.result());
   case tok::kw_typeid:
     Res = ParseCXXTypeid();
     // This can be followed by postfix-expr pieces.
-    return ParsePostfixExpressionSuffix(Res.move());
+    return ParsePostfixExpressionSuffix(Res.result());
   case tok::kw_this:
     Res = ParseCXXThis();
     // This can be followed by postfix-expr pieces.
-    return ParsePostfixExpressionSuffix(Res.move());
+    return ParsePostfixExpressionSuffix(Res.result());
 
   case tok::kw_char:
   case tok::kw_wchar_t:
@@ -616,14 +618,14 @@
 
     Res = ParseCXXTypeConstructExpression(DS);
     // This can be followed by postfix-expr pieces.
-    return ParsePostfixExpressionSuffix(Res.move());
+    return ParsePostfixExpressionSuffix(Res.result());
   }
 
   case tok::annot_cxxscope: // [C++] id-expression: qualified-id
   case tok::kw_operator: // [C++] id-expression: operator/conversion-function-id
                          //                      template-id
     Res = ParseCXXIdExpression();
-    return ParsePostfixExpressionSuffix(Res.move());
+    return ParsePostfixExpressionSuffix(Res.result());
 
   case tok::coloncolon: // [C++] new-expression or [C++] delete-expression
     // If the next token is neither 'new' nor 'delete', the :: would have been
@@ -689,7 +691,7 @@
   while (1) {
     switch (Tok.getKind()) {
     default:  // Not a postfix-expression suffix.
-      return LHS.move();
+      return LHS.result();
     case tok::l_square: {  // postfix-expression: p-e '[' expression ']'
       Loc = ConsumeBracket();
       OwningExprResult Idx(Actions, ParseExpression());
@@ -697,8 +699,8 @@
       SourceLocation RLoc = Tok.getLocation();
 
       if (!LHS.isInvalid() && !Idx.isInvalid() && Tok.is(tok::r_square)) {
-        LHS = Actions.ActOnArraySubscriptExpr(CurScope, LHS.move(), Loc,
-                                              Idx.move(), RLoc);
+        LHS = Actions.ActOnArraySubscriptExpr(CurScope, LHS.release(), Loc,
+                                              Idx.release(), RLoc);
       } else
         LHS = ExprResult(true);
 
@@ -724,7 +726,7 @@
       if (!LHS.isInvalid() && Tok.is(tok::r_paren)) {
         assert((ArgExprs.size() == 0 || ArgExprs.size()-1 == CommaLocs.size())&&
                "Unexpected number of commas!");
-        LHS = Actions.ActOnCallExpr(CurScope, LHS.move(), Loc, 
+        LHS = Actions.ActOnCallExpr(CurScope, LHS.release(), Loc,
                                     ArgExprs.take(),
                                     ArgExprs.size(), &CommaLocs[0],
                                     Tok.getLocation());
@@ -744,7 +746,7 @@
       }
       
       if (!LHS.isInvalid()) {
-        LHS = Actions.ActOnMemberReferenceExpr(LHS.move(), OpLoc, OpKind,
+        LHS = Actions.ActOnMemberReferenceExpr(LHS.release(), OpLoc, OpKind,
                                                Tok.getLocation(),
                                                *Tok.getIdentifierInfo());
       }
@@ -755,7 +757,7 @@
     case tok::minusminus:  // postfix-expression: postfix-expression '--'
       if (!LHS.isInvalid()) {
         LHS = Actions.ActOnPostfixUnaryOp(CurScope, Tok.getLocation(), 
-                                          Tok.getKind(), LHS.move());
+                                          Tok.getKind(), LHS.release());
       }
       ConsumeToken();
       break;
@@ -803,16 +805,16 @@
     // If this is a parenthesized expression, it is the start of a 
     // unary-expression, but doesn't include any postfix pieces.  Parse these
     // now if present.
-    Operand = ParsePostfixExpressionSuffix(Operand.move());
+    Operand = ParsePostfixExpressionSuffix(Operand.result());
   }
   
   // If we get here, the operand to the sizeof/alignof was an expresion.
   if (!Operand.isInvalid())
     Operand = Actions.ActOnSizeOfAlignOfExpr(OpTok.getLocation(),
                                              OpTok.is(tok::kw_sizeof),
-                                             /*isType=*/false, Operand.move(),
-                                             SourceRange());
-  return Operand.move();
+                                             /*isType=*/false,
+                                             Operand.release(), SourceRange());
+  return Operand.result();
 }
 
 /// ParseBuiltinPrimaryExpression
@@ -864,7 +866,7 @@
       Diag(Tok, diag::err_expected_rparen);
       return ExprResult(true);
     }
-    Res = Actions.ActOnVAArg(StartLoc, Expr.move(), Ty, ConsumeParen());
+    Res = Actions.ActOnVAArg(StartLoc, Expr.release(), Ty, ConsumeParen());
     break;
   }
   case tok::kw___builtin_offsetof: {
@@ -913,9 +915,9 @@
         Res = ParseExpression();
         if (Res.isInvalid()) {
           SkipUntil(tok::r_paren);
-          return Res.move();
+          return Res.result();
         }
-        Comps.back().U.E = Res.move();
+        Comps.back().U.E = Res.release();
 
         Comps.back().LocEnd =
           MatchRHSPunctuation(tok::r_square, Comps.back().LocStart);
@@ -934,7 +936,7 @@
     OwningExprResult Cond(Actions, ParseAssignmentExpression());
     if (Cond.isInvalid()) {
       SkipUntil(tok::r_paren);
-      return Cond.move();
+      return Cond.result();
     }
     if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "",tok::r_paren))
       return ExprResult(true);
@@ -942,7 +944,7 @@
     OwningExprResult Expr1(Actions, ParseAssignmentExpression());
     if (Expr1.isInvalid()) {
       SkipUntil(tok::r_paren);
-      return Expr1.move();
+      return Expr1.result();
     }
     if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "",tok::r_paren))
       return ExprResult(true);
@@ -950,14 +952,14 @@
     OwningExprResult Expr2(Actions, ParseAssignmentExpression());
     if (Expr2.isInvalid()) {
       SkipUntil(tok::r_paren);
-      return Expr2.move();
+      return Expr2.result();
     }
     if (Tok.isNot(tok::r_paren)) {
       Diag(Tok, diag::err_expected_rparen);
       return ExprResult(true);
     }
-    Res = Actions.ActOnChooseExpr(StartLoc, Cond.move(), Expr1.move(),
-                                  Expr2.move(), ConsumeParen());
+    Res = Actions.ActOnChooseExpr(StartLoc, Cond.release(), Expr1.release(),
+                                  Expr2.release(), ConsumeParen());
     break;
   }
   case tok::kw___builtin_overload: {
@@ -973,7 +975,7 @@
           SkipUntil(tok::r_paren);
           return ExprResult(true);
         } else
-          ArgExprs.push_back(ArgExpr.move());
+          ArgExprs.push_back(ArgExpr.release());
 
         if (Tok.isNot(tok::comma))
           break;
@@ -1010,7 +1012,7 @@
   
   // These can be followed by postfix-expr pieces because they are
   // primary-expressions.
-  return ParsePostfixExpressionSuffix(Res.move());
+  return ParsePostfixExpressionSuffix(Res.result());
 }
 
 /// ParseParenExpression - This parses the unit that starts with a '(' token,
@@ -1042,7 +1044,7 @@
     // If the substmt parsed correctly, build the AST node.
     if (!Stmt.isInvalid() && Tok.is(tok::r_paren))
       Result = Actions.ActOnStmtExpr(
-        OpenLoc, Stmt.move(), Tok.getLocation());
+        OpenLoc, Stmt.release(), Tok.getLocation());
 
   } else if (ExprType >= CompoundLiteral && isTypeIdInParens()) {
     // Otherwise, this is a compound literal expression or cast expression.
@@ -1061,7 +1063,7 @@
       ExprType = CompoundLiteral;
       if (!Result.isInvalid())
         return Actions.ActOnCompoundLiteral(OpenLoc, Ty, RParenLoc,
-                                            Result.move());
+                                            Result.release());
     } else if (ExprType == CastExpr) {
       // Note that this doesn't parse the subsequence cast-expression, it just
       // returns the parsed type to the callee.
@@ -1072,13 +1074,13 @@
       Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
       return ExprResult(true);
     }
-    return Result.move();
+    return Result.result();
   } else {
     Result = ParseExpression();
     ExprType = SimpleExpr;
     if (!Result.isInvalid() && Tok.is(tok::r_paren))
       Result = Actions.ActOnParenExpr(
-        OpenLoc, Tok.getLocation(), Result.move());
+        OpenLoc, Tok.getLocation(), Result.release());
   }
   
   // Match the ')'.
@@ -1091,7 +1093,7 @@
       MatchRHSPunctuation(tok::r_paren, OpenLoc);
   }
   
-  return Result.move();
+  return Result.result();
 }
 
 /// ParseStringLiteralExpression - This handles the various token types that
@@ -1132,7 +1134,7 @@
     if (Expr.isInvalid())
       return true;
 
-    Exprs.push_back(Expr.move());
+    Exprs.push_back(Expr.release());
 
     if (Tok.isNot(tok::comma))
       return false;
@@ -1193,12 +1195,12 @@
   if (Tok.is(tok::l_brace)) {
     OwningStmtResult Stmt(Actions, ParseCompoundStatementBody());
     if (!Stmt.isInvalid()) {
-      Result = Actions.ActOnBlockStmtExpr(CaretLoc, Stmt.move(), CurScope);
+      Result = Actions.ActOnBlockStmtExpr(CaretLoc, Stmt.release(), CurScope);
     } else {
       Actions.ActOnBlockError(CaretLoc, CurScope);
     }
   }
   ExitScope();
-  return Result.move();
+  return Result.result();
 }
 

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=60809&r1=60808&r2=60809&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Tue Dec  9 18:02:53 2008
@@ -226,9 +226,9 @@
   if (!Result.isInvalid())
     Result = Actions.ActOnCXXNamedCast(OpLoc, Kind,
                                        LAngleBracketLoc, CastTy, RAngleBracketLoc,
-                                       LParenLoc, Result.move(), RParenLoc);
+                                       LParenLoc, Result.release(), RParenLoc);
 
-  return Result.move();
+  return Result.result();
 }
 
 /// ParseCXXTypeid - This handles the C++ typeid expression.
@@ -272,11 +272,11 @@
       MatchRHSPunctuation(tok::r_paren, LParenLoc);
 
       Result = Actions.ActOnCXXTypeid(OpLoc, LParenLoc, /*isType=*/false,
-                                      Result.move(), RParenLoc);
+                                      Result.release(), RParenLoc);
     }
   }
 
-  return Result.move();
+  return Result.result();
 }
 
 /// ParseCXXBoolLiteral - This handles the C++ Boolean literals.
@@ -311,8 +311,8 @@
 
   default:
     OwningExprResult Expr(Actions, ParseAssignmentExpression());
-    if (Expr.isInvalid()) return Expr.move();
-    return Actions.ActOnCXXThrow(ThrowLoc, Expr.move());
+    if (Expr.isInvalid()) return Expr.result();
+    return Actions.ActOnCXXThrow(ThrowLoc, Expr.release());
   }
 }
 
@@ -388,12 +388,12 @@
 
   // simple-asm-expr[opt]
   if (Tok.is(tok::kw_asm)) {
-    OwningExprResult AsmLabel(Actions, ParseSimpleAsm());
+    OwningExprResult AsmLabel(ParseSimpleAsm());
     if (AsmLabel.isInvalid()) {
       SkipUntil(tok::semi);
       return true;
     }
-    DeclaratorInfo.setAsmLabel(AsmLabel.move());
+    DeclaratorInfo.setAsmLabel(AsmLabel.release());
   }
 
   // If attributes are present, parse them.
@@ -409,8 +409,8 @@
     return true;
   
   return Actions.ActOnCXXConditionDeclarationExpr(CurScope, StartLoc,
-                                                  DeclaratorInfo,
-                                                  EqualLoc, AssignExpr.move());
+                                                  DeclaratorInfo, EqualLoc,
+                                                  AssignExpr.release());
 }
 
 /// ParseCXXSimpleTypeSpecifier - [C++ 7.1.5.2] Simple type specifiers.
@@ -786,7 +786,7 @@
     first = false;
 
     D.AddTypeInfo(DeclaratorChunk::getArray(0, /*static=*/false, /*star=*/false,
-                                            Size.move(), LLoc));
+                                            Size.release(), LLoc));
 
     if (MatchRHSPunctuation(tok::r_square, LLoc).isInvalid())
       return;
@@ -853,7 +853,8 @@
 
   OwningExprResult Operand(Actions, ParseCastExpression(false));
   if (Operand.isInvalid())
-    return Operand.move();
+    return Operand.result();
 
-  return Actions.ActOnCXXDelete(Start, UseGlobal, ArrayDelete, Operand.move());
+  return Actions.ActOnCXXDelete(Start, UseGlobal, ArrayDelete,
+                                Operand.release());
 }

Modified: cfe/trunk/lib/Parse/ParseInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseInit.cpp?rev=60809&r1=60808&r2=60809&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseInit.cpp (original)
+++ cfe/trunk/lib/Parse/ParseInit.cpp Tue Dec  9 18:02:53 2008
@@ -146,7 +146,7 @@
     OwningExprResult Idx(Actions, ParseAssignmentExpression());
     if (Idx.isInvalid()) {
       SkipUntil(tok::r_square);
-      return Idx.move();
+      return Idx.result();
     }
     
     // Given an expression, we could either have a designator (if the next
@@ -170,7 +170,7 @@
       
       return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
                                                          SourceLocation(), 
-                                                         0, Idx.move());
+                                                         0, Idx.release());
     }
 
     // Create designation if we haven't already.
@@ -179,7 +179,7 @@
     
     // If this is a normal array designator, remember it.
     if (Tok.isNot(tok::ellipsis)) {
-      Desig->AddDesignator(Designator::getArray(Idx.move()));
+      Desig->AddDesignator(Designator::getArray(Idx.release()));
     } else {
       // Handle the gnu array range extension.
       Diag(Tok, diag::ext_gnu_array_range);
@@ -188,9 +188,10 @@
       OwningExprResult RHS(Actions, ParseConstantExpression());
       if (RHS.isInvalid()) {
         SkipUntil(tok::r_square);
-        return RHS.move();
+        return RHS.result();
       }
-      Desig->AddDesignator(Designator::getArrayRange(Idx.move(), RHS.move()));
+      Desig->AddDesignator(Designator::getArrayRange(Idx.release(),
+                                                     RHS.release()));
     }
 
     MatchRHSPunctuation(tok::r_square, StartLoc);
@@ -280,7 +281,7 @@
     
     // If we couldn't parse the subelement, bail out.
     if (!SubElt.isInvalid()) {
-      InitExprs.push_back(SubElt.move());
+      InitExprs.push_back(SubElt.release());
     } else {
       InitExprsOk = false;
       

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=60809&r1=60808&r2=60809&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Dec  9 18:02:53 2008
@@ -1185,7 +1185,7 @@
     }
   }
   ConsumeToken(); // consume ';'
-  return Actions.ActOnObjCAtThrowStmt(atLoc, Res.move());
+  return Actions.ActOnObjCAtThrowStmt(atLoc, Res.release());
 }
 
 /// objc-synchronized-statement:
@@ -1221,8 +1221,8 @@
   ExitScope();
   if (SynchBody.isInvalid())
     SynchBody = Actions.ActOnNullStmt(Tok.getLocation());
-  return Actions.ActOnObjCAtSynchronizedStmt(atLoc, Res.move(),
-                                             SynchBody.move());
+  return Actions.ActOnObjCAtSynchronizedStmt(atLoc, Res.release(),
+                                             SynchBody.release());
 }
 
 ///  objc-try-catch-statement:
@@ -1295,7 +1295,8 @@
         if (CatchBody.isInvalid())
           CatchBody = Actions.ActOnNullStmt(Tok.getLocation());
         CatchStmts = Actions.ActOnObjCAtCatchStmt(AtCatchFinallyLoc,
-          RParenLoc, FirstPart.move(), CatchBody.move(), CatchStmts.move());
+          RParenLoc, FirstPart.release(), CatchBody.release(),
+          CatchStmts.release());
         ExitScope();
       } else {
         Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after)
@@ -1317,7 +1318,7 @@
       if (FinallyBody.isInvalid())
         FinallyBody = Actions.ActOnNullStmt(Tok.getLocation());
       FinallyStmt = Actions.ActOnObjCAtFinallyStmt(AtCatchFinallyLoc,
-                                                       FinallyBody.move());
+                                                   FinallyBody.release());
       catch_or_finally_seen = true;
       ExitScope();
       break;
@@ -1327,8 +1328,9 @@
     Diag(atLoc, diag::err_missing_catch_finally);
     return true;
   }
-  return Actions.ActOnObjCAtTryStmt(atLoc, TryBody.move(), CatchStmts.move(), 
-                                    FinallyStmt.move());
+  return Actions.ActOnObjCAtTryStmt(atLoc, TryBody.release(),
+                                    CatchStmts.release(),
+                                    FinallyStmt.release());
 }
 
 ///   objc-method-def: objc-method-proto ';'[opt] '{' body '}'
@@ -1369,7 +1371,7 @@
   ExitScope();
   
   // TODO: Pass argument information.
-  Actions.ActOnFinishFunctionBody(MDecl, FnBody.move());
+  Actions.ActOnFinishFunctionBody(MDecl, FnBody.release());
   return MDecl;
 }
 
@@ -1390,7 +1392,7 @@
   }
   // Otherwise, eat the semicolon.
   ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
-  return Actions.ActOnExprStmt(Res.move());
+  return Actions.ActOnExprStmt(Res.release());
 }
 
 Parser::ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) {
@@ -1436,11 +1438,11 @@
   OwningExprResult Res(Actions, ParseExpression());
   if (Res.isInvalid()) {
     SkipUntil(tok::r_square);
-    return Res.move();
+    return Res.result();
   }
   
   return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(),
-                                        0, Res.move());
+                                        0, Res.release());
 }
   
 /// ParseObjCMessageExpressionBody - Having parsed "'[' objc-receiver", parse
@@ -1498,11 +1500,11 @@
         // stop at the ']' when it skips to the ';'.  We want it to skip beyond
         // the enclosing expression.
         SkipUntil(tok::r_square);
-        return Res.move();
+        return Res.result();
       }
       
       // We have a valid expression.
-      KeyExprs.push_back(Res.move());
+      KeyExprs.push_back(Res.release());
       
       // Check for another keyword selector.
       selIdent = ParseObjCSelector(Loc);
@@ -1520,11 +1522,11 @@
         // stop at the ']' when it skips to the ';'.  We want it to skip beyond
         // the enclosing expression.
         SkipUntil(tok::r_square);
-        return Res.move();
+        return Res.result();
       }
 
       // We have a valid expression.
-      KeyExprs.push_back(Res.move());
+      KeyExprs.push_back(Res.release());
     }
   } else if (!selIdent) {
     Diag(Tok, diag::err_expected_ident); // missing selector name.
@@ -1564,7 +1566,7 @@
 
 Parser::ExprResult Parser::ParseObjCStringLiteral(SourceLocation AtLoc) {
   OwningExprResult Res(Actions, ParseStringLiteralExpression());
-  if (Res.isInvalid()) return Res.move();
+  if (Res.isInvalid()) return Res.result();
   
   // @"foo" @"bar" is a valid concatenated string.  Eat any subsequent string
   // expressions.  At this point, we know that the only valid thing that starts
@@ -1572,7 +1574,7 @@
   llvm::SmallVector<SourceLocation, 4> AtLocs;
   ExprVector AtStrings(Actions);
   AtLocs.push_back(AtLoc);
-  AtStrings.push_back(Res.move());
+  AtStrings.push_back(Res.release());
 
   while (Tok.is(tok::at)) {
     AtLocs.push_back(ConsumeToken()); // eat the @.
@@ -1585,9 +1587,9 @@
       Diag(Tok, diag::err_objc_concat_string);
 
     if (Lit.isInvalid())
-      return Lit.move();
+      return Lit.result();
 
-    AtStrings.push_back(Lit.move());
+    AtStrings.push_back(Lit.release());
   }
   
   return Actions.ParseObjCStringLiteral(&AtLocs[0], AtStrings.take(),

Modified: cfe/trunk/lib/Parse/ParsePragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=60809&r1=60808&r2=60809&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParsePragma.cpp (original)
+++ cfe/trunk/lib/Parse/ParsePragma.cpp Tue Dec  9 18:02:53 2008
@@ -100,7 +100,7 @@
   }
 
   SourceLocation RParenLoc = Tok.getLocation();
-  Actions.ActOnPragmaPack(Kind, Name, Alignment.move(), PackLoc,
+  Actions.ActOnPragmaPack(Kind, Name, Alignment.release(), PackLoc,
                           LParenLoc, RParenLoc);
 }
 

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=60809&r1=60808&r2=60809&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Tue Dec  9 18:02:53 2008
@@ -116,7 +116,7 @@
       }
       // Otherwise, eat the semicolon.
       ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
-      return Actions.ActOnExprStmt(Expr.move());
+      return Actions.ActOnExprStmt(Expr.release());
     }
     
   case tok::kw_case:                // C99 6.8.1: labeled-statement
@@ -163,7 +163,7 @@
   case tok::kw_asm:
     bool msAsm = false;
     Res = ParseAsmStatement(msAsm);
-    if (msAsm) return Res.move();
+    if (msAsm) return Res.result();
     SemiError = "asm statement";
     break;
   }
@@ -176,7 +176,7 @@
     // Skip until we see a } or ;, but don't eat it.
     SkipUntil(tok::r_brace, true, true);
   }
-  return Res.move();
+  return Res.result();
 }
 
 /// ParseLabeledStatement - We have an identifier and a ':' after it.
@@ -211,7 +211,7 @@
 
   return Actions.ActOnLabelStmt(IdentTok.getLocation(), 
                                 IdentTok.getIdentifierInfo(),
-                                ColonLoc, SubStmt.move());
+                                ColonLoc, SubStmt.release());
 }
 
 /// ParseCaseStatement
@@ -265,8 +265,8 @@
   if (SubStmt.isInvalid())
     SubStmt = Actions.ActOnNullStmt(ColonLoc);
   
-  return Actions.ActOnCaseStmt(CaseLoc, LHS.move(), DotDotDotLoc,
-                               RHS.move(), ColonLoc, SubStmt.move());
+  return Actions.ActOnCaseStmt(CaseLoc, LHS.release(), DotDotDotLoc,
+                               RHS.release(), ColonLoc, SubStmt.release());
 }
 
 /// ParseDefaultStatement
@@ -297,7 +297,7 @@
     return true;
   
   return Actions.ActOnDefaultStmt(DefaultLoc, ColonLoc,
-                                  SubStmt.move(), CurScope);
+                                  SubStmt.release(), CurScope);
 }
 
 
@@ -339,7 +339,7 @@
   OwningStmtResult Body(Actions, ParseCompoundStatementBody(isStmtExpr));
 
   ExitScope();
-  return Body.move();
+  return Body.result();
 }
 
 
@@ -389,19 +389,19 @@
         
         // Add the __extension__ node to the AST.
         Res = Actions.ActOnUnaryOp(CurScope, ExtLoc, tok::kw___extension__, 
-                                   Res.move());
+                                   Res.release());
         if (Res.isInvalid())
           continue;
         
         // Eat the semicolon at the end of stmt and convert the expr into a
         // statement.
         ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
-        R = Actions.ActOnExprStmt(Res.move());
+        R = Actions.ActOnExprStmt(Res.release());
       }
     }
     
     if (R.isUsable())
-      Stmts.push_back(R.move());
+      Stmts.push_back(R.release());
   }
   
   // We broke out of the while loop because we found a '}' or EOF.
@@ -540,8 +540,8 @@
   if (ElseStmt.isInvalid())
     ElseStmt = Actions.ActOnNullStmt(ElseStmtLoc);
 
-  return Actions.ActOnIfStmt(IfLoc, CondExp.move(), ThenStmt.move(),
-                             ElseLoc, ElseStmt.move());
+  return Actions.ActOnIfStmt(IfLoc, CondExp.release(), ThenStmt.release(),
+                             ElseLoc, ElseStmt.release());
 }
 
 /// ParseSwitchStatement
@@ -592,7 +592,8 @@
     return true;
   }
 
-  OwningStmtResult Switch(Actions, Actions.ActOnStartOfSwitchStmt(Cond.move()));
+  OwningStmtResult Switch(Actions,
+                          Actions.ActOnStartOfSwitchStmt(Cond.release()));
 
   // C99 6.8.4p3 - In C99, the body of the switch statement is a scope, even if
   // there is no compound stmt.  C90 does not have this clause.  We only do this
@@ -621,7 +622,8 @@
   
   ExitScope();
   
-  return Actions.ActOnFinishSwitchStmt(SwitchLoc, Switch.move(), Body.move());
+  return Actions.ActOnFinishSwitchStmt(SwitchLoc, Switch.release(),
+                                       Body.release());
 }
 
 /// ParseWhileStatement
@@ -693,7 +695,7 @@
   
   if (Cond.isInvalid() || Body.isInvalid()) return true;
   
-  return Actions.ActOnWhileStmt(WhileLoc, Cond.move(), Body.move());
+  return Actions.ActOnWhileStmt(WhileLoc, Cond.release(), Body.release());
 }
 
 /// ParseDoStatement
@@ -754,7 +756,7 @@
 
   if (Cond.isInvalid() || Body.isInvalid()) return true;
 
-  return Actions.ActOnDoStmt(DoLoc, Body.move(), WhileLoc, Cond.move());
+  return Actions.ActOnDoStmt(DoLoc, Body.release(), WhileLoc, Cond.release());
 }
 
 /// ParseForStatement
@@ -833,8 +835,8 @@
 
     // Turn the expression into a stmt.
     if (!Value.isInvalid())
-      FirstPart = Actions.ActOnExprStmt(Value.move());
-      
+      FirstPart = Actions.ActOnExprStmt(Value.release());
+
     if (Tok.is(tok::semi)) {
       ConsumeToken();
     }
@@ -871,7 +873,7 @@
       Value = ParseExpression();
       if (!Value.isInvalid()) {
         // Turn the expression into a stmt.
-        ThirdPart = Actions.ActOnExprStmt(Value.move());
+        ThirdPart = Actions.ActOnExprStmt(Value.release());
       }
     }
   }
@@ -903,16 +905,16 @@
 
   if (Body.isInvalid())
     return true;
-  
-  if (!ForEach) 
-    return Actions.ActOnForStmt(ForLoc, LParenLoc, FirstPart.move(),
-                                SecondPart.move(), ThirdPart.move(), RParenLoc,
-                                Body.move());
+
+  if (!ForEach)
+    return Actions.ActOnForStmt(ForLoc, LParenLoc, FirstPart.release(),
+                                SecondPart.release(), ThirdPart.release(),
+                                RParenLoc, Body.release());
   else
     return Actions.ActOnObjCForCollectionStmt(ForLoc, LParenLoc,
-                                              FirstPart.move(),
-                                              SecondPart.move(),
-                                              RParenLoc, Body.move());
+                                              FirstPart.release(),
+                                              SecondPart.release(),
+                                              RParenLoc, Body.release());
 }
 
 /// ParseGotoStatement
@@ -940,13 +942,13 @@
       SkipUntil(tok::semi, false, true);
       return true;
     }
-    Res = Actions.ActOnIndirectGotoStmt(GotoLoc, StarLoc, R.move());
+    Res = Actions.ActOnIndirectGotoStmt(GotoLoc, StarLoc, R.release());
   } else {
     Diag(Tok, diag::err_expected_ident);
     return true;
   }
 
-  return Res.move();
+  return Res.result();
 }
 
 /// ParseContinueStatement
@@ -986,7 +988,7 @@
       return true;
     }
   }
-  return Actions.ActOnReturnStmt(ReturnLoc, R.move());
+  return Actions.ActOnReturnStmt(ReturnLoc, R.release());
 }
 
 /// FuzzyParseMicrosoftAsmStatement. When -fms-extensions is enabled, this
@@ -1068,7 +1070,7 @@
   }
   Loc = ConsumeParen();
   
-  OwningExprResult AsmString(Actions, ParseAsmStringLiteral());
+  OwningExprResult AsmString(ParseAsmStringLiteral());
   if (AsmString.isInvalid())
     return true;
 
@@ -1095,38 +1097,38 @@
     // Parse Inputs, if present.
     if (ParseAsmOperandsOpt(Names, Constraints, Exprs))
         return true;
-      
+
     assert(Names.size() == Constraints.size() &&
            Constraints.size() == Exprs.size() 
            && "Input operand size mismatch!");
 
     NumInputs = Names.size() - NumOutputs;
-  
+
     // Parse the clobbers, if present.
     if (Tok.is(tok::colon)) {
       ConsumeToken();
-    
+
       // Parse the asm-string list for clobbers.
       while (1) {
-        OwningExprResult Clobber(Actions, ParseAsmStringLiteral());
+        OwningExprResult Clobber(ParseAsmStringLiteral());
 
         if (Clobber.isInvalid())
           break;
-      
-        Clobbers.push_back(Clobber.move());
-      
+
+        Clobbers.push_back(Clobber.release());
+
         if (Tok.isNot(tok::comma)) break;
         ConsumeToken();
       }
     }
-  
+
     RParenLoc = MatchRHSPunctuation(tok::r_paren, Loc);
   }
-  
+
   return Actions.ActOnAsmStmt(AsmLoc, isSimple, isVolatile,
                               NumOutputs, NumInputs,
                               &Names[0], Constraints.take(),
-                              Exprs.take(), AsmString.move(),
+                              Exprs.take(), AsmString.release(),
                               Clobbers.size(), Clobbers.take(),
                               RParenLoc);
 }
@@ -1173,26 +1175,26 @@
     } else
       Names.push_back(std::string());
 
-    OwningExprResult Constraint(Actions, ParseAsmStringLiteral());
+    OwningExprResult Constraint(ParseAsmStringLiteral());
     if (Constraint.isInvalid()) {
         SkipUntil(tok::r_paren);
         return true;
     }
-    Constraints.push_back(Constraint.move());
+    Constraints.push_back(Constraint.release());
 
     if (Tok.isNot(tok::l_paren)) {
       Diag(Tok, diag::err_expected_lparen_after) << "asm operand";
       SkipUntil(tok::r_paren);
       return true;
     }
-    
+
     // Read the parenthesized expression.
     OwningExprResult Res(Actions, ParseSimpleParenExpression());
     if (Res.isInvalid()) {
       SkipUntil(tok::r_paren);
       return true;
     }
-    Exprs.push_back(Res.move());
+    Exprs.push_back(Res.release());
     // Eat the comma and continue parsing if it exists.
     if (Tok.isNot(tok::comma)) return false;
     ConsumeToken();
@@ -1215,5 +1217,5 @@
   // Leave the function body scope.
   ExitScope();
   
-  return Actions.ActOnFinishFunctionBody(Decl, FnBody.move());
+  return Actions.ActOnFinishFunctionBody(Decl, FnBody.release());
 }

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=60809&r1=60808&r2=60809&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Tue Dec  9 18:02:53 2008
@@ -336,13 +336,13 @@
     return ParseExternalDeclaration();
   }
   case tok::kw_asm: {
-    OwningExprResult Result(Actions, ParseSimpleAsm());
+    OwningExprResult Result(ParseSimpleAsm());
 
     ExpectAndConsume(tok::semi, diag::err_expected_semi_after,
                      "top-level asm block");
 
     if (!Result.isInvalid())
-      return Actions.ActOnFileScopeAsmDecl(Tok.getLocation(), Result.move());
+      return Actions.ActOnFileScopeAsmDecl(Tok.getLocation(), Result.release());
     return 0;
   }
   case tok::at:
@@ -666,18 +666,18 @@
 /// [GNU] asm-string-literal:
 ///         string-literal
 ///
-Parser::ExprResult Parser::ParseAsmStringLiteral() {
+Parser::OwningExprResult Parser::ParseAsmStringLiteral() {
   if (!isTokenStringLiteral()) {
     Diag(Tok, diag::err_expected_string_literal);
-    return true;
+    return OwningExprResult(true);
   }
 
   OwningExprResult Res(Actions, ParseStringLiteralExpression());
-  if (Res.isInvalid()) return true;
+  if (Res.isInvalid()) return move(Res);
 
   // TODO: Diagnose: wide string literal in 'asm'
 
-  return Res.move();
+  return move(Res);
 }
 
 /// ParseSimpleAsm
@@ -685,25 +685,25 @@
 /// [GNU] simple-asm-expr:
 ///         'asm' '(' asm-string-literal ')'
 ///
-Parser::ExprResult Parser::ParseSimpleAsm() {
+Parser::OwningExprResult Parser::ParseSimpleAsm() {
   assert(Tok.is(tok::kw_asm) && "Not an asm!");
   SourceLocation Loc = ConsumeToken();
 
   if (Tok.isNot(tok::l_paren)) {
     Diag(Tok, diag::err_expected_lparen_after) << "asm";
-    return true;
+    return OwningExprResult(true);
   }
 
   ConsumeParen();
 
-  OwningExprResult Result(Actions, ParseAsmStringLiteral());
+  OwningExprResult Result(ParseAsmStringLiteral());
 
   if (Result.isInvalid())
     SkipUntil(tok::r_paren);
   else
     MatchRHSPunctuation(tok::r_paren, Loc);
 
-  return Result.move();
+  return move(Result);
 }
 
 /// TryAnnotateTypeOrScopeToken - If the current token position is on a





More information about the cfe-commits mailing list