mirror of
https://github.com/github/codeql.git
synced 2025-12-19 18:33:16 +01:00
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
27 lines
770 B
Plaintext
27 lines
770 B
Plaintext
/**
|
|
* @name Guards comparison test
|
|
* @description List comparison parts.
|
|
* @kind test
|
|
*/
|
|
|
|
import cpp
|
|
import semmle.code.cpp.controlflow.Guards
|
|
|
|
from GuardCondition guard, Expr left, Expr right, int k, string which, string op, string msg
|
|
where
|
|
exists(boolean sense |
|
|
sense = true and which = "true"
|
|
or
|
|
sense = false and which = "false"
|
|
|
|
|
guard.comparesLt(left, right, k, true, sense) and op = " < "
|
|
or
|
|
guard.comparesLt(left, right, k, false, sense) and op = " >= "
|
|
or
|
|
guard.comparesEq(left, right, k, true, sense) and op = " == "
|
|
or
|
|
guard.comparesEq(left, right, k, false, sense) and op = " != "
|
|
) and
|
|
msg = left + op + right + "+" + k + " when " + guard + " is " + which
|
|
select guard.getLocation().getStartLine(), msg
|