Skip to content

Commit 9eca56c

Browse files
authored
Merge pull request github#10779 from MathiasVP/add-uninitialized-dataflow-predicate-to-ir-dataflow
C++: Add `UninitializedNode` to experimental IR dataflow
2 parents 9bd2522 + f88aaf3 commit 9eca56c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

cpp/ql/lib/experimental/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ class Node extends TIRDataFlowNode {
231231
/** Gets the positional parameter corresponding to this node, if any. */
232232
Parameter asParameter() { result = asParameter(0) }
233233

234+
/**
235+
* Gets the uninitialized local variable corresponding to this node, if
236+
* any.
237+
*/
238+
LocalVariable asUninitialized() { result = this.(UninitializedNode).getLocalVariable() }
239+
234240
/**
235241
* Gets the positional parameter corresponding to the node that represents
236242
* the value of the parameter after `index` number of loads, if any. For
@@ -666,6 +672,25 @@ class IndirectOperand extends Node, TIndirectOperand {
666672
}
667673
}
668674

675+
/**
676+
* The value of an uninitialized local variable, viewed as a node in a data
677+
* flow graph.
678+
*/
679+
class UninitializedNode extends Node {
680+
LocalVariable v;
681+
682+
UninitializedNode() {
683+
exists(Ssa::Def def |
684+
def.getDefiningInstruction() instanceof UninitializedInstruction and
685+
Ssa::nodeToDefOrUse(this, def) and
686+
v = def.getSourceVariable().getBaseVariable().(Ssa::BaseIRVariable).getIRVariable().getAst()
687+
)
688+
}
689+
690+
/** Gets the uninitialized local variable corresponding to this node. */
691+
LocalVariable getLocalVariable() { result = v }
692+
}
693+
669694
/**
670695
* INTERNAL: Do not use.
671696
*

0 commit comments

Comments
 (0)