I am setting up clang* tools for the 1st time. I am using 20.0.0git versions for the clang* tools (clangd, clang-format and clang-tidy) I have couple of questions:
-
Background Index:
I see indexes are getting generated under ${HOME}/.cache/clangd/index directory.
Since I have multiple sandboxes (perforce), I want indexes to be generated in the sandbox (project directory). What is the way to define that
.clangd
file? And is there a way to specify priority or effort or number of threads to use for indexing in the.clangd
file?I have defined
.clangd
file as following in the sandbox directory:Hover: ShowAKA: true InlayHints: Enabled: Yes BlockEnd: No Designators: No ParameterNames: Yes DeducedTypes: Yes TypeNameLimit: 0 CompileFlags: CompilationDatabase: <path to compilation database parent dir> Add: [ -Wunused-function, -Wall, -Wextra, -Wshadow, -Wpedantic, -Werror=unused-variable, -Wexceptions, -Wno-switch-enum, -Wimplicit-fallthrough, -Wno-unknown-warning-option, --gcc-toolchain=<path to GGC>, ] Remove: -Werror Diagnostics: UnusedIncludes: Strict ClangTidy: FastCheckFilter: Strict Add: [ clang-diagnostic-*, clang-analyzer-*, modernize*, performance*, readability*, google-explicit-constructor, bugprone-exception-escape, bugprone-incorrect-enable-if, bugprone-inaccurate-erase, bugprone-redundant-branch-condition, bugprone-pointer-arithmetic-on-polymorphic-object, bugprone-parent-virtual-call, bugprone-unhandled-self-assignment, bugprone-unused-raii, bugprone-use-after-move, bugprone-unused-local-non-trivial-variable, cppcoreguidelines-slicing, misc-unused-parameters, ] Remove: [ modernize-use-trailing-return-type, modernize-use-using, readability-avoid-unconditional-preprocessor-if, readability-identifier-length, readability-implicit-bool-conversion, readability-isolate-declaration, readability-magic-numbers, readability-qualified-auto, readability-suspicious-call-argument, ] CheckOptions: readability-function-cognitive-complexity.Threshold: 25, readability-function-cognitive-complexity.IgnoreMacros: true Index: Background: Build StandardLibrary: No
-
Compilation DB:
We have a custom build system (different from plain make or cmake). And to avoid corrupting the sandbox, we create linked area where all source files are symlinks to ones from the sandbox and do the build there. As a result, the compilation database gets created in the linked area.
If I create a soft-link in the sandbox pointing to the generated compilation db in the build area, will the indexing work?
If no, what are other options that I can explore for this use model?<sandbox> <linked build area> | | + compile_commands.json -> <build area>/compile_commands.json +
Note: The files in the compilation database in the build area are symlink to the corresponding files in the sandbox