]> granicus.if.org Git - clang/commitdiff
Switch parameter passing for overloaded binary operators to
authorDouglas Gregor <dgregor@apple.com>
Tue, 22 Dec 2009 21:44:34 +0000 (21:44 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 22 Dec 2009 21:44:34 +0000 (21:44 +0000)
InitializationSequence. Fixes the -fsyntax-only failure in
llvm/lib/Transforms/Scalar/InstructionCombining.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91921 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp

index 8236ad7eecb7a1c8c47ab7167b9e3adb381938f2..44eb184a36fe319103a80e2ea4567803a918fd83 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "Sema.h"
 #include "Lookup.h"
+#include "SemaInit.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/AST/ASTContext.h"
@@ -5167,17 +5168,40 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
 
         // Convert the arguments.
         if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
-          if (PerformObjectArgumentInitialization(Args[0], Method) ||
-              PerformCopyInitialization(Args[1], FnDecl->getParamDecl(0)->getType(),
-                                        AA_Passing))
+          OwningExprResult Arg1
+            = PerformCopyInitialization(
+                                        InitializedEntity::InitializeParameter(
+                                                        FnDecl->getParamDecl(0)),
+                                        SourceLocation(),
+                                        Owned(Args[1]));
+          if (Arg1.isInvalid())
             return ExprError();
+
+          if (PerformObjectArgumentInitialization(Args[0], Method))
+            return ExprError();
+
+          Args[1] = RHS = Arg1.takeAs<Expr>();
         } else {
           // Convert the arguments.
-          if (PerformCopyInitialization(Args[0], FnDecl->getParamDecl(0)->getType(),
-                                        AA_Passing) ||
-              PerformCopyInitialization(Args[1], FnDecl->getParamDecl(1)->getType(),
-                                        AA_Passing))
+          OwningExprResult Arg0
+            = PerformCopyInitialization(
+                                        InitializedEntity::InitializeParameter(
+                                                        FnDecl->getParamDecl(0)),
+                                        SourceLocation(),
+                                        Owned(Args[0]));
+          if (Arg0.isInvalid())
+            return ExprError();
+
+          OwningExprResult Arg1
+            = PerformCopyInitialization(
+                                        InitializedEntity::InitializeParameter(
+                                                        FnDecl->getParamDecl(1)),
+                                        SourceLocation(),
+                                        Owned(Args[1]));
+          if (Arg1.isInvalid())
             return ExprError();
+          Args[0] = LHS = Arg0.takeAs<Expr>();
+          Args[1] = RHS = Arg1.takeAs<Expr>();
         }
 
         // Determine the result type