Skip to content

Commit fd915bb

Browse files
committed
C++: fix join order in IR virtual dispatch
1 parent a061811 commit fd915bb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowDispatch.qll

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ private module VirtualDispatch {
7070
// Call return
7171
exists(DataFlowCall call, ReturnKind returnKind |
7272
other = getAnOutNode(call, returnKind) and
73-
src.(ReturnNode).getKind() = returnKind and
74-
call.getStaticCallTarget() = src.getEnclosingCallable()
73+
returnNodeWithKindAndEnclosingCallable(src, returnKind, call.getStaticCallTarget())
7574
) and
7675
allowFromArg = false
7776
or
@@ -125,6 +124,16 @@ private module VirtualDispatch {
125124
}
126125
}
127126

127+
/**
128+
* A ReturnNode with its ReturnKind and its enclosing callable.
129+
*
130+
* Used to fix a join ordering issue in flowsFrom.
131+
*/
132+
private predicate returnNodeWithKindAndEnclosingCallable(ReturnNode node, ReturnKind kind, DataFlowCallable callable) {
133+
node.getKind() = kind and
134+
node.getEnclosingCallable() = callable
135+
}
136+
128137
/** Call through a function pointer. */
129138
private class DataSensitiveExprCall extends DataSensitiveCall {
130139
DataSensitiveExprCall() { not exists(this.getStaticCallTarget()) }

0 commit comments

Comments
 (0)