Data flow analysis
Data flow analysis (DFA) tracks the flow of data in your code and detects potential issues based on that analysis. For example, DFA checks can identify conditions that are always false or always true, endless loops, missing return statements, infinite recursion, and other potential vulnerabilities.
DFA can work globally (taking a whole translation unit of a program as a single unit for analysis) or locally (within a single function).
Global DFA works within the translation unit on all usages of the functions or fields that are guaranteed to be local inside it. This helps detect potential issues which can’t be captured by Local DFA. For example, dangling pointer analysis with Global DFA can capture cases when memory is deleted in another function:
In CLion, Global DFA is enabled by default, however, it falls back to the local mode in the following cases:
There is an error in any of the functions within the translation unit reported by Clangd.
The file is included in another translation unit.
Global DFA is manually turned off via the Registry key clion.dfa.global (which is not recommended unless you face a critical regression).
Some of the DFA inspections can work both globally and locally, while the following three are only available in Global DFA: Constant function result, Constant parameter, and Unreachable calls of function.