forked from OSchip/llvm-project
Fix canonicalization of protocol-qualified types
llvm-svn: 147421
This commit is contained in:
parent
1bd9617671
commit
cf9f3ea6f9
|
@ -2710,8 +2710,12 @@ static bool areSortedAndUniqued(ObjCProtocolDecl * const *Protocols,
|
|||
unsigned NumProtocols) {
|
||||
if (NumProtocols == 0) return true;
|
||||
|
||||
if (Protocols[0]->getCanonicalDecl() != Protocols[0])
|
||||
return false;
|
||||
|
||||
for (unsigned i = 1; i != NumProtocols; ++i)
|
||||
if (!CmpProtocolNames(Protocols[i-1], Protocols[i]))
|
||||
if (!CmpProtocolNames(Protocols[i-1], Protocols[i]) ||
|
||||
Protocols[i]->getCanonicalDecl() != Protocols[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -2723,6 +2727,10 @@ static void SortAndUniqueProtocols(ObjCProtocolDecl **Protocols,
|
|||
// Sort protocols, keyed by name.
|
||||
std::sort(Protocols, Protocols+NumProtocols, CmpProtocolNames);
|
||||
|
||||
// Canonicalize.
|
||||
for (unsigned I = 0, N = NumProtocols; I != N; ++I)
|
||||
Protocols[I] = Protocols[I]->getCanonicalDecl();
|
||||
|
||||
// Remove duplicates.
|
||||
ProtocolsEnd = std::unique(Protocols, ProtocolsEnd);
|
||||
NumProtocols = ProtocolsEnd-Protocols;
|
||||
|
|
|
@ -990,7 +990,8 @@ void RewriteObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) {
|
|||
|
||||
void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
|
||||
SourceLocation LocStart = PDecl->getLocStart();
|
||||
|
||||
assert(PDecl->isThisDeclarationADefinition());
|
||||
|
||||
// FIXME: handle protocol headers that are declared across multiple lines.
|
||||
ReplaceText(LocStart, 0, "// ");
|
||||
|
||||
|
@ -5223,6 +5224,9 @@ void RewriteObjCFragileABI::RewriteObjCProtocolMetaData(
|
|||
if (ObjCSynthesizedProtocols.count(PDecl->getCanonicalDecl()))
|
||||
return;
|
||||
|
||||
if (ObjCProtocolDecl *Def = PDecl->getDefinition())
|
||||
PDecl = Def;
|
||||
|
||||
if (PDecl->instmeth_begin() != PDecl->instmeth_end()) {
|
||||
unsigned NumMethods = std::distance(PDecl->instmeth_begin(),
|
||||
PDecl->instmeth_end());
|
||||
|
|
Loading…
Reference in New Issue