[cfe-commits] r50767 - /cfe/trunk/Driver/RewriteObjC.cpp
Steve Naroff
snaroff at apple.com
Tue May 6 11:26:51 PDT 2008
Author: snaroff
Date: Tue May 6 13:26:51 2008
New Revision: 50767
URL: http://llvm.org/viewvc/llvm-project?rev=50767&view=rev
Log:
Fix <rdar://problem/5881225> clang ObjC Rewriter: Protocol structure defined twice when two interfaces use it in same file
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=50767&r1=50766&r2=50767&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Tue May 6 13:26:51 2008
@@ -50,6 +50,7 @@
llvm::SmallVector<ObjCImplementationDecl *, 8> ClassImplementation;
llvm::SmallVector<ObjCCategoryImplDecl *, 8> CategoryImplementation;
llvm::SmallPtrSet<ObjCInterfaceDecl*, 8> ObjCSynthesizedStructs;
+ llvm::SmallPtrSet<ObjCProtocolDecl*, 8> ObjCSynthesizedProtocols;
llvm::SmallPtrSet<ObjCInterfaceDecl*, 8> ObjCForwardDecls;
llvm::DenseMap<ObjCMethodDecl*, std::string> MethodInternalNames;
llvm::SmallVector<Stmt *, 32> Stmts;
@@ -2299,7 +2300,7 @@
}
// Mark this struct as having been generated.
if (!ObjCSynthesizedStructs.insert(CDecl))
- assert(false && "struct already synthesize- SynthesizeObjCInternalStruct");
+ assert(false && "struct already synthesize- SynthesizeObjCInternalStruct");
}
// RewriteObjCMethodsMetaData - Rewrite methods metadata for instance or
@@ -2399,6 +2400,10 @@
objc_protocol_methods = true;
}
+ // Do not synthesize the protocol more than once.
+ if (ObjCSynthesizedProtocols.count(PDecl))
+ continue;
+
if (PDecl->instmeth_begin() != PDecl->instmeth_end()) {
unsigned NumMethods = PDecl->getNumInstanceMethods();
/* struct _objc_protocol_method_list {
@@ -2467,6 +2472,7 @@
}
Result += "\t }\n};\n";
}
+
// Output:
/* struct _objc_protocol {
// Objective-C 1.0 extensions
@@ -2511,6 +2517,10 @@
else
Result += "0\n";
Result += "};\n";
+
+ // Mark this protocol as having been generated.
+ if (!ObjCSynthesizedProtocols.insert(PDecl))
+ assert(false && "protocol already synthesized");
}
// Output the top lovel protocol meta-data for the class.
/* struct _objc_protocol_list {
More information about the cfe-commits
mailing list