[cfe-commits] r62537 - in /cfe/trunk: Driver/PrintParserCallbacks.cpp include/clang/Parse/Action.h lib/Parse/ParseExpr.cpp lib/Parse/ParseInit.cpp lib/Sema/Sema.h lib/Sema/SemaExpr.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Mon Jan 19 14:31:54 PST 2009


Author: cornedbee
Date: Mon Jan 19 16:31:54 2009
New Revision: 62537

URL: http://llvm.org/viewvc/llvm-project?rev=62537&view=rev
Log:
Convert more expression actions to smart pointers.

Modified:
    cfe/trunk/Driver/PrintParserCallbacks.cpp
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/lib/Parse/ParseInit.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/Driver/PrintParserCallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/PrintParserCallbacks.cpp?rev=62537&r1=62536&r2=62537&view=diff

==============================================================================
--- cfe/trunk/Driver/PrintParserCallbacks.cpp (original)
+++ cfe/trunk/Driver/PrintParserCallbacks.cpp Mon Jan 19 16:31:54 2009
@@ -542,42 +542,45 @@
       llvm::cout << __FUNCTION__ << "\n";
       return ExprEmpty();
     }
-  
-    virtual ExprResult ActOnCompoundLiteral(SourceLocation LParen, TypeTy *Ty,
-                                            SourceLocation RParen, ExprTy *Op) {
+
+    virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParen,
+                                                  TypeTy *Ty,
+                                                  SourceLocation RParen,
+                                                  ExprArg Op) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return ExprEmpty();
     }
-    virtual ExprResult ActOnInitList(SourceLocation LParenLoc,
-                                     ExprTy **InitList, unsigned NumInit,
-                                     InitListDesignations &Designators,
-                                     SourceLocation RParenLoc) {
+    virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc,
+                                           MultiExprArg InitList,
+                                           InitListDesignations &Designators,
+                                           SourceLocation RParenLoc) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return ExprEmpty();
     }
-    virtual ExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
-                                     SourceLocation RParenLoc, ExprTy *Op) {
+    virtual OwningExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
+                                           SourceLocation RParenLoc,ExprArg Op){
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return ExprEmpty();
     }
-  
-    virtual ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, 
-                                  tok::TokenKind Kind,
-                                  ExprTy *LHS, ExprTy *RHS) {
+
+    virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
+                                        tok::TokenKind Kind,
+                                        ExprArg LHS, ExprArg RHS) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return ExprEmpty();
     }
 
     /// ActOnConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
     /// in the case of a the GNU conditional expr extension.
-    virtual ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, 
-                                          SourceLocation ColonLoc,
-                                          ExprTy *Cond, ExprTy *LHS, ExprTy *RHS){
+    virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
+                                                SourceLocation ColonLoc,
+                                                ExprArg Cond, ExprArg LHS,
+                                                ExprArg RHS) {
       llvm::cout << __FUNCTION__ << "\n";
-      return 0;
+      return ExprEmpty();
     }
-  
-    //===---------------------- GNU Extension Expressions -------------------===//
+
+    //===--------------------- GNU Extension Expressions ------------------===//
 
     virtual ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
                                       IdentifierInfo *LabelII) { // "&&foo"

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

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Mon Jan 19 16:31:54 2009
@@ -629,35 +629,38 @@
     return ExprEmpty();
   }
 
-  virtual ExprResult ActOnCompoundLiteral(SourceLocation LParen, TypeTy *Ty,
-                                          SourceLocation RParen, ExprTy *Op) {
-    return 0;
+  virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParen,
+                                                TypeTy *Ty,
+                                                SourceLocation RParen,
+                                                ExprArg Op) {
+    return ExprEmpty();
   }
-  virtual ExprResult ActOnInitList(SourceLocation LParenLoc,
-                                   ExprTy **InitList, unsigned NumInit,
-                                   InitListDesignations &Designators,
-                                   SourceLocation RParenLoc) {
-    return 0;
+  virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc,
+                                         MultiExprArg InitList,
+                                         InitListDesignations &Designators,
+                                         SourceLocation RParenLoc) {
+    return ExprEmpty();
   }
-  virtual ExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
-                                   SourceLocation RParenLoc, ExprTy *Op) {
-    return 0;
+  virtual OwningExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
+                                         SourceLocation RParenLoc, ExprArg Op) {
+    return ExprEmpty();
   }
-  
-  virtual ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, 
-                                tok::TokenKind Kind,
-                                ExprTy *LHS, ExprTy *RHS) {
-    return 0;
+
+  virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
+                                      tok::TokenKind Kind,
+                                      ExprArg LHS, ExprArg RHS) {
+    return ExprEmpty();
   }
 
   /// ActOnConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
   /// in the case of a the GNU conditional expr extension.
-  virtual ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, 
-                                        SourceLocation ColonLoc,
-                                        ExprTy *Cond, ExprTy *LHS, ExprTy *RHS){
-    return 0;
+  virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
+                                              SourceLocation ColonLoc,
+                                              ExprArg Cond, ExprArg LHS,
+                                              ExprArg RHS) {
+    return ExprEmpty();
   }
-  
+
   //===---------------------- GNU Extension Expressions -------------------===//
 
   virtual ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Mon Jan 19 16:31:54 2009
@@ -315,12 +315,12 @@
       // Combine the LHS and RHS into the LHS (e.g. build AST).
       if (TernaryMiddle.isInvalid())
         LHS = Actions.ActOnBinOp(CurScope, OpToken.getLocation(),
-                                 OpToken.getKind(), LHS.release(),
-                                 RHS.release());
+                                 OpToken.getKind(), move_arg(LHS),
+                                 move_arg(RHS));
       else
         LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
-                                         LHS.release(), TernaryMiddle.release(),
-                                         RHS.release());
+                                         move_arg(LHS), move_arg(TernaryMiddle),
+                                         move_arg(RHS));
     }
   }
 }
@@ -472,7 +472,7 @@
       Res = ParseCastExpression(false);
       if (!Res.isInvalid())
         Res = Actions.ActOnCastExpr(LParenLoc, CastTy, RParenLoc,
-                                    Res.release());
+                                    move_arg(Res));
       return move(Res);
     }
 
@@ -1097,11 +1097,11 @@
       Result = ParseInitializer();
       ExprType = CompoundLiteral;
       if (!Result.isInvalid())
-        return Owned(Actions.ActOnCompoundLiteral(OpenLoc, Ty, RParenLoc,
-                                                  Result.release()));
+        return Actions.ActOnCompoundLiteral(OpenLoc, Ty, RParenLoc,
+                                            move_arg(Result));
       return move(Result);
     }
-    
+
     if (ExprType == CastExpr) {
       // Note that this doesn't parse the subsequence cast-expression, it just
       // returns the parsed type to the callee.
@@ -1109,7 +1109,7 @@
       CastTy = Ty;
       return OwningExprResult(Actions);
     }
-    
+
     Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
     return ExprError();
   } else {

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

==============================================================================
--- cfe/trunk/lib/Parse/ParseInit.cpp (original)
+++ cfe/trunk/lib/Parse/ParseInit.cpp Mon Jan 19 16:31:54 2009
@@ -253,8 +253,8 @@
   if (Tok.is(tok::r_brace)) {
     Diag(LBraceLoc, diag::ext_gnu_empty_initializer);
     // Match the '}'.
-    return Owned(Actions.ActOnInitList(LBraceLoc, 0, 0, InitExprDesignations,
-                                       ConsumeBrace()));
+    return Actions.ActOnInitList(LBraceLoc, Action::MultiExprArg(Actions),
+                                 InitExprDesignations, ConsumeBrace());
   }
 
   bool InitExprsOk = true;
@@ -309,9 +309,8 @@
     if (Tok.is(tok::r_brace)) break;
   }
   if (InitExprsOk && Tok.is(tok::r_brace))
-    return Owned(Actions.ActOnInitList(LBraceLoc, InitExprs.take(),
-                                       InitExprs.size(),
-                                       InitExprDesignations, ConsumeBrace()));
+    return Actions.ActOnInitList(LBraceLoc, move_arg(InitExprs),
+                                 InitExprDesignations, ConsumeBrace());
 
   // Match the '}'.
   MatchRHSPunctuation(tok::r_brace, LBraceLoc);

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=62537&r1=62536&r2=62537&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Mon Jan 19 16:31:54 2009
@@ -255,7 +255,7 @@
   OwningStmtResult Owned(Stmt* S) { return OwningStmtResult(*this, S); }
 
   virtual void ActOnEndOfTranslationUnit();
-  
+
   //===--------------------------------------------------------------------===//
   // Type Analysis / Processing: SemaType.cpp.
   //
@@ -310,7 +310,7 @@
   virtual DeclTy *ActOnStartOfFunctionDef(Scope *S, Declarator &D);
   virtual DeclTy *ActOnStartOfFunctionDef(Scope *S, DeclTy *D);
   virtual void ObjCActOnStartOfMethodDef(Scope *S, DeclTy *D);
-  
+
   virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtArg Body);
   virtual DeclTy *ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg expr);
 
@@ -1029,29 +1029,31 @@
                                          SourceLocation *CommaLocs,
                                          SourceLocation RParenLoc);
 
-  virtual ExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
-                                   SourceLocation RParenLoc, ExprTy *Op);
-                                   
-  virtual ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,
-                                          SourceLocation RParenLoc, ExprTy *Op);
-  
-  virtual ExprResult ActOnInitList(SourceLocation LParenLoc, 
-                                   ExprTy **InitList, unsigned NumInit,
-                                   InitListDesignations &Designators,
-                                   SourceLocation RParenLoc);
-                                   
-  virtual ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, 
-                                tok::TokenKind Kind,
-                                ExprTy *LHS,ExprTy *RHS);
-  ExprResult CreateBuiltinBinOp(SourceLocation TokLoc, 
-                                unsigned Opc,
-                                Expr *lhs, Expr *rhs);
+  virtual OwningExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
+                                         SourceLocation RParenLoc, ExprArg Op);
+
+  virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParenLoc,
+                                                TypeTy *Ty,
+                                                SourceLocation RParenLoc,
+                                                ExprArg Op);
+
+  virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc,
+                                         MultiExprArg InitList,
+                                         InitListDesignations &Designators,
+                                         SourceLocation RParenLoc);
+
+  virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
+                                      tok::TokenKind Kind,
+                                      ExprArg LHS, ExprArg RHS);
+  OwningExprResult CreateBuiltinBinOp(SourceLocation TokLoc,
+                                      unsigned Opc, Expr *lhs, Expr *rhs);
 
   /// ActOnConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
   /// in the case of a the GNU conditional expr extension.
-  virtual ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, 
-                                        SourceLocation ColonLoc,
-                                        ExprTy *Cond, ExprTy *LHS, ExprTy *RHS);
+  virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
+                                              SourceLocation ColonLoc,
+                                              ExprArg Cond, ExprArg LHS,
+                                              ExprArg RHS);
 
   /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
   virtual ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=62537&r1=62536&r2=62537&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jan 19 16:31:54 2009
@@ -1896,50 +1896,52 @@
   return Owned(TheCall.take());
 }
 
-Action::ExprResult Sema::
-ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,
-                     SourceLocation RParenLoc, ExprTy *InitExpr) {
+Action::OwningExprResult
+Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,
+                           SourceLocation RParenLoc, ExprArg InitExpr) {
   assert((Ty != 0) && "ActOnCompoundLiteral(): missing type");
   QualType literalType = QualType::getFromOpaquePtr(Ty);
   // FIXME: put back this assert when initializers are worked out.
   //assert((InitExpr != 0) && "ActOnCompoundLiteral(): missing expression");
-  Expr *literalExpr = static_cast<Expr*>(InitExpr);
+  Expr *literalExpr = static_cast<Expr*>(InitExpr.get());
 
   if (literalType->isArrayType()) {
     if (literalType->isVariableArrayType())
-      return Diag(LParenLoc, diag::err_variable_object_no_init)
-        << SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd());
+      return ExprError(Diag(LParenLoc, diag::err_variable_object_no_init)
+        << SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd()));
   } else if (DiagnoseIncompleteType(LParenLoc, literalType,
                                     diag::err_typecheck_decl_incomplete_type,
                 SourceRange(LParenLoc, literalExpr->getSourceRange().getEnd())))
-    return true;
+    return ExprError();
 
-  if (CheckInitializerTypes(literalExpr, literalType, LParenLoc, 
+  if (CheckInitializerTypes(literalExpr, literalType, LParenLoc,
                             DeclarationName(), /*FIXME:DirectInit=*/false))
-    return true;
+    return ExprError();
 
   bool isFileScope = getCurFunctionOrMethodDecl() == 0;
   if (isFileScope) { // 6.5.2.5p3
     if (CheckForConstantInitializer(literalExpr, literalType))
-      return true;
+      return ExprError();
   }
-  return new CompoundLiteralExpr(LParenLoc, literalType, literalExpr,
-                                 isFileScope);
+  InitExpr.release();
+  return Owned(new CompoundLiteralExpr(LParenLoc, literalType, literalExpr,
+                                       isFileScope));
 }
 
-Action::ExprResult Sema::
-ActOnInitList(SourceLocation LBraceLoc, ExprTy **initlist, unsigned NumInit,
-              InitListDesignations &Designators,
-              SourceLocation RBraceLoc) {
-  Expr **InitList = reinterpret_cast<Expr**>(initlist);
+Action::OwningExprResult
+Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg initlist,
+                    InitListDesignations &Designators,
+                    SourceLocation RBraceLoc) {
+  unsigned NumInit = initlist.size();
+  Expr **InitList = reinterpret_cast<Expr**>(initlist.release());
 
   // Semantic analysis for initializers is done by ActOnDeclarator() and
   // CheckInitializer() - it requires knowledge of the object being intialized. 
-  
+
   InitListExpr *E = new InitListExpr(LBraceLoc, InitList, NumInit, RBraceLoc,
                                      Designators.hasAnyDesignators());
   E->setType(Context.VoidTy); // FIXME: just a place holder for now.
-  return E;
+  return Owned(E);
 }
 
 /// CheckCastTypes - Check type constraints for casting between types.
@@ -2013,17 +2015,19 @@
   return false;
 }
 
-Action::ExprResult Sema::
-ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
-              SourceLocation RParenLoc, ExprTy *Op) {
-  assert((Ty != 0) && (Op != 0) && "ActOnCastExpr(): missing type or expr");
+Action::OwningExprResult
+Sema::ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
+                    SourceLocation RParenLoc, ExprArg Op) {
+  assert((Ty != 0) && (Op.get() != 0) &&
+         "ActOnCastExpr(): missing type or expr");
 
-  Expr *castExpr = static_cast<Expr*>(Op);
+  Expr *castExpr = static_cast<Expr*>(Op.release());
   QualType castType = QualType::getFromOpaquePtr(Ty);
 
   if (CheckCastTypes(SourceRange(LParenLoc, RParenLoc), castType, castExpr))
-    return true;
-  return new CStyleCastExpr(castType, castExpr, castType, LParenLoc, RParenLoc);
+    return ExprError();
+  return Owned(new CStyleCastExpr(castType, castExpr, castType,
+                                  LParenLoc, RParenLoc));
 }
 
 /// Note that lex is not null here, even if this is the gnu "x ?: y" extension.
@@ -2221,25 +2225,29 @@
 
 /// ActOnConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
 /// in the case of a the GNU conditional expr extension.
-Action::ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc, 
-                                            SourceLocation ColonLoc,
-                                            ExprTy *Cond, ExprTy *LHS,
-                                            ExprTy *RHS) {
-  Expr *CondExpr = (Expr *) Cond;
-  Expr *LHSExpr = (Expr *) LHS, *RHSExpr = (Expr *) RHS;
+Action::OwningExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
+                                                  SourceLocation ColonLoc,
+                                                  ExprArg Cond, ExprArg LHS,
+                                                  ExprArg RHS) {
+  Expr *CondExpr = (Expr *) Cond.get();
+  Expr *LHSExpr = (Expr *) LHS.get(), *RHSExpr = (Expr *) RHS.get();
 
   // If this is the gnu "x ?: y" extension, analyze the types as though the LHS
   // was the condition.
   bool isLHSNull = LHSExpr == 0;
   if (isLHSNull)
     LHSExpr = CondExpr;
-  
-  QualType result = CheckConditionalOperands(CondExpr, LHSExpr, 
+
+  QualType result = CheckConditionalOperands(CondExpr, LHSExpr,
                                              RHSExpr, QuestionLoc);
   if (result.isNull())
-    return true;
-  return new ConditionalOperator(CondExpr, isLHSNull ? 0 : LHSExpr,
-                                 RHSExpr, result);
+    return ExprError();
+
+  Cond.release();
+  LHS.release();
+  RHS.release();
+  return Owned(new ConditionalOperator(CondExpr, isLHSNull ? 0 : LHSExpr,
+                                       RHSExpr, result));
 }
 
 
@@ -3420,9 +3428,9 @@
 /// CreateBuiltinBinOp - Creates a new built-in binary operation with
 /// operator @p Opc at location @c TokLoc. This routine only supports
 /// built-in operations; ActOnBinOp handles overloaded operators.
-Action::ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc, 
-                                            unsigned Op,
-                                            Expr *lhs, Expr *rhs) {
+Action::OwningExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
+                                                  unsigned Op,
+                                                  Expr *lhs, Expr *rhs) {
   QualType ResultTy;  // Result type of the binary operator.
   QualType CompTy;    // Computation type for compound assignments (e.g. '+=')
   BinaryOperator::Opcode Opc = (BinaryOperator::Opcode)Op;
@@ -3508,19 +3516,20 @@
     break;
   }
   if (ResultTy.isNull())
-    return true;
+    return ExprError();
   if (CompTy.isNull())
-    return new BinaryOperator(lhs, rhs, Opc, ResultTy, OpLoc);
+    return Owned(new BinaryOperator(lhs, rhs, Opc, ResultTy, OpLoc));
   else
-    return new CompoundAssignOperator(lhs, rhs, Opc, ResultTy, CompTy, OpLoc);  
+    return Owned(new CompoundAssignOperator(lhs, rhs, Opc, ResultTy,
+                                            CompTy, OpLoc));
 }
 
 // Binary Operators.  'Tok' is the token for the operator.
-Action::ExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc, 
-                                    tok::TokenKind Kind, 
-                                    ExprTy *LHS, ExprTy *RHS) {
+Action::OwningExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc,
+                                          tok::TokenKind Kind,
+                                          ExprArg LHS, ExprArg RHS) {
   BinaryOperator::Opcode Opc = ConvertTokenKindToBinaryOpcode(Kind);
-  Expr *lhs = (Expr *)LHS, *rhs = (Expr*)RHS;
+  Expr *lhs = (Expr *)LHS.release(), *rhs = (Expr*)RHS.release();
 
   assert((lhs != 0) && "ActOnBinOp(): missing left expression");
   assert((rhs != 0) && "ActOnBinOp(): missing right expression");
@@ -3530,10 +3539,12 @@
   // lookup for operator+.
   if (lhs->isTypeDependent() || rhs->isTypeDependent()) {
     if (Opc > BinaryOperator::Assign && Opc <= BinaryOperator::OrAssign)
-      return new CompoundAssignOperator(lhs, rhs, Opc, Context.DependentTy, 
-                                        Context.DependentTy, TokLoc);
+      return Owned(new CompoundAssignOperator(lhs, rhs, Opc,
+                                              Context.DependentTy,
+                                              Context.DependentTy, TokLoc));
     else
-      return new BinaryOperator(lhs, rhs, Opc, Context.DependentTy, TokLoc);
+      return Owned(new BinaryOperator(lhs, rhs, Opc, Context.DependentTy,
+                                      TokLoc));
   }
 
   if (getLangOptions().CPlusPlus &&
@@ -3546,7 +3557,7 @@
         !(lhs->getType()->isRecordType() || lhs->getType()->isEnumeralType())) {
       return CreateBuiltinBinOp(TokLoc, Opc, lhs, rhs);
     }
-    
+
     // Determine which overloaded operator we're dealing with.
     static const OverloadedOperatorKind OverOps[] = {
       OO_Star, OO_Slash, OO_Percent,
@@ -3591,27 +3602,27 @@
           if (PerformObjectArgumentInitialization(lhs, Method) ||
               PerformCopyInitialization(rhs, FnDecl->getParamDecl(0)->getType(),
                                         "passing"))
-            return true;
+            return ExprError();
         } else {
           // Convert the arguments.
           if (PerformCopyInitialization(lhs, FnDecl->getParamDecl(0)->getType(),
                                         "passing") ||
               PerformCopyInitialization(rhs, FnDecl->getParamDecl(1)->getType(),
                                         "passing"))
-            return true;
+            return ExprError();
         }
 
         // Determine the result type
-        QualType ResultTy 
+        QualType ResultTy
           = FnDecl->getType()->getAsFunctionType()->getResultType();
         ResultTy = ResultTy.getNonReferenceType();
-        
+
         // Build the actual expression node.
-        Expr *FnExpr = new DeclRefExpr(FnDecl, FnDecl->getType(), 
+        Expr *FnExpr = new DeclRefExpr(FnDecl, FnDecl->getType(),
                                        SourceLocation());
         UsualUnaryConversions(FnExpr);
 
-        return new CXXOperatorCallExpr(FnExpr, Args, 2, ResultTy, TokLoc);
+        return Owned(new CXXOperatorCallExpr(FnExpr, Args, 2, ResultTy,TokLoc));
       } else {
         // We matched a built-in operator. Convert the arguments, then
         // break out so that we will build the appropriate built-in
@@ -3620,10 +3631,10 @@
                                       Best->Conversions[0], "passing") ||
             PerformImplicitConversion(rhs, Best->BuiltinTypes.ParamTypes[1],
                                       Best->Conversions[1], "passing"))
-          return true;
+          return ExprError();
 
         break;
-      } 
+      }
     }
 
     case OR_No_Viable_Function:
@@ -3636,14 +3647,14 @@
           << BinaryOperator::getOpcodeStr(Opc)
           << lhs->getSourceRange() << rhs->getSourceRange();
       PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/true);
-      return true;
+      return ExprError();
     }
 
     // Either we found no viable overloaded operator or we matched a
     // built-in operator. In either case, fall through to trying to
     // build a built-in operation.
-  } 
-  
+  }
+
   // Build a built-in binary operation.
   return CreateBuiltinBinOp(TokLoc, Opc, lhs, rhs);
 }





More information about the cfe-commits mailing list