[cfe-commits] r60906 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Parse/ParseDecl.cpp lib/Parse/ParseExpr.cpp lib/Parse/ParseExprCXX.cpp lib/Parse/ParseInit.cpp lib/Parse/ParseObjc.cpp lib/Parse/Parser.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Thu Dec 11 14:52:03 PST 2008


Author: cornedbee
Date: Thu Dec 11 16:51:44 2008
New Revision: 60906

URL: http://llvm.org/viewvc/llvm-project?rev=60906&view=rev
Log:
Convert a big bunch of expression parsers to use smart pointers.

Modified:
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/lib/Parse/ParseDecl.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/Parser.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Dec 11 16:51:44 2008
@@ -522,11 +522,11 @@
     TypeTy *CastTy;
     return ParseParenExpression(Op, CastTy, RParenLoc);
   }
-  ExprResult ParseStringLiteralExpression();
+  OwningExprResult ParseStringLiteralExpression();
 
   //===--------------------------------------------------------------------===//
   // C++ Expressions
-  ExprResult ParseCXXIdExpression();
+  OwningExprResult ParseCXXIdExpression();
 
   /// MaybeParseCXXScopeSpecifier - Parse global scope or nested-name-specifier.
   /// Returns true if a nested-name-specifier was parsed from the token stream.
@@ -534,28 +534,28 @@
   
   //===--------------------------------------------------------------------===//
   // C++ 5.2p1: C++ Casts
-  ExprResult ParseCXXCasts();
+  OwningExprResult ParseCXXCasts();
 
   //===--------------------------------------------------------------------===//
   // C++ 5.2p1: C++ Type Identification
-  ExprResult ParseCXXTypeid();
+  OwningExprResult ParseCXXTypeid();
 
   //===--------------------------------------------------------------------===//
   // C++ 9.3.2: C++ 'this' pointer
-  ExprResult ParseCXXThis();
+  OwningExprResult ParseCXXThis();
 
   //===--------------------------------------------------------------------===//
   // C++ 15: C++ Throw Expression
-  ExprResult ParseThrowExpression();
+  OwningExprResult ParseThrowExpression();
   bool ParseExceptionSpecification();
 
   //===--------------------------------------------------------------------===//
   // C++ 2.13.5: C++ Boolean Literals
-  ExprResult ParseCXXBoolLiteral();
+  OwningExprResult ParseCXXBoolLiteral();
 
   //===--------------------------------------------------------------------===//
   // C++ 5.2.3: Explicit type conversion (functional notation)
-  ExprResult ParseCXXTypeConstructExpression(const DeclSpec &DS);
+  OwningExprResult ParseCXXTypeConstructExpression(const DeclSpec &DS);
 
   /// ParseCXXSimpleTypeSpecifier - [C++ 7.1.5.2] Simple type specifiers.
   /// This should only be called when the current token is known to be part of
@@ -566,10 +566,10 @@
 
   //===--------------------------------------------------------------------===//
   // C++ 5.3.4 and 5.3.5: C++ new and delete
-  ExprResult ParseCXXNewExpression();
+  OwningExprResult ParseCXXNewExpression();
   bool ParseExpressionListOrTypeId(ExprListTy &Exprs, Declarator &D);
   void ParseDirectNewDeclarator(Declarator &D);
-  ExprResult ParseCXXDeleteExpression();
+  OwningExprResult ParseCXXDeleteExpression();
 
   //===--------------------------------------------------------------------===//
   // C++ if/switch/while/for condition expression.
@@ -585,14 +585,14 @@
   ///       initializer: [C99 6.7.8]
   ///         assignment-expression
   ///         '{' ...
-  ExprResult ParseInitializer() {
+  OwningExprResult ParseInitializer() {
     if (Tok.isNot(tok::l_brace))
-      return ParseAssignmentExpression().result();
+      return ParseAssignmentExpression();
     return ParseBraceInitializer();
   }
-  ExprResult ParseBraceInitializer();
-  ExprResult ParseInitializerWithPotentialDesignator(InitListDesignations &D,
-                                                     unsigned InitNum);
+  OwningExprResult ParseBraceInitializer();
+  OwningExprResult ParseInitializerWithPotentialDesignator(
+                       InitListDesignations &D, unsigned InitNum);
   
   //===--------------------------------------------------------------------===//
   // clang Expressions

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Dec 11 16:51:44 2008
@@ -289,7 +289,7 @@
     // Parse declarator '=' initializer.
     if (Tok.is(tok::equal)) {
       ConsumeToken();
-      OwningExprResult Init(Actions, ParseInitializer());
+      OwningExprResult Init(ParseInitializer());
       if (Init.isInvalid()) {
         SkipUntil(tok::semi);
         return 0;

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Dec 11 16:51:44 2008
@@ -171,7 +171,7 @@
 ///
 Parser::OwningExprResult Parser::ParseExpression() {
   if (Tok.is(tok::kw_throw))
-    return Owned(ParseThrowExpression());
+    return ParseThrowExpression();
 
   OwningExprResult LHS(ParseCastExpression(false));
   if (LHS.isInvalid()) return move(LHS);
@@ -196,7 +196,7 @@
 ///
 Parser::OwningExprResult Parser::ParseAssignmentExpression() {
   if (Tok.is(tok::kw_throw))
-    return Owned(ParseThrowExpression());
+    return ParseThrowExpression();
 
   OwningExprResult LHS(ParseCastExpression(false));
   if (LHS.isInvalid()) return move(LHS);
@@ -481,7 +481,7 @@
 
   case tok::kw_true:
   case tok::kw_false:
-    return Owned(ParseCXXBoolLiteral());
+    return ParseCXXBoolLiteral();
 
   case tok::identifier: {      // primary-expression: identifier
                                // unqualified-id: identifier
@@ -630,15 +630,15 @@
     // If the next token is neither 'new' nor 'delete', the :: would have been
     // parsed as a scope specifier already.
     if (NextToken().is(tok::kw_new))
-      return Owned(ParseCXXNewExpression());
+      return ParseCXXNewExpression();
     else
-      return Owned(ParseCXXDeleteExpression());
+      return ParseCXXDeleteExpression();
 
   case tok::kw_new: // [C++] new-expression
-    return Owned(ParseCXXNewExpression());
+    return ParseCXXNewExpression();
 
   case tok::kw_delete: // [C++] delete-expression
-    return Owned(ParseCXXDeleteExpression());
+    return ParseCXXDeleteExpression();
 
   case tok::at: {
     SourceLocation AtLoc = ConsumeToken();
@@ -1100,20 +1100,20 @@
 ///
 ///       primary-expression: [C99 6.5.1]
 ///         string-literal
-Parser::ExprResult Parser::ParseStringLiteralExpression() {
+Parser::OwningExprResult Parser::ParseStringLiteralExpression() {
   assert(isTokenStringLiteral() && "Not a string literal!");
-  
+
   // String concat.  Note that keywords like __func__ and __FUNCTION__ are not
   // considered to be strings for concatenation purposes.
   llvm::SmallVector<Token, 4> StringToks;
-  
+
   do {
     StringToks.push_back(Tok);
     ConsumeStringToken();
   } while (isTokenStringLiteral());
 
   // Pass the set of string tokens, ready for concatenation, to the actions.
-  return Actions.ActOnStringLiteral(&StringToks[0], StringToks.size());
+  return Owned(Actions.ActOnStringLiteral(&StringToks[0], StringToks.size()));
 }
 
 /// ParseExpressionList - Used for C/C++ (argument-)expression-list.

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Thu Dec 11 16:51:44 2008
@@ -135,7 +135,7 @@
 /// That way Sema can handle and report similar errors for namespaces and the
 /// global scope.
 ///
-Parser::ExprResult Parser::ParseCXXIdExpression() {
+Parser::OwningExprResult Parser::ParseCXXIdExpression() {
   // qualified-id:
   //   '::'[opt] nested-name-specifier 'template'[opt] unqualified-id
   //   '::' unqualified-id
@@ -152,30 +152,29 @@
   //
   switch (Tok.getKind()) {
   default:
-    return Diag(Tok, diag::err_expected_unqualified_id);
+    return ExprError(Diag(Tok, diag::err_expected_unqualified_id));
 
   case tok::identifier: {
     // Consume the identifier so that we can see if it is followed by a '('.
     IdentifierInfo &II = *Tok.getIdentifierInfo();
     SourceLocation L = ConsumeToken();
-    return Actions.ActOnIdentifierExpr(CurScope, L, II,
-                                       Tok.is(tok::l_paren), &SS);
+    return Owned(Actions.ActOnIdentifierExpr(CurScope, L, II,
+                                             Tok.is(tok::l_paren), &SS));
   }
 
   case tok::kw_operator: {
     SourceLocation OperatorLoc = Tok.getLocation();
     if (OverloadedOperatorKind Op = TryParseOperatorFunctionId()) {
-      return Actions.ActOnCXXOperatorFunctionIdExpr(CurScope, OperatorLoc, Op, 
-                                                    Tok.is(tok::l_paren), SS);
+      return Owned(Actions.ActOnCXXOperatorFunctionIdExpr(
+                         CurScope, OperatorLoc, Op, Tok.is(tok::l_paren), SS));
     } else if (TypeTy *Type = ParseConversionFunctionId()) {
-      return Actions.ActOnCXXConversionFunctionExpr(CurScope, OperatorLoc,
-                                                    Type, Tok.is(tok::l_paren), 
-                                                    SS);
+      return Owned(Actions.ActOnCXXConversionFunctionExpr(
+                         CurScope, OperatorLoc, Type, Tok.is(tok::l_paren),SS));
     }
-     
+
     // We already complained about a bad conversion-function-id,
     // above.
-    return true;
+    return ExprError();
   }
 
   } // switch.
@@ -192,7 +191,7 @@
 ///         'reinterpret_cast' '<' type-name '>' '(' expression ')'
 ///         'const_cast' '<' type-name '>' '(' expression ')'
 ///
-Parser::ExprResult Parser::ParseCXXCasts() {
+Parser::OwningExprResult Parser::ParseCXXCasts() {
   tok::TokenKind Kind = Tok.getKind();
   const char *CastName = 0;     // For error messages
 
@@ -208,18 +207,18 @@
   SourceLocation LAngleBracketLoc = Tok.getLocation();
 
   if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName))
-    return ExprResult(true);
+    return ExprError();
 
   TypeTy *CastTy = ParseTypeName();
   SourceLocation RAngleBracketLoc = Tok.getLocation();
 
   if (ExpectAndConsume(tok::greater, diag::err_expected_greater))
-    return Diag(LAngleBracketLoc, diag::note_matching) << "<";
+    return ExprError(Diag(LAngleBracketLoc, diag::note_matching) << "<");
 
   SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;
 
   if (Tok.isNot(tok::l_paren))
-    return Diag(Tok, diag::err_expected_lparen_after) << CastName;
+    return ExprError(Diag(Tok, diag::err_expected_lparen_after) << CastName);
 
   OwningExprResult Result(ParseSimpleParenExpression(RParenLoc));
 
@@ -228,7 +227,7 @@
                                        LAngleBracketLoc, CastTy, RAngleBracketLoc,
                                        LParenLoc, Result.release(), RParenLoc);
 
-  return Result.result();
+  return move(Result);
 }
 
 /// ParseCXXTypeid - This handles the C++ typeid expression.
@@ -237,7 +236,7 @@
 ///         'typeid' '(' expression ')'
 ///         'typeid' '(' type-id ')'
 ///
-Parser::ExprResult Parser::ParseCXXTypeid() {
+Parser::OwningExprResult Parser::ParseCXXTypeid() {
   assert(Tok.is(tok::kw_typeid) && "Not 'typeid'!");
 
   SourceLocation OpLoc = ConsumeToken();
@@ -247,7 +246,7 @@
   // typeid expressions are always parenthesized.
   if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
       "typeid"))
-    return ExprResult(true);
+    return ExprError();
 
   OwningExprResult Result(Actions);
 
@@ -258,7 +257,7 @@
     MatchRHSPunctuation(tok::r_paren, LParenLoc);
 
     if (!Ty)
-      return ExprResult(true);
+      return ExprError();
 
     Result = Actions.ActOnCXXTypeid(OpLoc, LParenLoc, /*isType=*/true,
                                     Ty, RParenLoc);
@@ -276,7 +275,7 @@
     }
   }
 
-  return Result.result();
+  return move(Result);
 }
 
 /// ParseCXXBoolLiteral - This handles the C++ Boolean literals.
@@ -284,19 +283,19 @@
 ///       boolean-literal: [C++ 2.13.5]
 ///         'true'
 ///         'false'
-Parser::ExprResult Parser::ParseCXXBoolLiteral() {
+Parser::OwningExprResult Parser::ParseCXXBoolLiteral() {
   tok::TokenKind Kind = Tok.getKind();
-  return Actions.ActOnCXXBoolLiteral(ConsumeToken(), Kind);
+  return Owned(Actions.ActOnCXXBoolLiteral(ConsumeToken(), Kind));
 }
 
 /// ParseThrowExpression - This handles the C++ throw expression.
 ///
 ///       throw-expression: [C++ 15]
 ///         'throw' assignment-expression[opt]
-Parser::ExprResult Parser::ParseThrowExpression() {
+Parser::OwningExprResult Parser::ParseThrowExpression() {
   assert(Tok.is(tok::kw_throw) && "Not throw!");
   SourceLocation ThrowLoc = ConsumeToken();           // Eat the throw token.
-  
+
   // If the current token isn't the start of an assignment-expression,
   // then the expression is not present.  This handles things like:
   //   "C ? throw : (void)42", which is crazy but legal.
@@ -307,12 +306,12 @@
   case tok::r_brace:
   case tok::colon:
   case tok::comma:
-    return Actions.ActOnCXXThrow(ThrowLoc);
+    return Owned(Actions.ActOnCXXThrow(ThrowLoc));
 
   default:
     OwningExprResult Expr(ParseAssignmentExpression());
-    if (Expr.isInvalid()) return Expr.result();
-    return Actions.ActOnCXXThrow(ThrowLoc, Expr.release());
+    if (Expr.isInvalid()) return move(Expr);
+    return Owned(Actions.ActOnCXXThrow(ThrowLoc, Expr.release()));
   }
 }
 
@@ -321,10 +320,10 @@
 /// C++ 9.3.2: In the body of a non-static member function, the keyword this is
 /// a non-lvalue expression whose value is the address of the object for which
 /// the function is called.
-Parser::ExprResult Parser::ParseCXXThis() {
+Parser::OwningExprResult Parser::ParseCXXThis() {
   assert(Tok.is(tok::kw_this) && "Not 'this'!");
   SourceLocation ThisLoc = ConsumeToken();
-  return Actions.ActOnCXXThis(ThisLoc);
+  return Owned(Actions.ActOnCXXThis(ThisLoc));
 }
 
 /// ParseCXXTypeConstructExpression - Parse construction of a specified type.
@@ -336,7 +335,8 @@
 ///         simple-type-specifier '(' expression-list[opt] ')'      [C++ 5.2.3]
 ///         typename-specifier '(' expression-list[opt] ')'         [TODO]
 ///
-Parser::ExprResult Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) {
+Parser::OwningExprResult
+Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) {
   Declarator DeclaratorInfo(DS, Declarator::TypeNameContext);
   TypeTy *TypeRep = Actions.ActOnTypeName(CurScope, DeclaratorInfo).Val;
 
@@ -349,7 +349,7 @@
   if (Tok.isNot(tok::r_paren)) {
     if (ParseExpressionList(Exprs, CommaLocs)) {
       SkipUntil(tok::r_paren);
-      return ExprResult(true);
+      return ExprError();
     }
   }
 
@@ -358,10 +358,10 @@
 
   assert((Exprs.size() == 0 || Exprs.size()-1 == CommaLocs.size())&&
          "Unexpected number of commas!");
-  return Actions.ActOnCXXTypeConstructExpr(DS.getSourceRange(), TypeRep,
-                                           LParenLoc,
-                                           Exprs.take(), Exprs.size(),
-                                           &CommaLocs[0], RParenLoc);
+  return Owned(Actions.ActOnCXXTypeConstructExpr(DS.getSourceRange(), TypeRep,
+                                                 LParenLoc,
+                                                 Exprs.take(), Exprs.size(),
+                                                 &CommaLocs[0], RParenLoc));
 }
 
 /// ParseCXXCondition - if/switch/while/for condition expression.
@@ -662,7 +662,7 @@
 ///                   '(' expression-list[opt] ')'
 /// [C++0x]           braced-init-list                                   [TODO]
 ///
-Parser::ExprResult Parser::ParseCXXNewExpression()
+Parser::OwningExprResult Parser::ParseCXXNewExpression()
 {
   assert((Tok.is(tok::coloncolon) || Tok.is(tok::kw_new)) &&
          "Expected :: or 'new' keyword");
@@ -692,13 +692,13 @@
     PlacementLParen = ConsumeParen();
     if (ParseExpressionListOrTypeId(PlacementArgs, DeclaratorInfo)) {
       SkipUntil(tok::semi, /*StopAtSemi=*/true, /*DontConsume=*/true);
-      return true;
+      return ExprError();
     }
 
     PlacementRParen = MatchRHSPunctuation(tok::r_paren, PlacementLParen);
     if (PlacementRParen.isInvalid()) {
       SkipUntil(tok::semi, /*StopAtSemi=*/true, /*DontConsume=*/true);
-      return true;
+      return ExprError();
     }
 
     if (PlacementArgs.empty()) {
@@ -734,7 +734,7 @@
   }
   if (DeclaratorInfo.getInvalidType()) {
     SkipUntil(tok::semi, /*StopAtSemi=*/true, /*DontConsume=*/true);
-    return true;
+    return ExprError();
   }
 
   ExprVector ConstructorArgs(Actions);
@@ -746,21 +746,21 @@
       CommaLocsTy CommaLocs;
       if (ParseExpressionList(ConstructorArgs, CommaLocs)) {
         SkipUntil(tok::semi, /*StopAtSemi=*/true, /*DontConsume=*/true);
-        return true;
+        return ExprError();
       }
     }
     ConstructorRParen = MatchRHSPunctuation(tok::r_paren, ConstructorLParen);
     if (ConstructorRParen.isInvalid()) {
       SkipUntil(tok::semi, /*StopAtSemi=*/true, /*DontConsume=*/true);
-      return true;
+      return ExprError();
     }
   }
 
-  return Actions.ActOnCXXNew(Start, UseGlobal, PlacementLParen,
-                             PlacementArgs.take(), PlacementArgs.size(),
-                             PlacementRParen, ParenTypeId, DeclaratorInfo,
-                             ConstructorLParen, ConstructorArgs.take(),
-                             ConstructorArgs.size(), ConstructorRParen);
+  return Owned(Actions.ActOnCXXNew(Start, UseGlobal, PlacementLParen,
+                                   PlacementArgs.take(), PlacementArgs.size(),
+                                   PlacementRParen, ParenTypeId, DeclaratorInfo,
+                                   ConstructorLParen, ConstructorArgs.take(),
+                                   ConstructorArgs.size(), ConstructorRParen));
 }
 
 /// ParseDirectNewDeclarator - Parses a direct-new-declarator. Intended to be
@@ -825,7 +825,7 @@
 ///        delete-expression:
 ///                   '::'[opt] 'delete' cast-expression
 ///                   '::'[opt] 'delete' '[' ']' cast-expression
-Parser::ExprResult Parser::ParseCXXDeleteExpression()
+Parser::OwningExprResult Parser::ParseCXXDeleteExpression()
 {
   assert((Tok.is(tok::coloncolon) || Tok.is(tok::kw_delete)) &&
          "Expected :: or 'delete' keyword");
@@ -848,13 +848,13 @@
     SourceLocation LHS = ConsumeBracket();
     SourceLocation RHS = MatchRHSPunctuation(tok::r_square, LHS);
     if (RHS.isInvalid())
-      return true;
+      return ExprError();
   }
 
   OwningExprResult Operand(ParseCastExpression(false));
   if (Operand.isInvalid())
-    return Operand.result();
+    return move(Operand);
 
-  return Actions.ActOnCXXDelete(Start, UseGlobal, ArrayDelete,
-                                Operand.release());
+  return Owned(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=60906&r1=60905&r2=60906&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseInit.cpp (original)
+++ cfe/trunk/lib/Parse/ParseInit.cpp Thu Dec 11 16:51:44 2008
@@ -57,10 +57,10 @@
 /// initializer (because it is an expression).  We need to consider this case
 /// when parsing array designators.
 ///
-Parser::ExprResult Parser::
+Parser::OwningExprResult Parser::
 ParseInitializerWithPotentialDesignator(InitListDesignations &Designations,
                                         unsigned InitNum) {
-  
+
   // If this is the old-style GNU extension:
   //   designation ::= identifier ':'
   // Handle it as a field designator.  Otherwise, this must be the start of a
@@ -94,7 +94,7 @@
       
       if (Tok.isNot(tok::identifier)) {
         Diag(Tok.getLocation(), diag::err_expected_field_designator);
-        return ExprResult(true);
+        return ExprError();
       }
       
       Desig->AddDesignator(Designator::getField(Tok.getIdentifierInfo()));
@@ -136,8 +136,8 @@
       
       IdentifierInfo *Name = Tok.getIdentifierInfo();
       SourceLocation NameLoc = ConsumeToken();
-      return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, NameLoc,
-                                                         Name, 0);
+      return Owned(ParseAssignmentExprWithObjCMessageExprStart(
+                       StartLoc, NameLoc, Name, 0));
     }
     
     // Note that we parse this as an assignment expression, not a constant
@@ -146,7 +146,7 @@
     OwningExprResult Idx(ParseAssignmentExpression());
     if (Idx.isInvalid()) {
       SkipUntil(tok::r_square);
-      return Idx.result();
+      return move(Idx);
     }
     
     // Given an expression, we could either have a designator (if the next
@@ -167,10 +167,10 @@
         else
           Diag(Tok, diag::err_expected_equal_designator);
       }
-      
-      return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
-                                                         SourceLocation(), 
-                                                         0, Idx.release());
+
+      return Owned(ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
+                                                               SourceLocation(),
+                                                             0, Idx.release()));
     }
 
     // Create designation if we haven't already.
@@ -188,7 +188,7 @@
       OwningExprResult RHS(ParseConstantExpression());
       if (RHS.isInvalid()) {
         SkipUntil(tok::r_square);
-        return RHS.result();
+        return move(RHS);
       }
       Desig->AddDesignator(Designator::getArrayRange(Idx.release(),
                                                      RHS.release()));
@@ -202,13 +202,13 @@
   // without a designator is when we have an objc message send.  That case is
   // handled and returned from above.
   assert(Desig && "Designator didn't get created?");
-  
+
   // Handle a normal designator sequence end, which is an equal.
   if (Tok.is(tok::equal)) {
     ConsumeToken();
     return ParseInitializer();
   }
-  
+
   // We read some number of designators and found something that isn't an = or
   // an initializer.  If we have exactly one array designator, this
   // is the GNU 'designation: array-designator' extension.  Otherwise, it is a
@@ -219,9 +219,9 @@
     Diag(Tok, diag::ext_gnu_missing_equal_designator);
     return ParseInitializer();
   }
-  
+
   Diag(Tok, diag::err_expected_equal_designator);
-  return true;
+  return ExprError();
 }
 
 
@@ -237,7 +237,7 @@
 ///         designation[opt] initializer
 ///         initializer-list ',' designation[opt] initializer
 ///
-Parser::ExprResult Parser::ParseBraceInitializer() {
+Parser::OwningExprResult Parser::ParseBraceInitializer() {
   SourceLocation LBraceLoc = ConsumeBrace();
 
   /// InitExprs - This is the actual list of expressions contained in the
@@ -253,15 +253,15 @@
   if (Tok.is(tok::r_brace)) {
     Diag(LBraceLoc, diag::ext_gnu_empty_initializer);
     // Match the '}'.
-    return Actions.ActOnInitList(LBraceLoc, 0, 0, InitExprDesignations,
-                                 ConsumeBrace());
+    return Owned(Actions.ActOnInitList(LBraceLoc, 0, 0, InitExprDesignations,
+                                       ConsumeBrace()));
   }
-  
+
   bool InitExprsOk = true;
-  
+
   while (1) {
     // Parse: designation[opt] initializer
-    
+
     // If we know that this cannot be a designation, just parse the nested
     // initializer directly.
     OwningExprResult SubElt(Actions);
@@ -301,19 +301,20 @@
 
     // If we don't have a comma continued list, we're done.
     if (Tok.isNot(tok::comma)) break;
-    
+
     // TODO: save comma locations if some client cares.
     ConsumeToken();
-    
+
     // Handle trailing comma.
     if (Tok.is(tok::r_brace)) break;
   }
   if (InitExprsOk && Tok.is(tok::r_brace))
-    return Actions.ActOnInitList(LBraceLoc, InitExprs.take(), InitExprs.size(),
-                                 InitExprDesignations, ConsumeBrace());
-  
+    return Owned(Actions.ActOnInitList(LBraceLoc, InitExprs.take(),
+                                       InitExprs.size(),
+                                       InitExprDesignations, ConsumeBrace()));
+
   // Match the '}'.
   MatchRHSPunctuation(tok::r_brace, LBraceLoc);
-  return ExprResult(true); // an error occurred.
+  return ExprError(); // an error occurred.
 }
 

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Dec 11 16:51:44 2008
@@ -1567,7 +1567,7 @@
 }
 
 Parser::ExprResult Parser::ParseObjCStringLiteral(SourceLocation AtLoc) {
-  OwningExprResult Res(Actions, ParseStringLiteralExpression());
+  OwningExprResult Res(ParseStringLiteralExpression());
   if (Res.isInvalid()) return Res.result();
   
   // @"foo" @"bar" is a valid concatenated string.  Eat any subsequent string

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

==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Thu Dec 11 16:51:44 2008
@@ -669,7 +669,7 @@
     return ExprError();
   }
 
-  OwningExprResult Res(Actions, ParseStringLiteralExpression());
+  OwningExprResult Res(ParseStringLiteralExpression());
   if (Res.isInvalid()) return move(Res);
 
   // TODO: Diagnose: wide string literal in 'asm'





More information about the cfe-commits mailing list