]> granicus.if.org Git - clang/commitdiff
Find copy constructor needed to copy an rvalue reference
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 1 Nov 2011 18:57:34 +0000 (18:57 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 1 Nov 2011 18:57:34 +0000 (18:57 +0000)
c++ object into block descriptor. // rdar://9971124

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143475 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/CodeGenCXX/block-rvalue-reference-capture.cpp

index 61766a88c07f546e816bb097b3b1abcdbaf6efb2..d4d08703d3a2c454589b0053fd73f5f081d466ff 100644 (file)
@@ -1304,7 +1304,10 @@ static CaptureResult shouldCaptureValueReference(Sema &S, SourceLocation loc,
   // 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);
index df99e42177d4f389d94fdb79ff3761ff53fe7962..997e14f8518f8079f0bba1be7e166dd46a4b7dfd 100644 (file)
@@ -14,3 +14,18 @@ int main() {
 // 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_