diff options
| author | Steve Naroff <snaroff@apple.com> | 2008-05-06 18:26:51 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2008-05-06 18:26:51 +0000 |
| commit | 13e74879b05676ebf0326817e468823428c853d1 (patch) | |
| tree | ea118e5e2cc58a52531450aa0fd98a3cad67a2cc /clang | |
| parent | eeac27e38c5c567d63bbfa5410620d955696491b (diff) | |
| download | bcm5719-llvm-13e74879b05676ebf0326817e468823428c853d1.tar.gz bcm5719-llvm-13e74879b05676ebf0326817e468823428c853d1.zip | |
Fix <rdar://problem/5881225> clang ObjC Rewriter: Protocol structure defined twice when two interfaces use it in same file
llvm-svn: 50767
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/Driver/RewriteObjC.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/Driver/RewriteObjC.cpp b/clang/Driver/RewriteObjC.cpp index 8cf98a16436..66f98a41c57 100644 --- a/clang/Driver/RewriteObjC.cpp +++ b/clang/Driver/RewriteObjC.cpp @@ -50,6 +50,7 @@ namespace { 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 @@ void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl, } // 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 @@ void RewriteObjC::RewriteObjCProtocolsMetaData(ObjCProtocolDecl **Protocols, 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 @@ void RewriteObjC::RewriteObjCProtocolsMetaData(ObjCProtocolDecl **Protocols, } Result += "\t }\n};\n"; } + // Output: /* struct _objc_protocol { // Objective-C 1.0 extensions @@ -2511,6 +2517,10 @@ void RewriteObjC::RewriteObjCProtocolsMetaData(ObjCProtocolDecl **Protocols, 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 { |

