-
Notifications
You must be signed in to change notification settings - Fork 15k
[clang] NFC: NNS getLocalSourceRange user cleanup #163206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-clang Author: Matheus Izvekov (mizvekov) ChangesThis adds a note to the documentation of getLocalSourceRange, and cleans up one of the users of this function which was changed in #147835 Full diff: https://github.com/llvm/llvm-project/pull/163206.diff 2 Files Affected:
diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp
index 8aae41420b83e..799c64b8dab4d 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -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(
diff --git a/clang/include/clang/AST/NestedNameSpecifierBase.h b/clang/include/clang/AST/NestedNameSpecifierBase.h
index 73c60ba695419..669566e142447 100644
--- a/clang/include/clang/AST/NestedNameSpecifierBase.h
+++ b/clang/include/clang/AST/NestedNameSpecifierBase.h
@@ -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 '::'.
|
|
@llvm/pr-subscribers-clangd Author: Matheus Izvekov (mizvekov) ChangesThis adds a note to the documentation of getLocalSourceRange, and cleans up one of the users of this function which was changed in #147835 Full diff: https://github.com/llvm/llvm-project/pull/163206.diff 2 Files Affected:
diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp
index 8aae41420b83e..799c64b8dab4d 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -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(
diff --git a/clang/include/clang/AST/NestedNameSpecifierBase.h b/clang/include/clang/AST/NestedNameSpecifierBase.h
index 73c60ba695419..669566e142447 100644
--- a/clang/include/clang/AST/NestedNameSpecifierBase.h
+++ b/clang/include/clang/AST/NestedNameSpecifierBase.h
@@ -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 '::'.
|
|
@llvm/pr-subscribers-clang-tools-extra Author: Matheus Izvekov (mizvekov) ChangesThis adds a note to the documentation of getLocalSourceRange, and cleans up one of the users of this function which was changed in #147835 Full diff: https://github.com/llvm/llvm-project/pull/163206.diff 2 Files Affected:
diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp
index 8aae41420b83e..799c64b8dab4d 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -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(
diff --git a/clang/include/clang/AST/NestedNameSpecifierBase.h b/clang/include/clang/AST/NestedNameSpecifierBase.h
index 73c60ba695419..669566e142447 100644
--- a/clang/include/clang/AST/NestedNameSpecifierBase.h
+++ b/clang/include/clang/AST/NestedNameSpecifierBase.h
@@ -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 '::'.
|
bd77676 to
eeeced2
Compare
This adds a note to the documentation of getLocalSourceRange, and cleans up one of the users of this function which was changed in #147835 This also removes `TypeLoc::getNonPrefixBeginLoc`, which was recently introduced in the above patch, as that became unused.
eeeced2 to
51eedf9
Compare
This adds a note to the documentation of getLocalSourceRange, and cleans up one of the users of this function which was changed in llvm#147835 This also removes `TypeLoc::getNonPrefixBeginLoc`, which was recently introduced in the above patch, as that became unused.
This adds a note to the documentation of getLocalSourceRange, and cleans up one of the users of this function which was changed in #147835
This also removes
TypeLoc::getNonPrefixBeginLoc, which was recently introduced in the above patch, as that became unused.