Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e940d7

Browse files
committed
CPP: Improve nonReturningFunction.
1 parent 1a62296 commit 6e940d7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cpp/ql/src/semmle/code/cpp/controlflow/internal/ConstantExprs.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,23 @@ private predicate impossibleDefaultSwitchEdge(Block switchBlock, DefaultCase dc)
138138

139139
/**
140140
* Holds if the function `f` never returns due to not containing a return
141-
* statement (explicit or compiler generated). Reachability of return
141+
* statement (explicit or compiler generated). This can be thought of as
142+
* a lightweight `potentiallyReturningFunction`- reachability of return
142143
* statements is not checked.
143144
*/
144145
private predicate nonReturningFunction(Function f)
145146
{
146147
exists(f.getBlock()) and
147-
not exists(ReturnStmt ret | ret.getEnclosingFunction() = f)
148+
not exists(ReturnStmt ret | ret.getEnclosingFunction() = f) and
149+
not getOptions().exits(f)
148150
}
149151

150152
/**
151153
* An edge from a call to a function that never returns is impossible.
152154
*/
153155
private predicate impossibleFunctionReturn(FunctionCall fc, Node succ) {
154156
nonReturningFunction(fc.getTarget()) and
157+
not fc.isVirtual() and
155158
successors_extended(fc, succ)
156159
}
157160

0 commit comments

Comments
 (0)