[PATCH] D39398: [CFG][Analyzer] Add LoopExit element to the CFG in more cases
Peter Szecsi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 27 18:25:52 PDT 2017
szepet created this revision.
Herald added subscribers: baloghadamsoftware, whisperity.
This patch adds a LoopExit element to the CFG whenever a loop is exited by a ReturnStmt, GotoStmt or IndirectGotoStmt.
The LoopExit element is consumed by the Static Analyzer in order to simulate the loops more precisely. This patch aims to ensure that the simulation will be always consistent. So, whenever a loop is entered a loop exit element will be encountered after leaving it.
The idea is the following: In cases where a 'jump' is made we check (by walking up on the AST) the containing loops for both (From and To) locations. Then, generate the LoopExit element for the exited loops (which is the difference of the two "containing loop" set.
Note: In case of IndirectGotoStmt, it could happen that we generate LoopExit elements even for loops which is not exited by that jump. However, it does not seem to be a problem. This could result that we can not apply some more precise modeling feature (like unrolling and widening) but not any more - as I can see. (Also, this is a rare case.)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 19511 bytes
Desc: not available
More information about the cfe-commits