@@ -453,15 +453,6 @@ struct TargetFinder {
453
453
void VisitObjCInterfaceType (const ObjCInterfaceType *OIT) {
454
454
Outer.add (OIT->getDecl (), Flags);
455
455
}
456
- void VisitObjCObjectType (const ObjCObjectType *OOT) {
457
- // Make all of the protocols targets since there's no child nodes for
458
- // protocols. This isn't needed for the base type, which *does* have a
459
- // child `ObjCInterfaceTypeLoc`. This structure is a hack, but it works
460
- // well for go-to-definition.
461
- unsigned NumProtocols = OOT->getNumProtocols ();
462
- for (unsigned I = 0 ; I < NumProtocols; I++)
463
- Outer.add (OOT->getProtocol (I), Flags);
464
- }
465
456
};
466
457
Visitor (*this , Flags).Visit (T.getTypePtr ());
467
458
}
@@ -547,6 +538,8 @@ allTargetDecls(const DynTypedNode &N, const HeuristicResolver *Resolver) {
547
538
Finder.add (TAL->getArgument (), Flags);
548
539
else if (const CXXBaseSpecifier *CBS = N.get <CXXBaseSpecifier>())
549
540
Finder.add (CBS->getTypeSourceInfo ()->getType (), Flags);
541
+ else if (const ObjCProtocolLoc *PL = N.get <ObjCProtocolLoc>())
542
+ Finder.add (PL->getProtocol (), Flags);
550
543
return Finder.takeDecls ();
551
544
}
552
545
@@ -669,25 +662,7 @@ llvm::SmallVector<ReferenceLoc> refInDecl(const Decl *D,
669
662
{OMD}});
670
663
}
671
664
672
- void visitProtocolList (
673
- llvm::iterator_range<ObjCProtocolList::iterator> Protocols,
674
- llvm::iterator_range<const SourceLocation *> Locations) {
675
- for (const auto &P : llvm::zip (Protocols, Locations)) {
676
- Refs.push_back (ReferenceLoc{NestedNameSpecifierLoc (),
677
- std::get<1 >(P),
678
- /* IsDecl=*/ false ,
679
- {std::get<0 >(P)}});
680
- }
681
- }
682
-
683
- void VisitObjCInterfaceDecl (const ObjCInterfaceDecl *OID) {
684
- if (OID->isThisDeclarationADefinition ())
685
- visitProtocolList (OID->protocols (), OID->protocol_locs ());
686
- Base::VisitObjCInterfaceDecl (OID); // Visit the interface's name.
687
- }
688
-
689
665
void VisitObjCCategoryDecl (const ObjCCategoryDecl *OCD) {
690
- visitProtocolList (OCD->protocols (), OCD->protocol_locs ());
691
666
// getLocation is the extended class's location, not the category's.
692
667
Refs.push_back (ReferenceLoc{NestedNameSpecifierLoc (),
693
668
OCD->getLocation (),
@@ -709,12 +684,6 @@ llvm::SmallVector<ReferenceLoc> refInDecl(const Decl *D,
709
684
/* IsDecl=*/ true ,
710
685
{OCID->getCategoryDecl ()}});
711
686
}
712
-
713
- void VisitObjCProtocolDecl (const ObjCProtocolDecl *OPD) {
714
- if (OPD->isThisDeclarationADefinition ())
715
- visitProtocolList (OPD->protocols (), OPD->protocol_locs ());
716
- Base::VisitObjCProtocolDecl (OPD); // Visit the protocol's name.
717
- }
718
687
};
719
688
720
689
Visitor V{Resolver};
@@ -944,16 +913,6 @@ refInTypeLoc(TypeLoc L, const HeuristicResolver *Resolver) {
944
913
/* IsDecl=*/ false ,
945
914
{L.getIFaceDecl ()}});
946
915
}
947
-
948
- void VisitObjCObjectTypeLoc (ObjCObjectTypeLoc L) {
949
- unsigned NumProtocols = L.getNumProtocols ();
950
- for (unsigned I = 0 ; I < NumProtocols; I++) {
951
- Refs.push_back (ReferenceLoc{NestedNameSpecifierLoc (),
952
- L.getProtocolLoc (I),
953
- /* IsDecl=*/ false ,
954
- {L.getProtocol (I)}});
955
- }
956
- }
957
916
};
958
917
959
918
Visitor V{Resolver};
@@ -1049,6 +1008,11 @@ class ExplicitReferenceCollector
1049
1008
return RecursiveASTVisitor::TraverseNestedNameSpecifierLoc (L);
1050
1009
}
1051
1010
1011
+ bool TraverseObjCProtocolLoc (ObjCProtocolLoc ProtocolLoc) {
1012
+ visitNode (DynTypedNode::create (ProtocolLoc));
1013
+ return true ;
1014
+ }
1015
+
1052
1016
bool TraverseConstructorInitializer (CXXCtorInitializer *Init) {
1053
1017
visitNode (DynTypedNode::create (*Init));
1054
1018
return RecursiveASTVisitor::TraverseConstructorInitializer (Init);
@@ -1094,6 +1058,12 @@ class ExplicitReferenceCollector
1094
1058
{CCI->getAnyMember ()}}};
1095
1059
}
1096
1060
}
1061
+ if (const ObjCProtocolLoc *PL = N.get <ObjCProtocolLoc>())
1062
+ return {ReferenceLoc{NestedNameSpecifierLoc (),
1063
+ PL->getLocation (),
1064
+ /* IsDecl=*/ false ,
1065
+ {PL->getProtocol ()}}};
1066
+
1097
1067
// We do not have location information for other nodes (QualType, etc)
1098
1068
return {};
1099
1069
}
0 commit comments