[cfe-commits] r90702 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/CodeGenCXX/elide-call-reference.cpp

Eli Friedman eli.friedman at gmail.com
Sun Dec 6 01:26:34 PST 2009


Author: efriedma
Date: Sun Dec  6 03:26:33 2009
New Revision: 90702

URL: http://llvm.org/viewvc/llvm-project?rev=90702&view=rev
Log:
Fix a slight oversight in computing whether a copy constructor is elidable.
Fixes PR5695.


Added:
    cfe/trunk/test/CodeGenCXX/elide-call-reference.cpp
Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Dec  6 03:26:33 2009
@@ -3369,8 +3369,10 @@
     if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
       if (ICE->getCastKind() == CastExpr::CK_NoOp)
         E = ICE->getSubExpr();
-    
-    if (isa<CallExpr>(E) || isa<CXXTemporaryObjectExpr>(E))
+
+    if (CallExpr *CE = dyn_cast<CallExpr>(E))
+      Elidable = !CE->getCallReturnType()->isReferenceType();
+    else if (isa<CXXTemporaryObjectExpr>(E))
       Elidable = true;
   }
 

Added: cfe/trunk/test/CodeGenCXX/elide-call-reference.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/elide-call-reference.cpp?rev=90702&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenCXX/elide-call-reference.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/elide-call-reference.cpp Sun Dec  6 03:26:33 2009
@@ -0,0 +1,11 @@
+// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s
+// PR5695
+
+struct A { A(const A&); ~A(); };
+A& a();
+void b() {
+  A x = a();
+}
+
+// CHECK: call void @_ZN1AC1ERKS_
+// CHECK: call void @_ZN1AD1Ev





More information about the cfe-commits mailing list