[cfe-commits] r64563 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/class-type.m
Fariborz Jahanian
fjahanian at apple.com
Sat Feb 14 12:13:30 PST 2009
Author: fjahanian
Date: Sat Feb 14 14:13:28 2009
New Revision: 64563
URL: http://llvm.org/viewvc/llvm-project?rev=64563&view=rev
Log:
Fixed a problem caused by foreward @class use
which consequently caused a Seg fault. during meta-data
generation. It also addresses an issue related to
late binding of newly synthesize ivars (when we support it).
Added:
cfe/trunk/test/CodeGenObjC/class-type.m
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=64563&r1=64562&r2=64563&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Sat Feb 14 14:13:28 2009
@@ -263,6 +263,7 @@
/// specified typename decl.
QualType getTypedefType(TypedefDecl *Decl);
QualType getObjCInterfaceType(ObjCInterfaceDecl *Decl);
+ QualType buildObjCInterfaceType(ObjCInterfaceDecl *Decl);
QualType getTemplateTypeParmType(unsigned Depth, unsigned Index,
IdentifierInfo *Name = 0);
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=64563&r1=64562&r2=64563&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Feb 14 14:13:28 2009
@@ -1210,6 +1210,18 @@
return QualType(Decl->TypeForDecl, 0);
}
+/// buildObjCInterfaceType - Returns a new type for the interface
+/// declaration, regardless. It also removes any previously built
+/// record declaration so caller can rebuild it.
+QualType ASTContext::buildObjCInterfaceType(ObjCInterfaceDecl *Decl) {
+ const RecordDecl *&RD = ASTRecordForInterface[Decl];
+ if (RD)
+ RD = 0;
+ Decl->TypeForDecl = new(*this,8) ObjCInterfaceType(Type::ObjCInterface, Decl);
+ Types.push_back(Decl->TypeForDecl);
+ return QualType(Decl->TypeForDecl, 0);
+}
+
/// \brief Retrieve the template type parameter type for a template
/// parameter with the given depth, index, and (optionally) name.
QualType ASTContext::getTemplateTypeParmType(unsigned Depth, unsigned Index,
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=64563&r1=64562&r2=64563&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sat Feb 14 14:13:28 2009
@@ -1370,7 +1370,7 @@
Interface->protocol_begin(),
Interface->protocol_end());
const llvm::Type *InterfaceTy =
- CGM.getTypes().ConvertType(CGM.getContext().getObjCInterfaceType(Interface));
+ CGM.getTypes().ConvertType(CGM.getContext().buildObjCInterfaceType(Interface));
unsigned Flags = eClassFlags_Factory;
unsigned Size = CGM.getTargetData().getTypePaddedSize(InterfaceTy);
@@ -3717,7 +3717,7 @@
const_cast<ObjCInterfaceDecl*>(ID->getClassInterface())) {
// FIXME. Share this with the one in EmitIvarList.
const llvm::Type *InterfaceTy =
- CGM.getTypes().ConvertType(CGM.getContext().getObjCInterfaceType(OID));
+ CGM.getTypes().ConvertType(CGM.getContext().buildObjCInterfaceType(OID));
const llvm::StructLayout *Layout =
CGM.getTargetData().getStructLayout(cast<llvm::StructType>(InterfaceTy));
Added: cfe/trunk/test/CodeGenObjC/class-type.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/class-type.m?rev=64563&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/class-type.m (added)
+++ cfe/trunk/test/CodeGenObjC/class-type.m Sat Feb 14 14:13:28 2009
@@ -0,0 +1,24 @@
+// RUN: clang -triple x86_64-unknown-unknown -emit-llvm -o %t %s
+
+ at interface I0 {
+ struct { int a; } a;
+}
+ at end
+
+ at class I2;
+
+ at interface I1 {
+ I2 *_imageBrowser;
+}
+ at end
+
+ at implementation I1
+ at end
+
+ at interface I2 : I0
+ at end
+
+ at implementation I2
+ at end
+
+
More information about the cfe-commits
mailing list