aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/Cflow.ml
Commit message (Collapse)AuthorAgeFilesLines
* Cflow: analysis of "switch" was too impreciseXavier Leroy2017-02-071-2/+3
| | | | Plus: updated comments.
* Revised, more precise implementation of control-flow analysisXavier Leroy2017-02-071-48/+98
| | | | The new implementation keeps track of goto labels that are actually branched to. It is less optimized than the previous implementation (no bit vectors) but perhaps easier to read.
* Control-flow analysis: wrong flow for "case"/"default" statementsXavier Leroy2017-02-071-4/+6
| | | | Those labeled statements can be entered either by fall-through or by the enclosing switch.
* More precise warnings about function returnsXavier Leroy2017-02-071-0/+195
This commit introduces a control-flow static analysis over C abstract syntax (file cparser/Cflow.ml) and uses it to - warn for non-void functions that can return by falling through the body - warn more precisely for _Noreturn functions that can return - introduce the "return 0" in "main" functions less often (cosmetic). For the control-flow analysis, the following conservative approximations are made: - any "goto" label is reachable - all cases of a "switch" statement are reachable as soon as the "switch" is reachable (i.e. the switch expression takes all values needed to reach every case) - the boolean expressions in "if", "while", "do"-"while" and "for" can take true and false values, unless they are compile-time constants.