summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-02 02:00:30 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-02 02:00:30 +0000
commitcf9f3ea6f969e0ac8fcc7af06d0ae7e511363411 (patch)
tree2cee59c17b8c23b37eff1f8498eabe6b3ea6e9fb
parent1bd96176717fc2e5edcc5e41a7a167c9401abd00 (diff)
downloadbcm5719-llvm-cf9f3ea6f969e0ac8fcc7af06d0ae7e511363411.tar.gz
bcm5719-llvm-cf9f3ea6f969e0ac8fcc7af06d0ae7e511363411.zip
Fix canonicalization of protocol-qualified types
llvm-svn: 147421
-rw-r--r--clang/lib/AST/ASTContext.cpp10
-rw-r--r--clang/lib/Rewrite/RewriteObjC.cpp6
2 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index a990989b20f..514a013e938 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -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;
diff --git a/clang/lib/Rewrite/RewriteObjC.cpp b/clang/lib/Rewrite/RewriteObjC.cpp
index 19277e8ea45..5cf1b11ad9a 100644
--- a/clang/lib/Rewrite/RewriteObjC.cpp
+++ b/clang/lib/Rewrite/RewriteObjC.cpp
@@ -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());
OpenPOWER on IntegriCloud