[cfe-commits] r95313 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGenCXX/temporaries.cpp
Anders Carlsson
andersca at mac.com
Thu Feb 4 09:32:58 PST 2010
Author: andersca
Date: Thu Feb 4 11:32:58 2010
New Revision: 95313
URL: http://llvm.org/viewvc/llvm-project?rev=95313&view=rev
Log:
When binding an lvalue to a reference, we always need to pop temporaries.
With this fix, and the other fixes committed today a make check-all with a clang-built LLVM now gives:
Expected Passes : 6933
Expected Failures : 46
Unsupported Tests : 40
Unexpected Failures: 27
which means that we pass 99.96% of all tests :) The resulting 27 tests are all LLVMC tests and seem to be because of differences in the clang and gcc drivers.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGenCXX/temporaries.cpp
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=95313&r1=95312&r2=95313&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Feb 4 11:32:58 2010
@@ -113,8 +113,16 @@
if (E->isLvalue(getContext()) == Expr::LV_Valid) {
// Emit the expr as an lvalue.
LValue LV = EmitLValue(E);
- if (LV.isSimple())
+ if (LV.isSimple()) {
+ if (ShouldDestroyTemporaries) {
+ // Pop temporaries.
+ while (LiveTemporaries.size() > OldNumLiveTemporaries)
+ PopCXXTemporary();
+ }
+
return RValue::get(LV.getAddress());
+ }
+
Val = EmitLoadOfLValue(LV, E->getType());
if (ShouldDestroyTemporaries) {
Modified: cfe/trunk/test/CodeGenCXX/temporaries.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/temporaries.cpp?rev=95313&r1=95312&r2=95313&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/temporaries.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/temporaries.cpp Thu Feb 4 11:32:58 2010
@@ -267,3 +267,24 @@
template A f2<int>(int);
}
+
+namespace T12 {
+
+struct A {
+ A();
+ ~A();
+ int f();
+};
+
+int& f(int);
+
+// CHECK: define void @_ZN3T121gEv
+void g() {
+ // CHECK: call void @_ZN3T121AC1Ev
+ // CHECK-NEXT: call i32 @_ZN3T121A1fEv(
+ // CHECK-NEXT: call i32* @_ZN3T121fEi(
+ // CHECK-NEXT: call void @_ZN3T121AD1Ev(
+ int& i = f(A().f());
+}
+
+}
More information about the cfe-commits
mailing list