Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions clang-tools-extra/clangd/FindTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,16 +1040,11 @@ class ExplicitReferenceCollector
if (auto *S = N.get<Stmt>())
return refInStmt(S, Resolver);
if (auto *NNSL = N.get<NestedNameSpecifierLoc>()) {
if (auto TL = NNSL->getAsTypeLoc())
return refInTypeLoc(NNSL->getAsTypeLoc(), Resolver);
// (!) 'DeclRelation::Alias' ensures we do not lose namespace aliases.
NestedNameSpecifierLoc Qualifier;
SourceLocation NameLoc;
if (auto TL = NNSL->getAsTypeLoc()) {
Qualifier = TL.getPrefix();
NameLoc = TL.getNonPrefixBeginLoc();
} else {
Qualifier = NNSL->getAsNamespaceAndPrefix().Prefix;
NameLoc = NNSL->getLocalBeginLoc();
}
NestedNameSpecifierLoc Qualifier = NNSL->getAsNamespaceAndPrefix().Prefix;
SourceLocation NameLoc = NNSL->getLocalBeginLoc();
return {
ReferenceLoc{Qualifier, NameLoc, false,
explicitReferenceTargets(
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/AST/NestedNameSpecifierBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ class NestedNameSpecifierLoc {
/// Retrieve the source range covering just the last part of
/// this nested-name-specifier, not including the prefix.
///
/// Note that this is the source range of this NestedNameSpecifier chunk,
/// and for a type this includes the prefix of that type.
///
/// For example, if this instance refers to a nested-name-specifier
/// \c \::std::vector<int>::, the returned source range would cover
/// from "vector" to the last '::'.
Expand Down
5 changes: 0 additions & 5 deletions clang/include/clang/AST/TypeLoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,6 @@ class TypeLoc {
/// "foo::bar". Returns null if this type represents an unqualified-id.
NestedNameSpecifierLoc getPrefix() const;

/// This returns the position of the type after any elaboration, such as the
/// 'struct' keyword, and name qualifiers. This will the 'template' keyword if
/// present, or the name location otherwise.
SourceLocation getNonPrefixBeginLoc() const;

/// This returns the position of the type after any elaboration, such as the
/// 'struct' keyword. This may be the position of the name qualifiers,
/// 'template' keyword, or the name location otherwise.
Expand Down
33 changes: 0 additions & 33 deletions clang/lib/AST/TypeLoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,39 +494,6 @@ NestedNameSpecifierLoc TypeLoc::getPrefix() const {
}
}

SourceLocation TypeLoc::getNonPrefixBeginLoc() const {
switch (getTypeLocClass()) {
case TypeLoc::TemplateSpecialization: {
auto TL = castAs<TemplateSpecializationTypeLoc>();
SourceLocation Loc = TL.getTemplateKeywordLoc();
if (!Loc.isValid())
Loc = TL.getTemplateNameLoc();
return Loc;
}
case TypeLoc::DeducedTemplateSpecialization: {
auto TL = castAs<DeducedTemplateSpecializationTypeLoc>();
SourceLocation Loc = TL.getTemplateKeywordLoc();
if (!Loc.isValid())
Loc = TL.getTemplateNameLoc();
return Loc;
}
case TypeLoc::DependentName:
return castAs<DependentNameTypeLoc>().getNameLoc();
case TypeLoc::Enum:
case TypeLoc::Record:
case TypeLoc::InjectedClassName:
return castAs<TagTypeLoc>().getNameLoc();
case TypeLoc::Typedef:
return castAs<TypedefTypeLoc>().getNameLoc();
case TypeLoc::UnresolvedUsing:
return castAs<UnresolvedUsingTypeLoc>().getNameLoc();
case TypeLoc::Using:
return castAs<UsingTypeLoc>().getNameLoc();
default:
return getBeginLoc();
}
}

SourceLocation TypeLoc::getNonElaboratedBeginLoc() const {
// For elaborated types (e.g. `struct a::A`) we want the portion after the
// `struct` but including the namespace qualifier, `a::`.
Expand Down
Loading