C++ support
CLion incorporates two language engines, the built-in one and the Clangd -based one, both working in parallel.
The Clangd-based engine detects warnings and errors to be shown in the editor and provides quick-fixes, performs certain navigation actions, highlighting, and completion, while CLion's own engine is used for other code insight features like refactorings. You can adjust the scope of Clangd functionality in Clangd settings.
The following table shows how the two engines handle CLion features by default:
IDE feature | Language engine |
---|---|
Syntax highlighting | Clangd |
Errors/warnings and quick-fixes | Clangd |
Clangd only, both, or built-in only * | |
Clangd | |
Built-in engine | |
Both ** | |
Clangd | |
Built-in engine |
*- As selected in Clangd settings.
**- Both engines are used. Clangd helps with highlighting references at caret, Go to declaration, Go to definition, Quick documentation, Quick definition, Find Usages.
Language standards compliance
CLion fully supports C++11, C++14, C++17, and partially C++20.
Support for C++11 and C++14 is provided by the built-in engine. It also supports a part of the C++17 features, while the rest of them are provided by Clangd.
Support for the C++20 standard relies on Clangd except for parsing and refactorings (handled by the built-in engine). Besides, the built-in engine extends the Clangd's support for C++20 Concepts (see the dedicated article for details).
The tables below give an overview of the standards support status, and the details of C++20 and C+17 support.
Standard | Clangd (CXX_status) | Built-in engine |
---|---|---|
C++20 | Partial support |
|
C++17 | Full support starting Clang 5 | Partial support |
C++14 | Full support | Full support |
C++11 | Full support | Full support |
C++ code inspections
CLion performs static analysis on your C/C++ code using a set of inspections, configurable in Settings / Preferences | Editor | Inspections | C/C++. Some of the C/C++ inspections are provided by Clangd, while the others work as part of the built-in engine.
The table below shows which engine is used for a particular inspection or a set of inspections. Note that Objective-C checks are not listed except for those with similar Clang diagnostics.
Inspection | Provided by |
---|---|
Clangd | |
Build-in engine | |
General: Argument selection defects | Clangd |
General: Clang-tidy | Clangd or built-in, as selected |
General: Unconstrained variable type | Built-in engine (based on Clangd) |
General: Empty declaration or statement | Clangd |
General: Format specifiers | For C/C++, this check is covered by Clang’s -Wformat diagnostic. |
General: | For C/C++, this check is covered by Clang’s -Wparentheses diagnostic. |
General: Inconsistent naming | Built-in engine |
General: Missing switch case | For C/C++, this check is covered by Clang’s -Wswitch diagnostic. |
General: Simplifiable statement | Clangd |
General: Virtual call from constructor or destructor | Clangd |
Built-in engine (based on Clangd) | |
Unused code: Unused expression result | For C/C++, this check is covered by Clangd’s DFA. |
Unused code: Unused global declaration | Clangd |
Unused code: Unused include directive | Clangd |
Unused code: Unused macro | Clangd |
Unused code: Unused struct | Clangd |
Unused code: Unused template parameter | Clangd |
Unused code: Unused type alias | Clangd |