Skip to content

Commit bd77676

Browse files
committed
[clang] NFC: NNS getLocalSourceRange user cleanup
This adds a note to the documentation of getLocalSourceRange, and cleans up one of the users of this function which was changed in #147835
1 parent 625aa09 commit bd77676

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,16 +1040,11 @@ class ExplicitReferenceCollector
10401040
if (auto *S = N.get<Stmt>())
10411041
return refInStmt(S, Resolver);
10421042
if (auto *NNSL = N.get<NestedNameSpecifierLoc>()) {
1043+
if (auto TL = NNSL->getAsTypeLoc())
1044+
return refInTypeLoc(NNSL->getAsTypeLoc(), Resolver);
10431045
// (!) 'DeclRelation::Alias' ensures we do not lose namespace aliases.
1044-
NestedNameSpecifierLoc Qualifier;
1045-
SourceLocation NameLoc;
1046-
if (auto TL = NNSL->getAsTypeLoc()) {
1047-
Qualifier = TL.getPrefix();
1048-
NameLoc = TL.getNonPrefixBeginLoc();
1049-
} else {
1050-
Qualifier = NNSL->getAsNamespaceAndPrefix().Prefix;
1051-
NameLoc = NNSL->getLocalBeginLoc();
1052-
}
1046+
NestedNameSpecifierLoc Qualifier = NNSL->getAsNamespaceAndPrefix().Prefix;
1047+
SourceLocation NameLoc = NNSL->getLocalBeginLoc();
10531048
return {
10541049
ReferenceLoc{Qualifier, NameLoc, false,
10551050
explicitReferenceTargets(

clang/include/clang/AST/NestedNameSpecifierBase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ class NestedNameSpecifierLoc {
361361
/// Retrieve the source range covering just the last part of
362362
/// this nested-name-specifier, not including the prefix.
363363
///
364+
/// Note that this is the source range of this NestedNameSpecifier chunk,
365+
// and for a type this includes the prefix of that type.
366+
///
364367
/// For example, if this instance refers to a nested-name-specifier
365368
/// \c \::std::vector<int>::, the returned source range would cover
366369
/// from "vector" to the last '::'.

0 commit comments

Comments
 (0)