[cfe-commits] r92131 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/CodeGenCXX/temporaries.cpp

Douglas Gregor dgregor at apple.com
Thu Dec 24 09:16:46 PST 2009


Author: dgregor
Date: Thu Dec 24 11:16:46 2009
New Revision: 92131

URL: http://llvm.org/viewvc/llvm-project?rev=92131&view=rev
Log:
InitializationSequence handles binding to temporaries, so that
argument-passing doesn't have to. Fixes PR5867, where we were binding
a temporary twice in the AST and, therefore, calling its destructor
twice.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/CodeGenCXX/temporaries.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Dec 24 11:16:46 2009
@@ -3234,9 +3234,6 @@
         return true;
 
       Arg = ArgE.takeAs<Expr>();
-      
-      if (!ProtoArgType->isReferenceType())
-        Arg = MaybeBindToTemporary(Arg).takeAs<Expr>();
     } else {
       ParmVarDecl *Param = FDecl->getParamDecl(i);
       

Modified: cfe/trunk/test/CodeGenCXX/temporaries.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/temporaries.cpp?rev=92131&r1=92130&r2=92131&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/temporaries.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/temporaries.cpp Thu Dec 24 11:16:46 2009
@@ -216,3 +216,22 @@
   // CHECK: ret void
   return "Hello";
 }
+
+// PR5867
+namespace PR5867 {
+  struct S {
+    S();
+    S(const S &);
+    ~S();
+  };
+
+  void f(S, int);
+  // CHECK: define void @_ZN6PR58671gEv
+  void g() {
+    // CHECK: call void @_ZN6PR58671SC1Ev
+    // CHECK-NEXT: call void @_ZN6PR58671fENS_1SEi
+    // CHECK-NEXT: call void @_ZN6PR58671SD1Ev
+    // CHECK-NEXT: ret void
+    (f)(S(), 0);
+  }
+}





More information about the cfe-commits mailing list