Skip to content

Commit 6e3ddde

Browse files
committed
C++: Use iterator flow in dataflow.
1 parent 683fe26 commit 6e3ddde

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ private newtype TIRDataFlowNode =
4646
Ssa::isModifiableByCall(operand, indirectionIndex)
4747
} or
4848
TSsaPhiNode(Ssa::PhiNode phi) or
49+
TSsaIteratorNode(IteratorFlow::IteratorFlowNode n) or
4950
TRawIndirectOperand0(Node0Impl node, int indirectionIndex) {
5051
Ssa::hasRawIndirectOperand(node.asOperand(), indirectionIndex)
5152
} or
@@ -653,6 +654,30 @@ class SsaPhiNode extends Node, TSsaPhiNode {
653654
predicate isPhiRead() { phi.isPhiRead() }
654655
}
655656

657+
/**
658+
* INTERNAL: do not use.
659+
*
660+
* Dataflow nodes necessary for iterator flow
661+
*/
662+
class SsaIteratorNode extends Node, TSsaIteratorNode {
663+
IteratorFlow::IteratorFlowNode node;
664+
665+
SsaIteratorNode() { this = TSsaIteratorNode(node) }
666+
667+
/** Gets the phi node associated with this node. */
668+
IteratorFlow::IteratorFlowNode getIteratorFlowNode() { result = node }
669+
670+
override Declaration getEnclosingCallable() { result = this.getFunction() }
671+
672+
override Declaration getFunction() { result = node.getFunction() }
673+
674+
override DataFlowType getType() { result = node.getType() }
675+
676+
final override Location getLocationImpl() { result = node.getLocation() }
677+
678+
override string toStringImpl() { result = node.toString() }
679+
}
680+
656681
/**
657682
* INTERNAL: do not use.
658683
*
@@ -2151,6 +2176,8 @@ private module Cached {
21512176
// Def-use/Use-use flow
21522177
Ssa::ssaFlow(nodeFrom, nodeTo)
21532178
or
2179+
IteratorFlow::localFlowStep(nodeFrom, nodeTo)
2180+
or
21542181
// Operand -> Instruction flow
21552182
simpleInstructionLocalFlowStep(nodeFrom.asOperand(), nodeTo.asInstruction())
21562183
or

0 commit comments

Comments
 (0)