Skip to content

Commit 027b9b5

Browse files
author
Pavel V Chupin
committed
Merge from 'main' to 'sycl-web' (#1)
2 parents ae1fb89 + 0f1137b commit 027b9b5

File tree

355 files changed

+7450
-3738
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

355 files changed

+7450
-3738
lines changed

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 61 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,13 @@ struct TargetFinder {
432432
Outer.add(OIT->getDecl(), Flags);
433433
}
434434
void VisitObjCObjectType(const ObjCObjectType *OOT) {
435-
// FIXME: ObjCObjectTypeLoc has no children for the protocol list, so
436-
// there is no node in id<Foo> that refers to ObjCProtocolDecl Foo.
437-
if (OOT->isObjCQualifiedId() && OOT->getNumProtocols() == 1)
438-
Outer.add(OOT->getProtocol(0), Flags);
435+
// Make all of the protocols targets since there's no child nodes for
436+
// protocols. This isn't needed for the base type, which *does* have a
437+
// child `ObjCInterfaceTypeLoc`. This structure is a hack, but it works
438+
// well for go-to-definition.
439+
unsigned NumProtocols = OOT->getNumProtocols();
440+
for (unsigned I = 0; I < NumProtocols; I++)
441+
Outer.add(OOT->getProtocol(I), Flags);
439442
}
440443
};
441444
Visitor(*this, Flags).Visit(T.getTypePtr());
@@ -813,30 +816,34 @@ refInTypeLoc(TypeLoc L, const HeuristicResolver *Resolver) {
813816
Visitor(const HeuristicResolver *Resolver) : Resolver(Resolver) {}
814817

815818
const HeuristicResolver *Resolver;
816-
llvm::Optional<ReferenceLoc> Ref;
819+
llvm::SmallVector<ReferenceLoc> Refs;
817820

818821
void VisitElaboratedTypeLoc(ElaboratedTypeLoc L) {
819822
// We only know about qualifier, rest if filled by inner locations.
823+
size_t InitialSize = Refs.size();
820824
Visit(L.getNamedTypeLoc().getUnqualifiedLoc());
821-
// Fill in the qualifier.
822-
if (!Ref)
823-
return;
824-
assert(!Ref->Qualifier.hasQualifier() && "qualifier already set");
825-
Ref->Qualifier = L.getQualifierLoc();
825+
size_t NewSize = Refs.size();
826+
// Add qualifier for the newly-added refs.
827+
for (unsigned I = InitialSize; I < NewSize; ++I) {
828+
ReferenceLoc *Ref = &Refs[I];
829+
// Fill in the qualifier.
830+
assert(!Ref->Qualifier.hasQualifier() && "qualifier already set");
831+
Ref->Qualifier = L.getQualifierLoc();
832+
}
826833
}
827834

828835
void VisitTagTypeLoc(TagTypeLoc L) {
829-
Ref = ReferenceLoc{NestedNameSpecifierLoc(),
830-
L.getNameLoc(),
831-
/*IsDecl=*/false,
832-
{L.getDecl()}};
836+
Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
837+
L.getNameLoc(),
838+
/*IsDecl=*/false,
839+
{L.getDecl()}});
833840
}
834841

835842
void VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc L) {
836-
Ref = ReferenceLoc{NestedNameSpecifierLoc(),
837-
L.getNameLoc(),
838-
/*IsDecl=*/false,
839-
{L.getDecl()}};
843+
Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
844+
L.getNameLoc(),
845+
/*IsDecl=*/false,
846+
{L.getDecl()}});
840847
}
841848

842849
void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc L) {
@@ -848,63 +855,71 @@ refInTypeLoc(TypeLoc L, const HeuristicResolver *Resolver) {
848855
// 1. valias with mask 'Alias'.
849856
// 2. 'vector<int>' with mask 'Underlying'.
850857
// we want to return only #1 in this case.
851-
Ref = ReferenceLoc{
858+
Refs.push_back(ReferenceLoc{
852859
NestedNameSpecifierLoc(), L.getTemplateNameLoc(), /*IsDecl=*/false,
853860
explicitReferenceTargets(DynTypedNode::create(L.getType()),
854-
DeclRelation::Alias, Resolver)};
861+
DeclRelation::Alias, Resolver)});
855862
}
856863
void VisitDeducedTemplateSpecializationTypeLoc(
857864
DeducedTemplateSpecializationTypeLoc L) {
858-
Ref = ReferenceLoc{
865+
Refs.push_back(ReferenceLoc{
859866
NestedNameSpecifierLoc(), L.getNameLoc(), /*IsDecl=*/false,
860867
explicitReferenceTargets(DynTypedNode::create(L.getType()),
861-
DeclRelation::Alias, Resolver)};
868+
DeclRelation::Alias, Resolver)});
862869
}
863870

864871
void VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
865-
Ref = ReferenceLoc{NestedNameSpecifierLoc(),
866-
TL.getNameLoc(),
867-
/*IsDecl=*/false,
868-
{TL.getDecl()}};
872+
Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
873+
TL.getNameLoc(),
874+
/*IsDecl=*/false,
875+
{TL.getDecl()}});
869876
}
870877

871878
void VisitDependentTemplateSpecializationTypeLoc(
872879
DependentTemplateSpecializationTypeLoc L) {
873-
Ref = ReferenceLoc{L.getQualifierLoc(), L.getTemplateNameLoc(),
874-
/*IsDecl=*/false,
875-
explicitReferenceTargets(
876-
DynTypedNode::create(L.getType()), {}, Resolver)};
880+
Refs.push_back(
881+
ReferenceLoc{L.getQualifierLoc(), L.getTemplateNameLoc(),
882+
/*IsDecl=*/false,
883+
explicitReferenceTargets(
884+
DynTypedNode::create(L.getType()), {}, Resolver)});
877885
}
878886

879887
void VisitDependentNameTypeLoc(DependentNameTypeLoc L) {
880-
Ref = ReferenceLoc{L.getQualifierLoc(), L.getNameLoc(), /*IsDecl=*/false,
881-
explicitReferenceTargets(
882-
DynTypedNode::create(L.getType()), {}, Resolver)};
888+
Refs.push_back(
889+
ReferenceLoc{L.getQualifierLoc(), L.getNameLoc(),
890+
/*IsDecl=*/false,
891+
explicitReferenceTargets(
892+
DynTypedNode::create(L.getType()), {}, Resolver)});
883893
}
884894

885895
void VisitTypedefTypeLoc(TypedefTypeLoc L) {
886-
Ref = ReferenceLoc{NestedNameSpecifierLoc(),
887-
L.getNameLoc(),
888-
/*IsDecl=*/false,
889-
{L.getTypedefNameDecl()}};
896+
Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
897+
L.getNameLoc(),
898+
/*IsDecl=*/false,
899+
{L.getTypedefNameDecl()}});
890900
}
891901

892902
void VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc L) {
893-
Ref = ReferenceLoc{NestedNameSpecifierLoc(),
894-
L.getNameLoc(),
895-
/*IsDecl=*/false,
896-
{L.getIFaceDecl()}};
903+
Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
904+
L.getNameLoc(),
905+
/*IsDecl=*/false,
906+
{L.getIFaceDecl()}});
897907
}
898908

899-
// FIXME: add references to protocols in ObjCObjectTypeLoc and maybe
900-
// ObjCObjectPointerTypeLoc.
909+
void VisitObjCObjectTypeLoc(ObjCObjectTypeLoc L) {
910+
unsigned NumProtocols = L.getNumProtocols();
911+
for (unsigned I = 0; I < NumProtocols; I++) {
912+
Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
913+
L.getProtocolLoc(I),
914+
/*IsDecl=*/false,
915+
{L.getProtocol(I)}});
916+
}
917+
}
901918
};
902919

903920
Visitor V{Resolver};
904921
V.Visit(L.getUnqualifiedLoc());
905-
if (!V.Ref)
906-
return {};
907-
return {*V.Ref};
922+
return V.Refs;
908923
}
909924

910925
class ExplicitReferenceCollector

0 commit comments

Comments
 (0)