summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-02-17 20:33:00 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-02-17 20:33:00 +0000
commit320c88afce13bdca7553b670f94f97993cb9a4cb (patch)
tree61d3f2a16f8c42818ffb24a7a8893ecb4ef6da71 /clang
parent132bea96ad7ad5b09e8426b7db18a63b12548542 (diff)
downloadbcm5719-llvm-320c88afce13bdca7553b670f94f97993cb9a4cb.tar.gz
bcm5719-llvm-320c88afce13bdca7553b670f94f97993cb9a4cb.zip
modern objc writer: more work for category metadata rewrite
and some cleanup. llvm-svn: 150839
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Rewrite/RewriteModernObjC.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/clang/lib/Rewrite/RewriteModernObjC.cpp b/clang/lib/Rewrite/RewriteModernObjC.cpp
index 3c9b97efd25..1c9bf6b056a 100644
--- a/clang/lib/Rewrite/RewriteModernObjC.cpp
+++ b/clang/lib/Rewrite/RewriteModernObjC.cpp
@@ -3219,8 +3219,19 @@ void RewriteModernObjC::RewriteImplementations() {
RewriteImplementationDecl(OIMP);
}
- for (int i = 0; i < CatDefCount; i++)
- RewriteImplementationDecl(CategoryImplementation[i]);
+ for (int i = 0; i < CatDefCount; i++) {
+ ObjCCategoryImplDecl *CIMP = CategoryImplementation[i];
+ ObjCInterfaceDecl *CDecl = CIMP->getClassInterface();
+ if (CDecl->isImplicitInterfaceDecl())
+ assert(false &&
+ "Legacy implicit interface rewriting not supported in moder abi");
+ // Write struct declaration for the class matching its ivar declarations.
+ // Note that for modern abi, this is postponed until implementation decl.
+ // because class extensions and the implementation might declare their own
+ // private ivars.
+ RewriteInterfaceDecl(CDecl);
+ RewriteImplementationDecl(CIMP);
+ }
}
void RewriteModernObjC::RewriteByRefString(std::string &ResultStr,
@@ -5480,8 +5491,6 @@ static void Write__class_ro_t_initializer(ASTContext *Context, std::string &Resu
ArrayRef<ObjCPropertyDecl *>Properties,
StringRef VarName,
StringRef ClassName) {
-
- WriteModernMetadataDeclarations(Result);
Result += "\nstatic struct _class_ro_t ";
Result += VarName; Result += ClassName;
Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
@@ -5540,7 +5549,6 @@ static void Write__class_ro_t_initializer(ASTContext *Context, std::string &Resu
static void Write_class_t(ASTContext *Context, std::string &Result,
StringRef VarName,
const ObjCInterfaceDecl *CDecl, bool metadata) {
- WriteModernMetadataDeclarations(Result);
if (metadata && !CDecl->getSuperClass()) {
// Need to handle a case of use of forward declaration.
@@ -5605,7 +5613,12 @@ static void Write_category_t(RewriteModernObjC &RewriteObj, ASTContext *Context,
ArrayRef<ObjCMethodDecl *> ClassMethods,
ArrayRef<ObjCProtocolDecl *> RefedProtocols,
ArrayRef<ObjCPropertyDecl *> ClassProperties) {
- WriteModernMetadataDeclarations(Result);
+ // must declare an extern class object in case this class is not implemented
+ // in this TU.
+ Result += "\nextern struct _class_t ";
+ Result += "OBJC_CLASS_$_"; Result += ClassName;
+ Result += ";\n";
+
Result += "\nstatic struct _category_t ";
Result += "_OBJC_$_CATEGORY_";
Result += ClassName; Result += "_$_"; Result += CatName;
@@ -6191,6 +6204,7 @@ void RewriteModernObjC::RewriteMetaDataIntoBuffer(std::string &Result) {
/// implementation.
void RewriteModernObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
std::string &Result) {
+ WriteModernMetadataDeclarations(Result);
ObjCInterfaceDecl *ClassDecl = IDecl->getClassInterface();
// Find category declaration for this implementation.
ObjCCategoryDecl *CDecl=0;
OpenPOWER on IntegriCloud