Files
codeql/cpp/ql/test/library-tests/rangeanalysis/RangeSSA/RangeSsaDominance.ql
Jonas Jensen 95a333d28c C++: Use StackVariable in SSA libraries
This means we'll no longer get SSA definitions for thread-local
local-scope variables.
2019-11-19 11:30:59 +01:00

27 lines
724 B
Plaintext

/**
* @name SSA dominance property test
* @description SSA dominance property test. SSA definitions *must* dominate all uses
* @kind test
*/
import cpp
import semmle.code.cpp.rangeanalysis.RangeSSA
/*
* Count of number of SSA def-use pairs where the defn does not dominate the use.
* Should always be zero *regardless* of the input
*/
select count(RangeSsaDefinition d, StackVariable v, Expr u |
d.getAUse(v) = u and
not exists(BasicBlock bd, BasicBlock bu |
bd.contains(mkElement(d).(ControlFlowNode)) and bu.contains(u)
|
bbStrictlyDominates(bd, bu)
or
exists(int i, int j |
bd = bu and bd.getNode(i) = mkElement(d) and bu.getNode(j) = u and i <= j
)
)
)