[cfe-commits] r43582 - in /cfe/trunk: Driver/RewriteTest.cpp Parse/ParseObjc.cpp
Steve Naroff
snaroff at apple.com
Wed Oct 31 15:11:36 PDT 2007
Author: snaroff
Date: Wed Oct 31 17:11:35 2007
New Revision: 43582
URL: http://llvm.org/viewvc/llvm-project?rev=43582&view=rev
Log:
Fix two rewriter bugs:
- For @class, don't generate multiple typedefs.
- Handle the following edge case interface...
@interface NSMiddleSpecifier : NSObject {}
@end
..which was incorrectly being rewritten to...
struct _interface_NSMiddleSpecifier {
struct _interface_NSObject _NSObject;
};
{}
Modified:
cfe/trunk/Driver/RewriteTest.cpp
cfe/trunk/Parse/ParseObjc.cpp
Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=43582&r1=43581&r2=43582&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Wed Oct 31 17:11:35 2007
@@ -33,6 +33,7 @@
llvm::SmallVector<ObjcImplementationDecl *, 8> ClassImplementation;
llvm::SmallVector<ObjcCategoryImplDecl *, 8> CategoryImplementation;
llvm::SmallPtrSet<ObjcInterfaceDecl*, 8> ObjcSynthesizedStructs;
+ llvm::SmallPtrSet<ObjcInterfaceDecl*, 8> ObjcForwardDecls;
FunctionDecl *MsgSendFunctionDecl;
FunctionDecl *GetClassFunctionDecl;
@@ -260,11 +261,17 @@
typedefString += "\n";
for (int i = 0; i < numDecls; i++) {
ObjcInterfaceDecl *ForwardDecl = ForwardDecls[i];
+ if (ObjcForwardDecls.count(ForwardDecl))
+ continue;
typedefString += "typedef struct ";
typedefString += ForwardDecl->getName();
typedefString += " ";
typedefString += ForwardDecl->getName();
typedefString += ";\n";
+
+ // Mark this typedef as having been generated.
+ if (!ObjcForwardDecls.insert(ForwardDecl))
+ assert(true && "typedef already output");
}
// Replace the @class with typedefs corresponding to the classes.
@@ -437,7 +444,6 @@
SelGetUidFunctionDecl = FD;
return;
}
- return; // FIXME: remove when the code below is ready.
// Check for ObjC 'id' and class types that have been adorned with protocol
// information (id<p>, C<p>*). The protocol references need to be rewritten!
const FunctionType *funcType = FD->getType()->getAsFunctionType();
@@ -560,6 +566,7 @@
}
else
Result += " {";
+
if (NumIvars > 0) {
SourceLocation LocStart = CDecl->getLocStart();
SourceLocation LocEnd = CDecl->getLocEnd();
@@ -595,7 +602,7 @@
Result += "};\n";
// Mark this struct as having been generated.
if (!ObjcSynthesizedStructs.insert(CDecl))
- assert(true && "struct already synthesize- SynthesizeObjcInternalStruct");
+ assert(true && "struct already synthesize- SynthesizeObjcInternalStruct");
}
// RewriteObjcMethodsMetaData - Rewrite methods metadata for instance or
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=43582&r1=43581&r2=43582&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Wed Oct 31 17:11:35 2007
@@ -740,11 +740,11 @@
}
}
SourceLocation RBraceLoc = MatchRHSPunctuation(tok::r_brace, LBraceLoc);
- if (AllIvarDecls.size()) { // Check for {} - no ivars in braces
- Actions.ActOnFields(CurScope, atLoc, interfaceDecl,
- &AllIvarDecls[0], AllIvarDecls.size(),
- LBraceLoc, RBraceLoc, &AllVisibilities[0]);
- }
+ // Call ActOnFields() even if we don't have any decls. This is useful
+ // for code rewriting tools that need to be aware of the empty list.
+ Actions.ActOnFields(CurScope, atLoc, interfaceDecl,
+ &AllIvarDecls[0], AllIvarDecls.size(),
+ LBraceLoc, RBraceLoc, &AllVisibilities[0]);
return;
}
More information about the cfe-commits
mailing list