@@ -13,6 +13,7 @@ private import semmle.code.cpp.models.interfaces.DataFlow
1313
1414private newtype TIRDataFlowNode =
1515 TInstructionNode ( Instruction i ) or
16+ TOperandNode ( Operand op ) or
1617 TVariableNode ( Variable var )
1718
1819/**
@@ -37,6 +38,9 @@ class Node extends TIRDataFlowNode {
3738 /** Gets the instruction corresponding to this node, if any. */
3839 Instruction asInstruction ( ) { result = this .( InstructionNode ) .getInstruction ( ) }
3940
41+ /** Gets the operands corresponding to this node, if any. */
42+ Operand asOperand ( ) { result = this .( OperandNode ) .getOperand ( ) }
43+
4044 /**
4145 * Gets the non-conversion expression corresponding to this node, if any. If
4246 * this node strictly (in the sense of `asConvertedExpr`) corresponds to a
@@ -132,6 +136,28 @@ class InstructionNode extends Node, TInstructionNode {
132136 }
133137}
134138
139+ /**
140+ * An operand, viewed as a node in a data flow graph.
141+ */
142+ class OperandNode extends Node , TOperandNode {
143+ Operand op ;
144+
145+ OperandNode ( ) { this = TOperandNode ( op ) }
146+
147+ /** Gets the operand corresponding to this node. */
148+ Operand getOperand ( ) { result = op }
149+
150+ override Declaration getEnclosingCallable ( ) { result = this .getFunction ( ) }
151+
152+ override Function getFunction ( ) { result = op .getUse ( ) .getEnclosingFunction ( ) }
153+
154+ override Type getType ( ) { result = op .getType ( ) }
155+
156+ override Location getLocation ( ) { result = op .getLocation ( ) }
157+
158+ override string toString ( ) { result = this .getOperand ( ) .toString ( ) }
159+ }
160+
135161/**
136162 * An expression, viewed as a node in a data flow graph.
137163 */
0 commit comments