[cfe-commits] r68177 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenTypes.cpp lib/CodeGen/CodeGenTypes.h test/CodeGenObjC/class-type.m test/CodeGenObjC/forward-class-impl-metadata.m
Chris Lattner
sabre at nondot.org
Tue Mar 31 19:36:43 PDT 2009
Author: lattner
Date: Tue Mar 31 21:36:43 2009
New Revision: 68177
URL: http://llvm.org/viewvc/llvm-project?rev=68177&view=rev
Log:
fix the two xfails I added with a previous patch by making ObjC interface
types get completed when their definition is seen if previously laid out by
the code generator.
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.h
cfe/trunk/test/CodeGenObjC/class-type.m
cfe/trunk/test/CodeGenObjC/forward-class-impl-metadata.m
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=68177&r1=68176&r2=68177&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Mar 31 21:36:43 2009
@@ -1242,9 +1242,13 @@
case Decl::ObjCClass:
case Decl::ObjCForwardProtocol:
case Decl::ObjCCategory:
+ break;
case Decl::ObjCInterface:
+ // If we already laid out this interface due to an @class, and if we
+ // codegen'd a reference it, update the 'opaque' type to be a real type now.
+ Types.UpdateCompletedType(cast<ObjCInterfaceDecl>(D));
break;
-
+
case Decl::ObjCProtocol:
Runtime->GenerateProtocol(cast<ObjCProtocolDecl>(D));
break;
@@ -1252,7 +1256,6 @@
case Decl::ObjCCategoryImpl:
// Categories have properties but don't support synthesize so we
// can ignore them here.
-
Runtime->GenerateCategory(cast<ObjCCategoryImplDecl>(D));
break;
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=68177&r1=68176&r2=68177&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Tue Mar 31 21:36:43 2009
@@ -197,6 +197,40 @@
}
}
+void CodeGenTypes::UpdateCompletedType(const ObjCInterfaceDecl *OID) {
+ // Check to see if we have already laid this type out, if not, just return.
+ QualType OIDTy =
+ Context.getObjCInterfaceType(const_cast<ObjCInterfaceDecl*>(OID));
+ llvm::DenseMap<Type *, llvm::PATypeHolder>::iterator TCI =
+ TypeCache.find(OIDTy.getTypePtr());
+ if (TCI == TypeCache.end()) return;
+
+ // Remember the opaque LLVM type for this interface.
+ llvm::PATypeHolder OpaqueHolder = TCI->second;
+ assert(isa<llvm::OpaqueType>(OpaqueHolder.get()) &&
+ "Updating compilation of an already non-opaque type?");
+
+ // Remove it from TagDeclTypes so that it will be regenerated.
+ TypeCache.erase(TCI);
+
+ // Update the "shadow" struct that is laid out.
+ // FIXME: REMOVE THIS.
+ const RecordDecl *RD = Context.addRecordToClass(OID);
+ UpdateCompletedType(RD);
+
+ // Generate the new type.
+ const llvm::Type *NT = ConvertType(OIDTy);
+ assert(!isa<llvm::OpaqueType>(NT) && "Didn't do layout!");
+
+ // FIXME: Remove this check when shadow structs go away.
+ if (isa<llvm::OpaqueType>(OpaqueHolder)) {
+
+ // Refine the old opaque type to its new definition.
+ cast<llvm::OpaqueType>(OpaqueHolder.get())->refineAbstractTypeTo(NT);
+ }
+}
+
+
static const llvm::Type* getTypeForFormat(const llvm::fltSemantics &format) {
if (&format == &llvm::APFloat::IEEEsingle)
return llvm::Type::FloatTy;
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=68177&r1=68176&r2=68177&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Tue Mar 31 21:36:43 2009
@@ -161,6 +161,8 @@
/// UpdateCompletedType - When we find the full definition for a TagDecl,
/// replace the 'opaque' type we previously made for it if applicable.
void UpdateCompletedType(const TagDecl *TD);
+ /// Likewise for an ObjC Interface.
+ void UpdateCompletedType(const ObjCInterfaceDecl *OID);
/// getFunctionInfo - Get the CGFunctionInfo for this function signature.
const CGFunctionInfo &getFunctionInfo(QualType RetTy,
Modified: cfe/trunk/test/CodeGenObjC/class-type.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/class-type.m?rev=68177&r1=68176&r2=68177&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/class-type.m (original)
+++ cfe/trunk/test/CodeGenObjC/class-type.m Tue Mar 31 21:36:43 2009
@@ -1,5 +1,4 @@
// RUN: clang-cc -triple x86_64-unknown-unknown -emit-llvm -o %t %s
-// XFAIL: *
@interface I0 {
struct { int a; } a;
Modified: cfe/trunk/test/CodeGenObjC/forward-class-impl-metadata.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/forward-class-impl-metadata.m?rev=68177&r1=68176&r2=68177&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/forward-class-impl-metadata.m (original)
+++ cfe/trunk/test/CodeGenObjC/forward-class-impl-metadata.m Tue Mar 31 21:36:43 2009
@@ -1,5 +1,4 @@
// RUN: clang-cc -triple x86_64-unknown-unknown -emit-llvm -o %t %s
-// XFAIL: *
@interface BASE {
@private
More information about the cfe-commits
mailing list