зеркало из https://github.com/microsoft/clang-1.git
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; }; {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43582 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
148fe67727
Коммит
8749be53f5
|
@ -33,6 +33,7 @@ namespace {
|
|||
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 @@ void RewriteTest::RewriteForwardClassDecl(ObjcClassDecl *ClassDecl) {
|
|||
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 @@ void RewriteTest::RewriteFunctionDecl(FunctionDecl *FD) {
|
|||
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 @@ void RewriteTest::SynthesizeObjcInternalStruct(ObjcInterfaceDecl *CDecl,
|
|||
}
|
||||
else
|
||||
Result += " {";
|
||||
|
||||
if (NumIvars > 0) {
|
||||
SourceLocation LocStart = CDecl->getLocStart();
|
||||
SourceLocation LocEnd = CDecl->getLocEnd();
|
||||
|
@ -595,7 +602,7 @@ void RewriteTest::SynthesizeObjcInternalStruct(ObjcInterfaceDecl *CDecl,
|
|||
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
|
||||
|
|
|
@ -740,11 +740,11 @@ void Parser::ParseObjCClassInstanceVariables(DeclTy *interfaceDecl,
|
|||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче