summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/Quality.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/Quality.cpp')
-rw-r--r--clang-tools-extra/clangd/Quality.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/clang-tools-extra/clangd/Quality.cpp b/clang-tools-extra/clangd/Quality.cpp
index dd8256a32a1..6a329fbe068 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -156,8 +156,8 @@ float SymbolQualitySignals::evaluate() const {
Score *= 0.1f;
switch (Category) {
- case Keyword: // Usually relevant, but misses most signals.
- Score *= 10;
+ case Keyword: // Often relevant, but misses most signals.
+ Score *= 4; // FIXME: important keywords should have specific boosts.
break;
case Type:
case Function:
@@ -241,10 +241,14 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
}
static SymbolRelevanceSignals::AccessibleScope
-ComputeScope(const NamedDecl &D) {
+ComputeScope(const NamedDecl *D) {
+ // Injected "Foo" within the class "Foo" has file scope, not class scope.
+ const DeclContext *DC = D->getDeclContext();
+ if (auto *R = dyn_cast_or_null<RecordDecl>(D))
+ if (R->isInjectedClassName())
+ DC = DC->getParent();
bool InClass = false;
- for (const DeclContext *DC = D.getDeclContext(); !DC->isFileContext();
- DC = DC->getParent()) {
+ for (; !DC->isFileContext(); DC = DC->getParent()) {
if (DC->isFunctionOrMethod())
return SymbolRelevanceSignals::FunctionScope;
InClass = InClass || DC->isRecord();
@@ -252,7 +256,7 @@ ComputeScope(const NamedDecl &D) {
if (InClass)
return SymbolRelevanceSignals::ClassScope;
// This threshold could be tweaked, e.g. to treat module-visible as global.
- if (D.getLinkageInternal() < ExternalLinkage)
+ if (D->getLinkageInternal() < ExternalLinkage)
return SymbolRelevanceSignals::FileScope;
return SymbolRelevanceSignals::GlobalScope;
}
@@ -280,7 +284,7 @@ void SymbolRelevanceSignals::merge(const CodeCompletionResult &SemaCCResult) {
// Declarations are scoped, others (like macros) are assumed global.
if (SemaCCResult.Declaration)
- Scope = std::min(Scope, ComputeScope(*SemaCCResult.Declaration));
+ Scope = std::min(Scope, ComputeScope(SemaCCResult.Declaration));
}
float SymbolRelevanceSignals::evaluate() const {
OpenPOWER on IntegriCloud