[cfe-commits] r79173 - in /cfe/trunk: lib/AST/Expr.cpp lib/Sema/SemaOverload.cpp test/CodeGenCXX/temp-1.cpp

Anders Carlsson andersca at mac.com
Sat Aug 15 21:11:06 PDT 2009


Author: andersca
Date: Sat Aug 15 23:11:06 2009
New Revision: 79173

URL: http://llvm.org/viewvc/llvm-project?rev=79173&view=rev
Log:
Call MaybeBindToTemporary for overloaded binary and unary operators.

Modified:
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/CodeGenCXX/temp-1.cpp

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=79173&r1=79172&r2=79173&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sat Aug 15 23:11:06 2009
@@ -588,6 +588,9 @@
     // effects (e.g. a placement new with an uninitialized POD).
   case CXXDeleteExprClass:
     return false;
+  case CXXBindTemporaryExprClass:
+    return cast<CXXBindTemporaryExpr>(this)
+      ->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2);
   case CXXExprWithTemporariesClass:
     return cast<CXXExprWithTemporaries>(this)
       ->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sat Aug 15 23:11:06 2009
@@ -4041,9 +4041,10 @@
       UsualUnaryConversions(FnExpr);
       
       input.release();
-      return Owned(new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
-                                                     &Input, 1, ResultTy, 
-                                                     OpLoc));
+      
+      Expr *CE = new (Context) CXXOperatorCallExpr(Context, Op, FnExpr, 
+                                                   &Input, 1, ResultTy, OpLoc);
+      return MaybeBindToTemporary(CE);
     } else {
       // We matched a built-in operator. Convert the arguments, then
       // break out so that we will build the appropriate built-in
@@ -4196,9 +4197,9 @@
                                                  OpLoc);
         UsualUnaryConversions(FnExpr);
 
-        return Owned(new (Context) CXXOperatorCallExpr(Context, Op, FnExpr, 
-                                                       Args, 2, ResultTy, 
-                                                       OpLoc));
+        Expr *CE = new (Context) CXXOperatorCallExpr(Context, Op, FnExpr, 
+                                                     Args, 2, ResultTy, OpLoc);
+        return MaybeBindToTemporary(CE);
       } else {
         // We matched a built-in operator. Convert the arguments, then
         // break out so that we will build the appropriate built-in

Modified: cfe/trunk/test/CodeGenCXX/temp-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/temp-1.cpp?rev=79173&r1=79172&r2=79173&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/temp-1.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/temp-1.cpp Sat Aug 15 23:11:06 2009
@@ -49,9 +49,23 @@
 };
 
 // RUN: grep "call void @_ZN1DC1Ev" %t | count 1 &&
-// RUN: grep "call void @_ZN1DD1Ev" %t | count 2
+// RUN: grep "call void @_ZN1DD1Ev" %t | count 2 &&
 void f4() {
   D()();
 }
 
+// Overloaded operators
+struct E {
+  E();
+  ~E();
+  E operator+(const E&);
+  E operator!();
+};
+
+// RUN: grep "call void @_ZN1EC1Ev" %t | count 3 &&
+// RUN: grep "call void @_ZN1ED1Ev" %t | count 5 
+void f5() {
+  E() + E();
+  !E();
+}
 





More information about the cfe-commits mailing list