[clang-tools-extra] bad8e57 - Fix DecisionForestBenchmark.cpp compile errors
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 2 01:28:20 PST 2021
Author: Utkarsh Saxena
Date: 2021-03-02T10:27:46+01:00
New Revision: bad8e577f9c75c8b84efca79980781599e8e9f86
URL: https://github.com/llvm/llvm-project/commit/bad8e577f9c75c8b84efca79980781599e8e9f86
DIFF: https://github.com/llvm/llvm-project/commit/bad8e577f9c75c8b84efca79980781599e8e9f86.diff
LOG: Fix DecisionForestBenchmark.cpp compile errors
clang-tools-extra/clangd/benchmarks/CompletionModel/DecisionForestBenchmark.cpp fails to compile since `"CompletionModel.h"` is auto-generated from clang-tools-extra/clangd/quality/model/features.json, which was changed in https://reviews.llvm.org/D94697 to remove `setFilterLength` and `setIsForbidden`, rename `setFileProximityDistance` and `setSymbolScopeDistance`, and add `setNumNameInContext` and `setFractionNameInContext`. This patch removes calls to the two removed functions, updates calls to the two renamed functions, and adds calls to the two new functions. (`20` is an arbitrary choice for the `setNumNameInContext` argument.) It also changes the `FlipCoin` argument from float to double to silence lossy conversion warnings.
Note: I don't use this tool but encountered the build errors and took a shot at fixing them. Please holler if there's another recommended solution. Thanks!
Reviewed By: usaxena95
Differential Revision: https://reviews.llvm.org/D97620
Added:
Modified:
clang-tools-extra/clangd/benchmarks/CompletionModel/DecisionForestBenchmark.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/benchmarks/CompletionModel/DecisionForestBenchmark.cpp b/clang-tools-extra/clangd/benchmarks/CompletionModel/DecisionForestBenchmark.cpp
index 69ce65e08b77..b146def7b36f 100644
--- a/clang-tools-extra/clangd/benchmarks/CompletionModel/DecisionForestBenchmark.cpp
+++ b/clang-tools-extra/clangd/benchmarks/CompletionModel/DecisionForestBenchmark.cpp
@@ -21,7 +21,7 @@ namespace clang {
namespace clangd {
namespace {
std::vector<Example> generateRandomDataset(int NumExamples) {
- auto FlipCoin = [&](float Probability) {
+ auto FlipCoin = [&](double Probability) {
return rand() % 1000 <= Probability * 1000;
};
auto RandInt = [&](int Max) { return rand() % Max; };
@@ -38,15 +38,15 @@ std::vector<Example> generateRandomDataset(int NumExamples) {
E.setIsImplementationDetail(FlipCoin(0.3)); // Boolean.
E.setNumReferences(RandInt(10000)); // Can be large integer.
E.setSymbolCategory(RandInt(10)); // 10 Symbol Category.
-
+ E.setNumNameInContext(RandInt(20)); // 0 to ContextWords->size().
+ E.setFractionNameInContext(RandFloat(1.0)); // Float in range [0,1].
E.setIsNameInContext(FlipCoin(0.5)); // Boolean.
- E.setIsForbidden(FlipCoin(0.1)); // Boolean.
E.setIsInBaseClass(FlipCoin(0.3)); // Boolean.
- E.setFileProximityDistance(
+ E.setFileProximityDistanceCost(
FlipCoin(0.1) ? 999999 // Sometimes file distance is not available.
: RandInt(20));
E.setSemaFileProximityScore(RandFloat(1)); // Float in range [0,1].
- E.setSymbolScopeDistance(
+ E.setSymbolScopeDistanceCost(
FlipCoin(0.1) ? 999999 // Sometimes scope distance is not available.
: RandInt(20));
E.setSemaSaysInScope(FlipCoin(0.5)); // Boolean.
@@ -56,7 +56,6 @@ std::vector<Example> generateRandomDataset(int NumExamples) {
E.setHadContextType(FlipCoin(0.6)); // Boolean.
E.setHadSymbolType(FlipCoin(0.6)); // Boolean.
E.setTypeMatchesPreferred(FlipCoin(0.5)); // Boolean.
- E.setFilterLength(RandInt(15));
Examples.push_back(E);
}
return Examples;
More information about the cfe-commits
mailing list