Skip to content

Commit fdb9f7b

Browse files
committed
C++: Move these predicates to make the diff smaller.
1 parent 42fcfca commit fdb9f7b

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

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

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,39 @@ private import DataFlowPrivate
44
private import DataFlowUtil
55
private import DataFlowImplCommon as DataFlowImplCommon
66

7+
/**
8+
* Holds if `f` has name `qualifiedName` and `nparams` parameter count. This is
9+
* an approximation of its signature for the purpose of matching functions that
10+
* might be the same across link targets.
11+
*/
12+
private predicate functionSignature(Function f, string qualifiedName, int nparams) {
13+
qualifiedName = f.getQualifiedName() and
14+
nparams = f.getNumberOfParameters() and
15+
not f.isStatic()
16+
}
17+
18+
/**
19+
* Holds if `f` is a function with a body that has name `qualifiedName` and
20+
* `nparams` parameter count. See `functionSignature`.
21+
*/
22+
private predicate functionSignatureWithBody(string qualifiedName, int nparams, Function f) {
23+
functionSignature(f, qualifiedName, nparams) and
24+
exists(f.getBlock())
25+
}
26+
27+
/**
28+
* Holds if the target of `call` is a function _with no definition_ that has
29+
* name `qualifiedName` and `nparams` parameter count. See `functionSignature`.
30+
*/
31+
pragma[noinline]
32+
private predicate callSignatureWithoutBody(string qualifiedName, int nparams, CallInstruction call) {
33+
exists(Function target |
34+
target = call.getStaticCallTarget() and
35+
not exists(target.getBlock()) and
36+
functionSignature(target, qualifiedName, nparams)
37+
)
38+
}
39+
740
/**
841
* Gets a function that might be called by `call`.
942
*
@@ -219,39 +252,6 @@ private module VirtualDispatch {
219252
}
220253
}
221254

222-
/**
223-
* Holds if `f` is a function with a body that has name `qualifiedName` and
224-
* `nparams` parameter count. See `functionSignature`.
225-
*/
226-
private predicate functionSignatureWithBody(string qualifiedName, int nparams, Function f) {
227-
functionSignature(f, qualifiedName, nparams) and
228-
exists(f.getBlock())
229-
}
230-
231-
/**
232-
* Holds if the target of `call` is a function _with no definition_ that has
233-
* name `qualifiedName` and `nparams` parameter count. See `functionSignature`.
234-
*/
235-
pragma[noinline]
236-
private predicate callSignatureWithoutBody(string qualifiedName, int nparams, CallInstruction call) {
237-
exists(Function target |
238-
target = call.getStaticCallTarget() and
239-
not exists(target.getBlock()) and
240-
functionSignature(target, qualifiedName, nparams)
241-
)
242-
}
243-
244-
/**
245-
* Holds if `f` has name `qualifiedName` and `nparams` parameter count. This is
246-
* an approximation of its signature for the purpose of matching functions that
247-
* might be the same across link targets.
248-
*/
249-
private predicate functionSignature(Function f, string qualifiedName, int nparams) {
250-
qualifiedName = f.getQualifiedName() and
251-
nparams = f.getNumberOfParameters() and
252-
not f.isStatic()
253-
}
254-
255255
/**
256256
* Holds if the set of viable implementations that can be called by `call`
257257
* might be improved by knowing the call context.

0 commit comments

Comments
 (0)