[cfe-commits] r143475 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/CodeGenCXX/block-rvalue-reference-capture.cpp
Fariborz Jahanian
fjahanian at apple.com
Tue Nov 1 11:57:34 PDT 2011
Author: fjahanian
Date: Tue Nov 1 13:57:34 2011
New Revision: 143475
URL: http://llvm.org/viewvc/llvm-project?rev=143475&view=rev
Log:
Find copy constructor needed to copy an rvalue reference
c++ object into block descriptor. // rdar://9971124
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGenCXX/block-rvalue-reference-capture.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=143475&r1=143474&r2=143475&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Nov 1 13:57:34 2011
@@ -1304,7 +1304,10 @@
// Okay, we descended all the way to the block that defines the variable.
// Actually try to capture it.
QualType type = var->getType();
-
+
+ if (type->isRValueReferenceType())
+ type = type->getPointeeType();
+
// Prohibit variably-modified types.
if (type->isVariablyModifiedType()) {
S.Diag(loc, diag::err_ref_vm_type);
Modified: cfe/trunk/test/CodeGenCXX/block-rvalue-reference-capture.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/block-rvalue-reference-capture.cpp?rev=143475&r1=143474&r2=143475&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/block-rvalue-reference-capture.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/block-rvalue-reference-capture.cpp Tue Nov 1 13:57:34 2011
@@ -14,3 +14,18 @@
// CHECK: [[C:%.*]] = getelementptr inbounds <{ {{.*}} i32 }>* [[B]]
// CHECK: [[R:%.*]] = load i32* [[C]], align 4
// CHECK: ret i32 [[R]]
+
+class S {
+public:
+ S (const S &);
+ S(int);
+ int field;
+};
+
+int func(S && rv)
+{
+ return ^{ return rv.field; }();
+}
+
+// CHECK: define i32 @_Z4funcO1S
+// CHECK: call void @_ZN1SC1ERKS_
More information about the cfe-commits
mailing list