[cfe-commits] r166809 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGenObjCXX/implementation-in-extern-c.mm
Fariborz Jahanian
fjahanian at apple.com
Fri Oct 26 13:22:11 PDT 2012
Author: fjahanian
Date: Fri Oct 26 15:22:11 2012
New Revision: 166809
URL: http://llvm.org/viewvc/llvm-project?rev=166809&view=rev
Log:
objective-C IRGen: for @implementation nested in
extern "C", its method definitions must be IRGen'ed
before meta-data for class is generated. Otherwise,
IRGen crashes (to say the least).
// rdar://12581683
Added:
cfe/trunk/test/CodeGenObjCXX/implementation-in-extern-c.mm
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=166809&r1=166808&r2=166809&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Oct 26 15:22:11 2012
@@ -2582,8 +2582,15 @@
}
for (RecordDecl::decl_iterator I = LSD->decls_begin(), E = LSD->decls_end();
- I != E; ++I)
+ I != E; ++I) {
+ if (ObjCImplDecl *OID = dyn_cast<ObjCImplDecl>(*I)) {
+ for (ObjCContainerDecl::method_iterator M = OID->meth_begin(),
+ MEnd = OID->meth_end();
+ M != MEnd; ++M)
+ EmitTopLevelDecl(*M);
+ }
EmitTopLevelDecl(*I);
+ }
}
/// EmitTopLevelDecl - Emit code for a single top level declaration.
Added: cfe/trunk/test/CodeGenObjCXX/implementation-in-extern-c.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/implementation-in-extern-c.mm?rev=166809&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/implementation-in-extern-c.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/implementation-in-extern-c.mm Fri Oct 26 15:22:11 2012
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+// rdar://12581683
+
+extern "C" {
+ at interface RetainBucket
++ (id) sharedRetainBucket;
+ at end
+
+ at implementation RetainBucket
++ (id) sharedRetainBucket
+{
+ static id sharedBucket = (id)0;
+ return sharedBucket;
+}
+ at end
+}
+
More information about the cfe-commits
mailing list