diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-03-14 21:44:09 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-03-14 21:44:09 +0000 |
commit | ddddca3e6d6559d8a9f1af476b82bf9bb0a90cef (patch) | |
tree | 483a3d01b6e90e3fa7f94a9f4436f0eb44025233 | |
parent | 3a0f57057ef0e96dc7998a3971b29f940fa12d1a (diff) | |
download | bcm5719-llvm-ddddca3e6d6559d8a9f1af476b82bf9bb0a90cef.tar.gz bcm5719-llvm-ddddca3e6d6559d8a9f1af476b82bf9bb0a90cef.zip |
objective-c modern tranaltor. More section info.
for misc. objc meta-data.
llvm-svn: 152743
-rw-r--r-- | clang/lib/Rewrite/RewriteModernObjC.cpp | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/clang/lib/Rewrite/RewriteModernObjC.cpp b/clang/lib/Rewrite/RewriteModernObjC.cpp index 13365f1ce73..4fe535922e8 100644 --- a/clang/lib/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Rewrite/RewriteModernObjC.cpp @@ -382,6 +382,7 @@ namespace { virtual void RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl, std::string &Result); virtual void RewriteMetaDataIntoBuffer(std::string &Result); + virtual void WriteImageInfo(std::string &Result); virtual void RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *CDecl, std::string &Result); @@ -5001,6 +5002,12 @@ void RewriteModernObjC::HandleTranslationUnit(ASTContext &C) { // Emit metadata. *OutFile << ResultStr; } + // Emit ImageInfo; + { + std::string ResultStr; + WriteImageInfo(ResultStr); + *OutFile << ResultStr; + } OutFile->flush(); } @@ -5020,10 +5027,25 @@ void RewriteModernObjC::Initialize(ASTContext &context) { Preamble += "struct objc_object *superClass; "; if (LangOpts.MicrosoftExt) { // Define all sections using syntax that makes sense. - Preamble += "\n#pragma section(\".datacoal_nt$B\", long, read, write)\n"; - Preamble += "#pragma section(\".cat_cls_meth$B\", long, read, write)\n"; - Preamble += "#pragma section(\".objc_classlist$B\", long, read, write)\n"; + // These are currently generated. + Preamble += "\n#pragma section(\".objc_classlist$B\", long, read, write)\n"; Preamble += "#pragma section(\".objc_catlist$B\", long, read, write)\n"; + Preamble += "#pragma section(\".objc_protolist$B\", long, read, write)\n"; + Preamble += "#pragma section(\".objc_imageinfo$B\", long, read, write)\n"; + + // These need be generated. But they are not,using API calls instead. + Preamble += "#pragma section(\".objc_selrefs$B\", long, read, write)\n"; + Preamble += "#pragma section(\".objc_classrefs$B\", long, read, write)\n"; + Preamble += "#pragma section(\".objc_superrefs$B\", long, read, write)\n"; + + Preamble += "#pragma section(\".objc_nlclslist$B\", long, read, write)\n"; + Preamble += "#pragma section(\".objc_nlcatlist$B\", long, read, write)\n"; + Preamble += "#pragma section(\".objc_protorefs$B\", long, read, write)\n"; + + + // These are generated but not necessary for functionality. + Preamble += "#pragma section(\".datacoal_nt$B\", long, read, write)\n"; + Preamble += "#pragma section(\".cat_cls_meth$B\", long, read, write)\n"; Preamble += "#pragma section(\".inst_meth$B\", long, read, write)\n"; Preamble += "#pragma section(\".cls_meth$B\", long, read, write)\n"; Preamble += "#pragma section(\".objc_ivar$B\", long, read, write)\n"; @@ -5951,6 +5973,16 @@ void RewriteModernObjC::RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl, } else Result += "\t0\n};\n"; + + // Use this protocol meta-data to build protocol list table in section + // .objc_protolist$B + // Unspecified visibility means 'private extern'. + if (LangOpts.MicrosoftExt) + Result += "__declspec(allocate(\".objc_protolist$B\")) "; + Result += "struct _protocol_t *"; + Result += "_OBJC_LABEL_PROTOCOL_$_"; Result += PDecl->getNameAsString(); + Result += " = &_OBJC_PROTOCOL_"; Result += PDecl->getNameAsString(); + Result += ";\n"; // Mark this protocol as having been generated. if (!ObjCSynthesizedProtocols.insert(PDecl->getCanonicalDecl())) @@ -6232,6 +6264,15 @@ void RewriteModernObjC::RewriteMetaDataIntoBuffer(std::string &Result) { } } +void RewriteModernObjC::WriteImageInfo(std::string &Result) { + if (LangOpts.MicrosoftExt) + Result += "__declspec(allocate(\".objc_imageinfo$B\")) \n"; + + Result += "static struct IMAGE_INFO { unsigned version; unsigned flag; } "; + // version 0, ObjCABI is 2 + Result += "_OBJC_IMAGE_INFO = { 0, 2 };\n"; +} + /// RewriteObjCCategoryImplDecl - Rewrite metadata for each category /// implementation. void RewriteModernObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl, |