Make it possible to disable building the decision forest ranking
model for clangd. To unbreak build of Clangd on PPC32 in gentoo, see
https://bugs.gentoo.org/829602
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This seems to build in both modes, but I still need to figure out what to do with tests with decision forest off.
Also, maybe there is a way to minimize the use of preprocessor even more.
clang-tools-extra/clangd/decision-forest/DecisionForest.cpp | ||
---|---|---|
15 ↗ | (On Diff #479270) | Note to self: split into two namespace declarations for consistency with the rest of clangd |
clang-tools-extra/clangd/CMakeLists.txt | ||
---|---|---|
54 | this muddies the waters a bit: the code in DecisionForest.cpp is *not* the generated completion model. | |
clang-tools-extra/clangd/Features.inc.in | ||
7 | we could include this in the feature-string too (Feature.cpp) but I think it's probably more noise than signal. | |
clang-tools-extra/clangd/decision-forest/DecisionForest_disabled.cpp | ||
19 ↗ | (On Diff #479270) | As much as I dislike the preprocessor, I think conditionally including source files is undiscoverable enough (if you're reading the source code) that I'd have a preference for this being an #else branch in DecisionForest.cpp. (It's also one mechanism vs two, given that we *do* still need the preprocessor elsewhere) |
clang-tools-extra/clangd/tool/ClangdMain.cpp | ||
215 | hmm, while reordering these: hueristics -> heuristics? :-) | |
216 | CodeCompleteOptions().RankingModel is also the one used in unit tests. |
- Merge DecisionForest.cpp and *_disabled.cpp, change #ifndef to #if
- Add decision_forest to the feature string
- Set Heuristics as the default code completion model in tests
- Do not compile decision forest tests when it's disabled
- Remove the use of preprocessor for defining the default value of -ranking-model flag to clangd
clang-tools-extra/clangd/Features.inc.in | ||
---|---|---|
7 | Maybe include only when it's disabled? I've added this to the commit, PTAL. | |
clang-tools-extra/clangd/tool/ClangdMain.cpp | ||
215 | I'm not sure how the reordering happened in the first place, TBH 🤔 | |
216 | I have moved it to the .cpp file. I think that avoiding conditionals in the preprocessor is a good thing definitely. I also considered putting the constant into DecisionForest.cpp to reduce the number of files that use #if CLANGD_DECISION_FOREST. |
Looks great, thanks!
clang-tools-extra/clangd/CMakeLists.txt | ||
---|---|---|
21 | May want to add a motivating comment like "this involves generating and compiling large source files, which can run into toolchain limitations"? (This does violate the convention that build configurations should be as mysterious as possible!) | |
clang-tools-extra/clangd/CodeComplete.cpp | ||
26 | Include feature.h instead of relying on it transitively? (Important here as losing the include changes the behavior) | |
clang-tools-extra/clangd/CodeComplete.h | ||
134 | Nice, somehow i forgot this was an option | |
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp | ||
14 | Feature.h here too |
- Add a comment to CMakelists.txt explaining motivation for the option
- Add #include "Feature.h"
- Revert changes to the order of compiler flags to keep this change more focused
- clang-format
- replace #ifndef with #if ! in ClangdMain.cpp
I have sent a follow-up NFC change to fix a typo in the documentation of --ranking-model=heuristics. Note that I decided to avoid changing the order of options for --ranking-model in the documentation, this didn't seem important.
May want to add a motivating comment like "this involves generating and compiling large source files, which can run into toolchain limitations"?
(This does violate the convention that build configurations should be as mysterious as possible!)