Clangd | Qt Creator Documentation
Description: Sets global preferences for the clangd code model.

- Qt Creator Documentation
- Clangd
- Qt Creator 15.0.0

Reference

# Clangd

The Clang project has libraries for parsing C language family source files and providing you with detailed diagnostics. The clangd index provides exact and complete results for services such as code completion.

To set preferences for clangd:

1. Select Preferences > C++ > Clangd > Use clangd.

2. In Path to executable, enter the path to clangd version 14, or later.
3. In the Background indexing field, select Off to use a faster, but less accurate built-in indexer than the one used by default. Set the indexing priority depending on whether the accuracy of results or speed is more important to you during global symbol searches.
4. In Per-project index location, select the folder to store the index files for each project. The `compile-commands.json` file is also stored in this folder.
5. In Per-session index location, select the folder to store the index files for each session.
6. In Header/source switch mode, select the C/C++ backend for switching between header and source files. While the clangd implementation has more capabilities than the built-in code model, it tends to find false positives. Try Both uses clangd if the built-in code model does not find anything.
7. By default, clangd attempts to use all unused cores. You can set a fixed number of cores to use in Worker thread count. Background indexing also uses this many worker threads.
8. Select Insert header files on completion to insert header files when completing symbols.
9. Select Update dependent sources to re-parse all source files that include a header file when editing the header file. This can cause a heavy CPU load if the header file is included in many source files. Clear this option to only re-parse the source files when saving the header file.
10. Set the number of Completion results if you regularly miss important results during code completion. Set it to 0 to remove the limit on the number of completion results. Setting this to 0 or a very high number can make code completion slow.
11. In Completion ranking model, select the clangd model to use for ranking completion suggestions. This determines their order in the selection list. The Decision Forest model (Default) results from pre-trained machine learning and usually provides better results than the hand-crafted Heuristic model. Select the latter if the completion suggestions stray too much from your expectations for your code base.
12. In Document update threshold, specify the amount of time Qt Creator waits before sending document changes to the server. If the document changes again while waiting, this timeout is reset.
13. Select Ignore files greater than to make parsing faster by ignoring big files. Specify the maximum size of files to parse in the field next to the check box.
14. The Diagnostic configuration field shows the Clang checks to perform. Click the value of the field to select and edit the checks to perform.
15. Select Add to select sessions that should use a single clangd process for indexing.

## Clang Checks

Click the value of the Diagnostic configuration field to open the Diagnostic Configurations dialog, where you can select and edit the checks to perform.

In addition to using the built-in checks, you can select Copy to create copies of them and edit the copies to fit your needs.

- Build-system warnings shows warnings as specified by the build system.
- Checks for questionable constructs combines the `-Wall` and `-Wextra` checks for easily avoidable questionable constructions and some additional issues.

Clang checks begin with `-W`. Each check also has a negative version that begins with `-Wno`.

Keep in mind that some options turn on other options. For more information, see Options to Request or Suppress Warnings or the GCC or Clang manual pages.

See also Specify clangd settings, Clang Code Model, and Code Model.

Reference