[PATCH] D94927: [clangd] Use ASTSignals in Heuristics CC Ranking.

Utkarsh Saxena via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 19 10:06:39 PST 2021


usaxena95 updated this revision to Diff 317613.
usaxena95 marked an inline comment as done.
usaxena95 added a comment.

Added a comment about the calculation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94927/new/

https://reviews.llvm.org/D94927

Files:
  clang-tools-extra/clangd/Quality.cpp


Index: clang-tools-extra/clangd/Quality.cpp
===================================================================
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -474,6 +474,21 @@
   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;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94927.317613.patch
Type: text/x-patch
Size: 920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210119/ef55537b/attachment.bin>


More information about the cfe-commits mailing list