[cfe-commits] r103022 - in /cfe/trunk: lib/CodeGen/CGBlocks.cpp test/CodeGenCXX/reference-in-blocks.cpp
Fariborz Jahanian
fjahanian at apple.com
Tue May 4 10:59:32 PDT 2010
Author: fjahanian
Date: Tue May 4 12:59:32 2010
New Revision: 103022
URL: http://llvm.org/viewvc/llvm-project?rev=103022&view=rev
Log:
Fixes a code gen crash when block is a reference type, etc.
(radar 7495203).
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/test/CodeGenCXX/reference-in-blocks.cpp
Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=103022&r1=103021&r2=103022&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue May 4 12:59:32 2010
@@ -532,6 +532,8 @@
V = Builder.CreateBitCast(V, PtrStructTy);
V = Builder.CreateStructGEP(V, getByRefValueLLVMField(VD),
VD->getNameAsString());
+ if (VD->getType()->isReferenceType())
+ V = Builder.CreateLoad(V);
} else {
const llvm::Type *Ty = CGM.getTypes().ConvertType(VD->getType());
Modified: cfe/trunk/test/CodeGenCXX/reference-in-blocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/reference-in-blocks.cpp?rev=103022&r1=103021&r2=103022&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/reference-in-blocks.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/reference-in-blocks.cpp Tue May 4 12:59:32 2010
@@ -9,6 +9,26 @@
T get() {return _i;};
};
+// rdar: // 7495203
+class A {
+ public:
+ A() : field(10), d1(3.14) {}
+ void F();
+ void S() {
+ printf(" field = %d\n", field);
+ printf(" field = %f\n", d1);
+ }
+ int field;
+ double d1;
+};
+
+void A::F()
+ {
+ __block A &tlc = *this;
+ // crashed in code gen (radar 7495203)
+ ^{ tlc.S(); }();
+ }
+
int main() {
// works
@@ -16,6 +36,8 @@
//crashes in godegen?
void (^bl2)(range<int>& ) = ^(range<int>& i){printf("Hello Blocks %d\n", i.get()); };
+
+ A *a = new A;
+ a->F();
return 0;
}
-
More information about the cfe-commits
mailing list