Fix rdar://6804402 - crash on objc implementations declared with
@class but no implementation. This was broken in all 3 runtime
impls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69512 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index cd94290..f7936fd 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -739,8 +739,12 @@
// Get the size of instances. For runtimes that support late-bound instances
// this should probably be something different (size just of instance
// varaibles in this class, not superclasses?).
- const llvm::Type *ObjTy =
- CGM.getTypes().ConvertType(Context.getObjCInterfaceType(ClassDecl));
+ const llvm::Type *ObjTy;
+
+ if (ClassDecl->isForwardDecl())
+ ObjTy = llvm::StructType::get(NULL, NULL);
+ else
+ ObjTy = CGM.getTypes().ConvertType(Context.getObjCInterfaceType(ClassDecl));
int instanceSize = CGM.getTargetData().getTypePaddedSize(ObjTy);
// Collect information about instance variables.