Files
codeql/cpp/ql/test/library-tests/sub_basic_blocks/sbb_test.qll
Jonas Jensen 4ef5c9af62 C++: Autoformat everything
Some files that will change in #1736 have been spared.

    ./build -j4 target/jars/qlformat
    find ql/cpp/ql -name "*.ql"  -print0 | xargs -0 target/jars/qlformat --input
    find ql/cpp/ql -name "*.qll" -print0 | xargs -0 target/jars/qlformat --input
    (cd ql && git checkout 'cpp/ql/src/semmle/code/cpp/ir/implementation/**/*SSA*.qll')
    buildutils-internal/scripts/pr-checks/sync-identical-files.py --latest
2019-09-09 11:25:53 +02:00

29 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.getRankInBasicBlock(_) - 1) +
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
)
}