Apache Doris supports static analysis of C++ code with Clangd and Clang-Tidy. Both are bundled in the LDB-toolchain, and you can also install or build them yourself.
| Tool | Purpose | Configuration file |
|---|---|---|
| Clangd | Provides IDE capabilities such as code navigation, completion, and hover hints | Passed in via clangd.arguments |
| Clang-Tidy | Static analysis and code quality checks (can be invoked by Clangd) | .clang-tidy in the Doris root directory |
Compared with vscode-cpptools, Clangd offers more accurate code navigation and integrates the diagnostics and quick-fix features of Clang-Tidy.
Clang-Tidy check rules are centralized in the .clang-tidy file in the Doris root directory. You can enable or disable specific checks by editing this file.
clangd plugin.be(RELEASE) and be-ut(ASAN) once to generate the corresponding compile_commands.json files.settings.json or change the plugin configuration directly in Preferences.{ "clangd.path": "ldb_toolchain/bin/clangd", "clangd.arguments": [ "--background-index", "--clang-tidy", "--compile-commands-dir=doris/be/build_Release/", "--completion-style=detailed", "-j=5", "--all-scopes-completion", "--pch-storage=memory", "--pretty", "--query-driver=ldb_toolchain/bin/*" ], "clangd.trace": "output/clangd-server.log" }
| Parameter | Description |
|---|---|
clangd.path | Path to the Clangd executable |
--background-index | Indexes the entire project in the background to speed up symbol lookup |
--clang-tidy | Enables Clang-Tidy static checks |
--compile-commands-dir | Specifies the directory containing compile_commands.json |
--completion-style=detailed | Shows detailed information during completion |
-j=5 | Number of parallel jobs Clangd uses to analyze files |
--query-driver | Path to the compiler, used to resolve system header files |
Q: How do I troubleshoot clangd when it reports a missing header file or symbol?
Confirm that BE has been compiled at least once to generate compile_commands.json, and that --compile-commands-dir points to the correct directory.