File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed
cpp/ql/src/semmle/code/cpp/controlflow/internal Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -15,9 +15,42 @@ predicate abortingFunction(Function f) {
1515 not potentiallyReturningFunction ( f )
1616}
1717
18+ /**
19+ * This relation is the same as the `el instanceof Function`, only obfuscated
20+ * so the optimizer will not understand that any `FunctionCall.getTarget()`
21+ * should be in this relation.
22+ */
23+ pragma [ noinline]
24+ private predicate isFunction ( Element el ) {
25+ el instanceof Function
26+ or
27+ el .( Expr ) .getParent ( ) = el
28+ }
29+
30+ /**
31+ * Holds if `fc` is a `FunctionCall` with no return value for `getTarget`. This
32+ * can happen due to extractor issue CPP-383.
33+ */
34+ pragma [ noopt]
35+ private predicate callHasNoTarget ( @funbindexpr fc ) {
36+ exists ( Function f |
37+ funbind ( fc , f ) and
38+ not isFunction ( f )
39+ )
40+ }
41+
42+ // This base case is pulled out to work around QL-796
43+ private predicate potentiallyReturningFunctionCall_base ( FunctionCall fc ) {
44+ fc .isVirtual ( )
45+ or
46+ callHasNoTarget ( fc )
47+ }
48+
1849/** A function call that *may* return; if in doubt, we assume it may. */
1950private predicate potentiallyReturningFunctionCall ( FunctionCall fc ) {
20- potentiallyReturningFunction ( fc .getTarget ( ) ) or fc .isVirtual ( )
51+ potentiallyReturningFunctionCall_base ( fc )
52+ or
53+ potentiallyReturningFunction ( fc .getTarget ( ) )
2154}
2255
2356/** A function that *may* return; if in doubt, we assume it may. */
You can’t perform that action at this time.
0 commit comments