summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/CodeComplete.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-01-19 21:58:58 +0000
committerSam McCall <sam.mccall@gmail.com>2018-01-19 21:58:58 +0000
commit1a8c55ecc6d28c8103f1825cd3ef03be58e350b7 (patch)
tree8ab608893c9cf60d7e3bb0162eab8c73a6e3d28e /clang-tools-extra/clangd/CodeComplete.cpp
parent563799b3a6cf23fa56c4fcdc91d3d2cf45b015b0 (diff)
downloadbcm5719-llvm-1a8c55ecc6d28c8103f1825cd3ef03be58e350b7.tar.gz
bcm5719-llvm-1a8c55ecc6d28c8103f1825cd3ef03be58e350b7.zip
[clangd] Change index scope convention from "outer::inner" to "outer::inner::"
Global scope is "" (was "") Top-level namespace scope is "ns::" (was "ns") Nested namespace scope is "ns::ns::" (was "ns::ns") This composes more naturally: - qname = scope + name - full scope = resolved scope + unresolved scope (D42073 was the trigger) It removes a wart from the old way: "foo::" has one more separator than "". Another alternative that has these properties is "::ns", but that lacks the property that both the scope and the name are substrings of the qname as produced by clang. llvm-svn: 322996
Diffstat (limited to 'clang-tools-extra/clangd/CodeComplete.cpp')
-rw-r--r--clang-tools-extra/clangd/CodeComplete.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp
index 1a95b6ba6bf..ab8a22d6b45 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -313,7 +313,7 @@ llvm::Optional<SymbolID> getSymbolID(const CodeCompletionResult &R) {
/// completion (e.g. "ns::ab?").
struct SpecifiedScope {
/// The scope specifier as written. For example, for completion "ns::ab?", the
- /// written scope specifier is "ns".
+ /// written scope specifier is "ns::". Doesn't include leading "::".
std::string Written;
// If this scope specifier is recognized in Sema (e.g. as a namespace
// context), this will be set to the fully qualfied name of the corresponding
@@ -321,8 +321,7 @@ struct SpecifiedScope {
std::string Resolved;
llvm::StringRef forIndex() {
- llvm::StringRef Chosen = Resolved.empty() ? Written : Resolved;
- return Chosen.trim(':');
+ return Resolved.empty() ? Written.ltrim('::') : Resolved;
}
};
@@ -631,15 +630,14 @@ SpecifiedScope getSpecifiedScope(Sema &S, const CXXScopeSpec &SS) {
auto SpecifierRange = SS.getRange();
Info.Written = Lexer::getSourceText(
CharSourceRange::getCharRange(SpecifierRange), SM, clang::LangOptions());
+ if (!Info.Written.empty())
+ Info.Written += "::"; // Sema excludes the trailing ::.
if (SS.isValid()) {
DeclContext *DC = S.computeDeclContext(SS);
if (auto *NS = llvm::dyn_cast<NamespaceDecl>(DC)) {
- Info.Resolved = NS->getQualifiedNameAsString();
+ Info.Resolved = NS->getQualifiedNameAsString() + "::";
} else if (llvm::dyn_cast<TranslationUnitDecl>(DC) != nullptr) {
- Info.Resolved = "::";
- // Sema does not include the suffix "::" in the range of SS, so we add
- // it back here.
- Info.Written = "::";
+ Info.Resolved = "";
}
}
return Info;
OpenPOWER on IntegriCloud