Files
codeql/csharp/ql/test/library-tests/obinit/ObInit.ql
Anders Schack-Mulligen ff978d1a8c C#: Replace CFG.
2026-04-10 15:47:13 +02:00

27 lines
755 B
Plaintext

import csharp
query predicate method(ObjectInitMethod m, RefType t) { m.getDeclaringType() = t }
query predicate call(Call c, ObjectInitMethod m, Callable src) {
c.getTarget() = m and c.getEnclosingCallable() = src
}
predicate scope(Callable callable, ControlFlowNode n, int i) {
(callable instanceof ObjectInitMethod or callable instanceof Constructor) and
n.(ControlFlow::EntryNode).getEnclosingCallable() = callable and
i = 0
or
exists(ControlFlowNode prev |
scope(callable, prev, i - 1) and
n = prev.getASuccessor() and
i < 30
)
}
query predicate cfg(
Callable callable, ControlFlowNode pred, ControlFlowNode succ, ControlFlow::SuccessorType c, int i
) {
scope(callable, pred, i) and
pred.getASuccessor(c) = succ
}