[llvm-branch-commits] [clang-tools-extra] 17846ed - [clangd] Use ASTSignals in Heuristics CC Ranking.
Utkarsh Saxena via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jan 19 10:52:54 PST 2021
Author: Utkarsh Saxena
Date: 2021-01-19T19:48:42+01:00
New Revision: 17846ed5af4a83334ef7d07f0b4a9d525e6ec0db
URL: https://github.com/llvm/llvm-project/commit/17846ed5af4a83334ef7d07f0b4a9d525e6ec0db
DIFF: https://github.com/llvm/llvm-project/commit/17846ed5af4a83334ef7d07f0b4a9d525e6ec0db.diff
LOG: [clangd] Use ASTSignals in Heuristics CC Ranking.
Differential Revision: https://reviews.llvm.org/D94927
Added:
Modified:
clang-tools-extra/clangd/Quality.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/Quality.cpp b/clang-tools-extra/clangd/Quality.cpp
index 1c41b7c7661f..b49392bc7d04 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -474,6 +474,21 @@ float SymbolRelevanceSignals::evaluateHeuristics() const {
if (NeedsFixIts)
Score *= 0.5f;
+ // Use a sigmoid style boosting function similar to `References`, which flats
+ // out nicely for large values. This avoids a sharp gradient for heavily
+ // referenced symbols. Use smaller gradient for ScopeRefsInFile since ideally
+ // MainFileRefs <= ScopeRefsInFile.
+ if (MainFileRefs >= 2) {
+ // E.g.: (2, 1.12), (9, 2.0), (48, 3.0).
+ float S = std::pow(MainFileRefs, -0.11);
+ Score *= 11.0 * (1 - S) / (1 + S) + 0.7;
+ }
+ if (ScopeRefsInFile >= 2) {
+ // E.g.: (2, 1.04), (14, 2.0), (109, 3.0), (400, 3.6).
+ float S = std::pow(ScopeRefsInFile, -0.10);
+ Score *= 10.0 * (1 - S) / (1 + S) + 0.7;
+ }
+
return Score;
}
More information about the llvm-branch-commits
mailing list