Skip to content

Commit bad8e57

Browse files
committed
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
1 parent 438b5bb commit bad8e57

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Diff for: clang-tools-extra/clangd/benchmarks/CompletionModel/DecisionForestBenchmark.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace clang {
2121
namespace clangd {
2222
namespace {
2323
std::vector<Example> generateRandomDataset(int NumExamples) {
24-
auto FlipCoin = [&](float Probability) {
24+
auto FlipCoin = [&](double Probability) {
2525
return rand() % 1000 <= Probability * 1000;
2626
};
2727
auto RandInt = [&](int Max) { return rand() % Max; };
@@ -38,15 +38,15 @@ std::vector<Example> generateRandomDataset(int NumExamples) {
3838
E.setIsImplementationDetail(FlipCoin(0.3)); // Boolean.
3939
E.setNumReferences(RandInt(10000)); // Can be large integer.
4040
E.setSymbolCategory(RandInt(10)); // 10 Symbol Category.
41-
41+
E.setNumNameInContext(RandInt(20)); // 0 to ContextWords->size().
42+
E.setFractionNameInContext(RandFloat(1.0)); // Float in range [0,1].
4243
E.setIsNameInContext(FlipCoin(0.5)); // Boolean.
43-
E.setIsForbidden(FlipCoin(0.1)); // Boolean.
4444
E.setIsInBaseClass(FlipCoin(0.3)); // Boolean.
45-
E.setFileProximityDistance(
45+
E.setFileProximityDistanceCost(
4646
FlipCoin(0.1) ? 999999 // Sometimes file distance is not available.
4747
: RandInt(20));
4848
E.setSemaFileProximityScore(RandFloat(1)); // Float in range [0,1].
49-
E.setSymbolScopeDistance(
49+
E.setSymbolScopeDistanceCost(
5050
FlipCoin(0.1) ? 999999 // Sometimes scope distance is not available.
5151
: RandInt(20));
5252
E.setSemaSaysInScope(FlipCoin(0.5)); // Boolean.
@@ -56,7 +56,6 @@ std::vector<Example> generateRandomDataset(int NumExamples) {
5656
E.setHadContextType(FlipCoin(0.6)); // Boolean.
5757
E.setHadSymbolType(FlipCoin(0.6)); // Boolean.
5858
E.setTypeMatchesPreferred(FlipCoin(0.5)); // Boolean.
59-
E.setFilterLength(RandInt(15));
6059
Examples.push_back(E);
6160
}
6261
return Examples;

0 commit comments

Comments
 (0)