[cfe-commits] r64664 - /cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp
Steve Naroff
snaroff at apple.com
Mon Feb 16 11:52:35 PST 2009
Author: snaroff
Date: Mon Feb 16 13:52:34 2009
New Revision: 64664
URL: http://llvm.org/viewvc/llvm-project?rev=64664&view=rev
Log:
More fun and games related to <rdar://problem/6562121> clang ObjC rewriter: @protocol(foo) returns nil.
Still a little more work to do...
Modified:
cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp
Modified: cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp?rev=64664&r1=64663&r2=64664&view=diff
==============================================================================
--- cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp (original)
+++ cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp Mon Feb 16 13:52:34 2009
@@ -60,7 +60,7 @@
llvm::SmallVector<Stmt *, 32> Stmts;
llvm::SmallVector<int, 8> ObjCBcLabelNo;
// Remember all the @protocol(<expr>) expressions.
- llvm::SmallVector<ObjCProtocolDecl *, 32> ProtocolExprDecls;
+ llvm::SmallPtrSet<ObjCProtocolDecl *, 32> ProtocolExprDecls;
unsigned NumObjCStringLiterals;
@@ -2587,7 +2587,7 @@
&ProtoExprs[0],
ProtoExprs.size());
ReplaceStmt(Exp, ProtoExp);
- ProtocolExprDecls.push_back(Exp->getProtocol());
+ ProtocolExprDecls.insert(Exp->getProtocol());
// delete Exp; leak for now, see RewritePropertySetter() usage for more info.
return ProtoExp;
@@ -2940,7 +2940,7 @@
objc_protocol = true;
}
- Result += "\nstatic struct _objc_protocol _OBJC_PROTOCOL_";
+ Result += "\nstruct _objc_protocol _OBJC_PROTOCOL_";
Result += PDecl->getNameAsString();
Result += " __attribute__ ((used, section (\"__OBJC, __protocol\")))= "
"{\n\t0, \"";
@@ -3386,11 +3386,10 @@
RewriteObjCCategoryImplDecl(CategoryImplementation[i], Result);
// Write out meta data for each @protocol(<expr>).
- if (unsigned int nProtoExprs = ProtocolExprDecls.size()) {
- for (unsigned int i = 0; i < nProtoExprs; i++)
- RewriteObjCProtocolMetaData(ProtocolExprDecls[i], "", "", Result);
+ for (llvm::SmallPtrSet<ObjCProtocolDecl *,8>::iterator I = ProtocolExprDecls.begin(),
+ E = ProtocolExprDecls.end(); I != E; ++I) {
+ RewriteObjCProtocolMetaData(*I, "", "", Result);
}
-
// Write objc_symtab metadata
/*
struct _objc_symtab
@@ -4546,6 +4545,15 @@
RewriteInclude();
+ // Here's a great place to add any extra declarations that may be needed.
+ // Write out meta data for each @protocol(<expr>).
+ for (llvm::SmallPtrSet<ObjCProtocolDecl *,8>::iterator I = ProtocolExprDecls.begin(),
+ E = ProtocolExprDecls.end(); I != E; ++I) {
+ Preamble += "\nextern struct _objc_protocol _OBJC_PROTOCOL_";
+ Preamble += (*I)->getNameAsString();
+ Preamble += ";\n";
+ }
+
InsertText(SM->getLocForStartOfFile(MainFileID),
Preamble.c_str(), Preamble.size(), false);
More information about the cfe-commits
mailing list