List of C/C++ inspections
Data flow analysis
Inspection | Description | Default Severity |
---|---|---|
Constant condition | Analyzes method control and data flow to report conditions that are always true or false and expressions with statically constant values. | Warning |
Constant function result | Detects functions whose return value is always equal to the same constant. | Warning |
Constant parameter | Detects functions where a parameter is always equal to the same constant. | Warning |
Dangling pointer | Detects pointers that point to invalid data, typical cases are double-free and use-after-free problems. Check out this parent ticket for the list of limitations. | Warning |
Endless loop | Detects the | Warning |
Infinite recursion | Detects when a function produces infinite recursion. | Warning |
Local value escapes scope | Detects variables that reference local values that escape their scope. | Warning |
Loop condition isn't updated inside the loop | Detects situations where a loop condition is not updated inside the loop, which can cause an infinite loop. There is a similar inspection in Clang-Tidy, | Warning |
Missing return | Reports when a non-void function doesn't have a | Warning |
Not initialized variable | Detects the local variables that haven't been initialized before usage. | Warning |
Null dereference | Detects dereferences of pointers that may contain the | Warning |
Unreachable calls of function | Detects functions whose call sites are never executed. | Warning |
Unreachable code | Detects the code that is never executed (dead code). | Warning |
Unused local variable | Detects the variables that are declared but not used and never accessed for reading. | Warning |
Unused parameter | Detects the parameters that are declared but not used and never accessed for reading. | Warning |
Unused value | Reports the cases when the value of a variable is never used after the assignment. Clear the Warn about unused variable initializers checkbox to disable the inspection for default variable initializers (for example, if you prefer to assign | Warning |
Declaration order
Inspection | Description | Default Severity |
---|---|---|
Function implicit declaration | Reports when a function is used prior to being declared. | Warning |
Hides upper scope | Reports local variables declared in the scope of other local variables or parameters with the same name. | Warning |
Functions
Inspection | Description | Default Severity |
---|---|---|
Hiding non-virtual function | Reports when a function hides non-virtual functions with the same signature from the base class. | Warning |
Not implemented function | Detects when a function is declared but not defined. | Warning |
Passing arguments to function with K&R unspecified parameters syntax | Reports when a function with the K&R parameters syntax uses a non-empty argument list. | Warning |
General
Inspection | Description | Default Severity |
---|---|---|
Argument selection defect | Compares the names of arguments in a call and formal parameter names in the declaration to detect the errors like accidental switching of the arguments. See Inspection: Argument selection defects for details. | Warning |
Clang-Tidy | Performs various clang-tidy checks related to C++ Core Guidelines, code modernization, readability, and performance issues. See Clang-Tidy integration for details. | Warning |
Clazy | Performs Qt-related clazy checks. | Warning |
Duplicate switch case | Reports duplicated | Warning |
Empty declaration or statement | Reports the redundant empty declarations and statements that can be safely removed. | Warning |
Format specifiers | Detects when a call to a string format function (such as | Warning |
'=' in conditional expression | Detects when the | Warning |
Inconsistent Naming | Reports when a symbol violates the currently selected naming convention. Find more details in Inspecting code for violations of the naming rules. | Disabled |
MISRA checks | Performs the checks defined by the MISRA C 2012 and MISRA C++ 2008 guidelines. See the list of currently supported checks. You can adjust the list of checks in the Options section. Note that on Windows with MSVC (including the case of clang-cl), CLion shows only the MISRA C++ checks. MISRA C checks can't be shown correctly because they apply to a specific language standard configurable via the | |
Missing switch case | Reports when a | Warning |
Preprocessor directive comment | Finds cases where a preprocessor | Warning |
Resource not found | Reports unresolved references to resources like NIBs, images, and others. | Warning |
Simplifiable statement | Suggests to simplify the following types of statements:
| Warning |
Unconstrained variable type | Suggests constraining local variables declared as This inspection is disabled by default on Windows and is not supported for concepts declared with the | Warning |
Usage of deprecated API | Detects the usages of deprecated code in the specified scope. | Warning |
Virtual call from constructor or destructor | Reports when a virtual function is called from a constructor or destructor, helping to prevent situations when virtual functions access the resources that are not yet initialized or have already been destroyed. | Warning |
Type checks
Inspection | Description | Default Severity |
---|---|---|
Implicit integer and enum conversion | Detects when a num type expression is used in the context of an integer or pointer type, and vice versa. | Warning |
Implicit pointer and integer conversion | Detects when an integer type expression is used in the context of a pointer type, and vice versa. | Warning |
Incompatible enums | Reports the cases when an expression of the enum type A is used in the context of another enum type B (assigned, casted, used in a parameter, returned from a method, function or a block, and so on). | Warning |
Incompatible initializers | Reports the cases when a variable initializer doesn't match the declared type. For example, when there are too many initializers for an array or structure. | Warning |
Incompatible pointers | Reports when an expression of a pointer type A is used in the context of another pointer type B (assigned, casted, used in a parameter, returned from a method, function or a block, and so on). This inspection doesn't check class type pointers. | Warning |
Not superclass | Reports when an expression of type A is used in the context of type B, whereas A and B are class types, and B is not a superclass of A. | Warning |
Redundant cast | Reports unnecessary type cast expressions. | Warning |
Signedness mismatch | Reports when an expression of a signed type is used in the context of an unsigned type (assigned, casted, used in a parameter, returned from a method, function or a block, and so on). | Warning |
Value may not fit into receiver | Reports when an expression of type A is used in the context of type B, while the range of values in type B is not large enough to store all possible values of type A. | Warning |
Unused code
Inspection | Description | Default Severity |
---|---|---|
Unused concepts | Detects C++ concepts that are never used. | Warning |
Unused expression result | Reports the expressions whose results are never used. | Warning |
Unused global declaration | Detects when a global function or variable is declared but never accessed or written. | Warning |
Unused include directive | Reports the unused or unrequired See Inspection: Unused include directive for details. | Warning |
Unused macro | Detects macro definitions that are never used in the code. | Warning |
Unused struct | Detects C/C++ classes and structures that are never used. | Warning |
Unused template parameter | Detects C++ class and function template parameters that are never used. | Warning |
Unused type alias | Reports using statements that are never used. |