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, C++2b | Partial support |
|
C++17 | Full support starting Clang 5 | Partial support |
C++14 | Full support | Full support |
C++11 | Full support | Full support |
C++2b
Language feature | Error highlighting and quick-fixes | Completion | Navigation | Parsing | Refactorings | |
---|---|---|---|---|---|---|
Literal suffix | Partially | - | - | - | - | - |
Make | Partially | - | - | - | - | - |
Simpler implicit move (P2266R1) | Partially | - | - | - | - | - |
| - | - | - | - | - | - |
Allow duplicate attributes (P2556R1) | Partial | - | - | - | - | - |
Narrowing contextual conversions to bool (P1401R5) | Partial | - | - | - | - | - |
Trimming whitespaces before line splicing (P2223R2) | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
Make declaration order layout mandated (P1874R4) | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
C++ identifier syntax using UAX 31 (P1949R7) | Partial | - | - | - | - | - |
Mixed string literal concatenation (P2201R1) | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
C++20
Language feature | Error highlighting and quick-fixes | Completion | Navigation | Parsing | Refactorings | |
---|---|---|---|---|---|---|
Default member initializers for bit-fields (P0683R1) | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
| + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
Allow lambda-capture | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
| + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
Designated initializers (P0329R4) | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
template-parameter-list for generic lambdas (P0428R2) | + | Clangd | Clangd | Mixed | Built-in engine | - |
+ | Clangd | Clangd | Mixed | Built-in engine | Built-in engine, Rename only | |
- | - | - | - | - | - | |
Range-based for statements with initializer (P0614R1) | + | Clangd | Clangd | Mixed | Built-in engine | Built-in engine |
ADL and function templates that are not visible (P0846R0) | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
| + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
Consistent comparison ( | + | Clangd | Clangd | Mixed | Built-in engine | - |
Consistent comparison ( | Partial | - | - | - | - | - |
Consistent comparison ( | - | - | - | - | - | - |
Access checking on specializations (P0692R1) | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
Default constructible and assignable stateless lambdas (P0624R2) | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
Lambdas in unevaluated contexts (P0315R4) | Partially (doesn't implement | Clangd | Clangd | Mixed, relying on Clangd | - | - |
| + | Clangd | Clangd | Mixed | Built-in engine | - |
| + | Built-in engine | Built-in engine | Built-in engine | Built-in engine | - |
typename optional in more contexts (P0634R3) | - | - | - | - | - | - |
Pack expansion in lambda init-capture (P0780R2) | + | Clangd | Clangd | Mixed | Built-in engine | - |
Class types as non-type template parameters (P0732R2, P1907R1 | Partial | Clangd | Clang | - | - | - |
Destroying operator delete (P0722R3) | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
Relaxations of constexpr restrictions (P1064R0, P1002R1, P1327R1, P1330R0, P1331R2, P1668R1, P0784R7) | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
Prohibit aggregates with user-declared constructors (P1008R1) | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
Feature test macros (P0941R2) | Clangd | Clangd | Mixed, relying on Clangd | - | - | |
| + | Clangd | Clangd | Mixed | Built-in engine | Built-in engine |
Signed integers are two's complement (P1236R1) | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
| + | Clangd | Clangd | Mixed | Built-in engine | - |
+ | Clangd | Clangd | Mixed | Built-in engine | - | |
| + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
Nested inline namespaces (P1094R2) | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
Partially | - | - | - | - | - | |
+ | Clangd | Clangd | Mixed, relying on Clangd | - | - | |
Parenthesized initialization of aggregates (P0960R3, P1975R0) | - | - | - | - | - | - |
+ (Clang 11) | - | - | - | - | - | |
Partially | - | - | - | - | - | |
Modules: P1979R0, P1779R3, P1857R3, P1815R2, P1811R0, P1703R1 | - | - | - | - | - | - |
Coroutines (P0912R5) | Partially | Clangd | Clangd | Mixed | Built-in engine | - |
Deprecate | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
Deprecate some problematic uses of | + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
| + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
| + | Clangd | Clangd | Mixed, relying on Clangd | - | - |
Class template argument deduction for aggregates (P1816R0, P2082R1) | - | - | - | - | - | - |
Class template argument deduction for alias templates (P1814R0) | - | - | - | - | - | - |
Permit conversions to arrays of unknown bound (P0388R4) | - | - | - | - | - | - |
| + | Clangd | Clangd | Mixed | Built-in engine | - |
+ (Clang 11) | - | - | - | - | - | |
+ | Clangd | Clangd | Mixed, relying on Clangd | - | - |
C++17
Language feature | Error highlighting and quick-fixes | Completion | Navigation | Refactorings |
---|---|---|---|---|
Clangd | Clangd | Mixed, relying on Clangd | - | |
Clangd | Clangd | Mixed, relying on Clangd | - | |
Clangd | Clangd | Mixed, relying on Clangd | - | |
Clangd | Clangd | Mixed, relying on Clangd | - | |
Clangd | Clangd | Mixed, relying on Clangd | - | |
Clangd | Clangd | Mixed, relying on Clangd | - | |
Clangd | Clangd | Mixed, relying on Clangd | - | |
Clangd | Clangd | Mixed, relying on Clangd | - | |
Clangd | Clangd | Mixed, relying on Clangd | - | |
Clangd | Clangd | Mixed, relying on Clangd | - | |
Clangd | Clangd | Mixed, relying on Clangd | - | |
Clangd | Clangd | Mixed, relying on Clangd | - | |
nested namespace definition | Clangd | Clangd only, both, or built-in only * | Mixed ** | Build-in engine |
Clangd | Clangd only, both, or built-in only * | Mixed ** | - | |
Clangd | Clangd only, both, or built-in only * | Mixed ** | - | |
Clangd | Clangd | - | - |
* - 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.
C++ code inspections
CLion performs static analysis on your C/C++ code using a set of inspections, configurable in . 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 |