C++: Add 'UninitializedNode' to IR dataflow.

This commit is contained in:
Mathias Vorreiter Pedersen
2022-10-11 16:08:06 +01:00
parent 7ac9c1e832
commit f88aaf37a5

View File

@@ -231,6 +231,12 @@ class Node extends TIRDataFlowNode {
/** Gets the positional parameter corresponding to this node, if any. */
Parameter asParameter() { result = asParameter(0) }
/**
* Gets the uninitialized local variable corresponding to this node, if
* any.
*/
LocalVariable asUninitialized() { result = this.(UninitializedNode).getLocalVariable() }
/**
* Gets the positional parameter corresponding to the node that represents
* the value of the parameter after `index` number of loads, if any. For
@@ -666,6 +672,25 @@ class IndirectOperand extends Node, TIndirectOperand {
}
}
/**
* The value of an uninitialized local variable, viewed as a node in a data
* flow graph.
*/
class UninitializedNode extends Node {
LocalVariable v;
UninitializedNode() {
exists(Ssa::Def def |
def.getDefiningInstruction() instanceof UninitializedInstruction and
Ssa::nodeToDefOrUse(this, def) and
v = def.getSourceVariable().getBaseVariable().(Ssa::BaseIRVariable).getIRVariable().getAst()
)
}
/** Gets the uninitialized local variable corresponding to this node. */
LocalVariable getLocalVariable() { result = v }
}
/**
* INTERNAL: Do not use.
*