Closed juxeii closed 2 years ago
Please see https://clangd.llvm.org/config.html#remove
Thx. I created a file .clangd in the project root(where main CMakeLists.txt exists). Contents are:
CompileFlags: # Tweak the parse settings
Remove: -fno-ipa-sra, -fno-ipa-sra
The errors are still popping up. Can you please give an example on how to disable fno-ipa-sra
?
An example file would be great.
Edit: I was not able to find a template .clangd file in this thread either clik
If there are multiple flags, I believe they need to be enclosed in []
, e.g.
CompileFlags:
Remove: [-fno-ipa-sra, -fno-ipa-sra]
(though there's no reason to put the same flag twice -- maybe that was a typo)
Thx, that was not a typo, I wanted to see the syntax for list here :)
Should there be a log entry of clangd that this config file was loaded?
I can only the see that the user yaml loaded:
V[09:06:49.968] User config file is /home/reiss/.config/clangd/config.yaml
It would help to debug to see which config files were loaded.
I do see log output like this for the project config file:
V[03:24:33.355] config note at <workspace>/.clangd:1:0: Parsing config fragment
I do not see this, but your example works anyway. Here is my startup log
I[09:24:00.438] clangd version 13.0.1 (ssh://gitlab@gitlab.dynamic.nsn-net.net/clang/llvm-project f7a4722045180b560f319624b76f9f08ef25daab)
I[09:24:00.439] Features: linux
I[09:24:00.439] PID: 30396
I[09:24:00.439] Working directory: /var/fpwork/reiss/gnb/cplane
I[09:24:00.439] argv[0]: /var/fpwork/reiss/gnb/cplane/sdk/cplane/prefix_root_native/bin/clangd
I[09:24:00.439] argv[1]: -log=verbose
I[09:24:00.439] argv[2]: -pretty
I[09:24:00.439] argv[3]: --background-index
V[09:24:00.439] User config file is /home/reiss/.config/clangd/config.yaml
I[09:24:00.439] Starting LSP over stdin/stdout
V[09:24:00.440] <<< {
I believe config parsing is done lazily, and therefore the "Parsing config fragment" log statements only show up a bit later (after the initialize
request, but before "ASTWorker building file" for the first open file).
Great, found it. There is one little thing though
V[10:18:34.328] config note at /var/fpwork/reiss/gnb/cplane/.clangd:1:0: Parsing config fragment
V[10:18:34.329] config note at /var/fpwork/reiss/gnb/cplane/.clangd:1:0: Parsed 1 fragments from file
V[10:18:34.329] Config fragment: compiling /var/fpwork/reiss/gnb/cplane/.clangd:1 -> 0x00007F80E0001D20 (trusted=false)
V[10:18:34.331] config note at /var/fpwork/reiss/gnb/cplane/CP-RT/CP-RT/.clangd:1:0: Parsing config fragment
V[10:18:34.331] config note at /var/fpwork/reiss/gnb/cplane/CP-RT/CP-RT/.clangd:1:0: Parsed 1 fragments from file
V[10:18:34.331] Config fragment: compiling /var/fpwork/reiss/gnb/cplane/CP-RT/CP-RT/.clangd:1 -> 0x00007F80E0028B90 (trusted=false)
We have a rather bad project structure. One project path lives as a nested one in another path, which leads to the situation that all config files are loaded on the "way up":
V[10:18:34.331] config note at /var/fpwork/reiss/gnb/cplane/CP-RT/CP-RT/.clangd:1:0: Parsing config fragment
This is the config for the current project. And this
V[10:18:34.328] config note at /var/fpwork/reiss/gnb/cplane/.clangd:1:0: Parsing config fragment
is the config for a project which happens to live above the current one.
Why does clangd look for config files, which exist in a path above the project root?
Is there a way to configure the project root and to tell clangd that it should not look for other configs in paths above?
Why does clangd look for config files, which exist in a path above the project root?
Well, that behavior is often what you want! Otherwise if you want config to apply to a whole tree, and then specialize behavior in a subtree, you'd have to repeat the whole config.
You can restrict the parent config file from matching subtrees using If.PathExclude: https://clangd.llvm.org/config#if
Excellent! BTW: Big thanks for your work. The last time I worked with the extension(9.0), it was very slow on our big code base. The improvements to 13.0 are really great! ;)
Is there a way to ignore some compiler arguments to get rid of errors? Example:
Would be great to specify a list of options to ignore...like in this case
-fno-ipa-sra
.