[cfe-commits] r147421 - in /cfe/trunk/lib: AST/ASTContext.cpp Rewrite/RewriteObjC.cpp
Douglas Gregor
dgregor at apple.com
Sun Jan 1 18:00:30 PST 2012
Author: dgregor
Date: Sun Jan 1 20:00:30 2012
New Revision: 147421
URL: http://llvm.org/viewvc/llvm-project?rev=147421&view=rev
Log:
Fix canonicalization of protocol-qualified types
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Rewrite/RewriteObjC.cpp
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=147421&r1=147420&r2=147421&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sun Jan 1 20:00:30 2012
@@ -2710,8 +2710,12 @@
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 @@
// 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;
Modified: cfe/trunk/lib/Rewrite/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteObjC.cpp?rev=147421&r1=147420&r2=147421&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteObjC.cpp Sun Jan 1 20:00:30 2012
@@ -990,7 +990,8 @@
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 @@
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());
More information about the cfe-commits
mailing list