mirror of
https://github.com/github/codeql.git
synced 2026-03-05 15:16:47 +01:00
32 lines
1.2 KiB
Plaintext
32 lines
1.2 KiB
Plaintext
import cpp
|
|
import semmle.code.cpp.controlflow.SubBasicBlocks
|
|
|
|
string subBasicBlockDebugInfo(SubBasicBlock sbb) {
|
|
result = sbb.getStart().toString() +
|
|
" [line " + sbb.getStart().getLocation().getStartLine() + "-" +
|
|
sbb.getEnd().getLocation().getEndLine() + ", " +
|
|
sbb.getNumberOfNodes() + " nodes, " +
|
|
"pos " + sbb.getPosInBasicBlock(_) +
|
|
any(string s | if sbb.firstInBB() then s = " (first in BB)" else s = "") +
|
|
any(string s | if sbb.lastInBB() then s = " (last in BB)" else s = "") +
|
|
", " +
|
|
count(sbb.getAPredecessor()) + " predecessors, " +
|
|
count(sbb.getASuccessor()) + " successors" +
|
|
"]"
|
|
}
|
|
|
|
predicate isNode(boolean isEdge, SubBasicBlock x, SubBasicBlock y, string label) {
|
|
isEdge = false and
|
|
x = y and
|
|
label = subBasicBlockDebugInfo(x)
|
|
}
|
|
|
|
predicate isSuccessor(boolean isEdge, SubBasicBlock x, SubBasicBlock y, string label) {
|
|
exists(string truelabel, string falselabel |
|
|
isEdge = true
|
|
and x.getASuccessor() = y
|
|
and if x.getATrueSuccessor() = y then truelabel = "T" else truelabel = ""
|
|
and if x.getAFalseSuccessor() = y then falselabel = "F" else falselabel = ""
|
|
and label = truelabel + falselabel)
|
|
}
|