Skip to content

Commit d89967c

Browse files
committed
C++: Add ''isLiveAtEndOfBlock' predicate to 'Definition'.
1 parent dd41538 commit d89967c

File tree

1 file changed

+13
-0
lines changed
  • cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal

1 file changed

+13
-0
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImpl.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,11 @@ module SsaCached {
940940
SsaImpl::phiHasInputFromBlock(phi, inp, bb)
941941
}
942942

943+
cached
944+
predicate ssaDefReachesEndOfBlock(IRBlock bb, Definition def) {
945+
SsaImpl::ssaDefReachesEndOfBlock(bb, def, _)
946+
}
947+
943948
predicate variableRead = SsaInput::variableRead/4;
944949

945950
predicate variableWrite = SsaInput::variableWrite/4;
@@ -1176,6 +1181,14 @@ class Definition extends SsaImpl::Definition {
11761181
SsaImpl::uncertainWriteDefinitionInput(this, result)
11771182
}
11781183

1184+
/**
1185+
* Holds if this SSA definition is live at the end of basic block `bb`.
1186+
* That is, this definition reaches the end of basic block `bb`, at which
1187+
* point it is still live, without crossing another SSA definition of the
1188+
* same source variable.
1189+
*/
1190+
predicate isLiveAtEndOfBlock(IRBlock bb) { ssaDefReachesEndOfBlock(bb, this) }
1191+
11791192
/**
11801193
* Gets a definition that ultimately defines this SSA definition and is
11811194
* not itself a phi node.

0 commit comments

Comments
 (0)