[cfe-commits] r59259 - /cfe/trunk/Driver/RewriteObjC.cpp
Steve Naroff
snaroff at apple.com
Thu Nov 13 12:07:05 PST 2008
Author: snaroff
Date: Thu Nov 13 14:07:04 2008
New Revision: 59259
URL: http://llvm.org/viewvc/llvm-project?rev=59259&view=rev
Log:
Fix an obscure rewriter bug when rewriting implementations that don't have a corresponding interface (found while doing random testing on another bug).
Modified:
cfe/trunk/Driver/RewriteObjC.cpp
Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=59259&r1=59258&r2=59259&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Thu Nov 13 14:07:04 2008
@@ -245,7 +245,8 @@
void SynthesizeIvarOffsetComputation(ObjCImplementationDecl *IDecl,
ObjCIvarDecl *ivar,
std::string &Result);
- void RewriteImplementations(std::string &Result);
+ void RewriteImplementations();
+ void SynthesizeMetaDataIntoBuffer(std::string &Result);
// Block rewriting.
void RewriteBlocksInFunctionTypeProto(QualType funcType, NamedDecl *D);
@@ -836,7 +837,7 @@
InsertText(IMD->getLocStart(), "// ", 3);
else
InsertText(CID->getLocStart(), "// ", 3);
-
+
for (ObjCCategoryImplDecl::instmeth_iterator
I = IMD ? IMD->instmeth_begin() : CID->instmeth_begin(),
E = IMD ? IMD->instmeth_end() : CID->instmeth_end(); I != E; ++I) {
@@ -3071,7 +3072,7 @@
/// RewriteImplementations - This routine rewrites all method implementations
/// and emits meta-data.
-void RewriteObjC::RewriteImplementations(std::string &Result) {
+void RewriteObjC::RewriteImplementations() {
int ClsDefCount = ClassImplementation.size();
int CatDefCount = CategoryImplementation.size();
@@ -3083,7 +3084,12 @@
for (int i = 0; i < CatDefCount; i++)
RewriteImplementationDecl(CategoryImplementation[i]);
+}
+void RewriteObjC::SynthesizeMetaDataIntoBuffer(std::string &Result) {
+ int ClsDefCount = ClassImplementation.size();
+ int CatDefCount = CategoryImplementation.size();
+
// This is needed for determining instance variable offsets.
Result += "\n#define __OFFSETOFIVAR__(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)\n";
// For each implemented class, write out all its meta data.
@@ -4125,9 +4131,7 @@
InsertText(SourceLocation::getFileLoc(MainFileID, 0),
Preamble.c_str(), Preamble.size(), false);
- // Rewrite Objective-c meta data*
- std::string ResultStr;
- RewriteImplementations(ResultStr);
+ RewriteImplementations();
// Get the buffer corresponding to MainFileID. If we haven't changed it, then
// we are done.
@@ -4138,6 +4142,11 @@
} else {
fprintf(stderr, "No changes\n");
}
+
+ // Rewrite Objective-c meta data*
+ std::string ResultStr;
+ SynthesizeMetaDataIntoBuffer(ResultStr);
+
// Emit metadata.
*OutFile << ResultStr;
OutFile->flush();
More information about the cfe-commits
mailing list