Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8c0f02a

Browse files
committed
C++: Add summary jumpStep, readStep, storeStep.
1 parent 3657269 commit 8c0f02a

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,10 @@ predicate jumpStep(Node n1, Node n2) {
795795
v = n1.asIndirectVariable(globalDef.getIndirection())
796796
)
797797
)
798+
or
799+
// models-as-data summarized flow
800+
FlowSummaryImpl::Private::Steps::summaryJumpStep(n1.(FlowSummaryNode).getSummaryNode(),
801+
n2.(FlowSummaryNode).getSummaryNode())
798802
}
799803

800804
/**
@@ -805,23 +809,28 @@ predicate jumpStep(Node n1, Node n2) {
805809
* The boolean `certain` is true if the destination address does not involve
806810
* any pointer arithmetic, and false otherwise.
807811
*/
808-
predicate storeStepImpl(Node node1, Content c, PostFieldUpdateNode node2, boolean certain) {
812+
predicate storeStepImpl(Node node1, Content c, Node node2, boolean certain) {
809813
exists(int indirectionIndex1, int numberOfLoads, StoreInstruction store |
810814
nodeHasInstruction(node1, store, pragma[only_bind_into](indirectionIndex1)) and
811-
node2.getIndirectionIndex() = 1 and
812-
numberOfLoadsFromOperand(node2.getFieldAddress(), store.getDestinationAddressOperand(),
813-
numberOfLoads, certain)
815+
node2.(PostFieldUpdateNode).getIndirectionIndex() = 1 and
816+
numberOfLoadsFromOperand(node2.(PostFieldUpdateNode).getFieldAddress(),
817+
store.getDestinationAddressOperand(), numberOfLoads, certain)
814818
|
815819
exists(FieldContent fc | fc = c |
816-
fc.getField() = node2.getUpdatedField() and
820+
fc.getField() = node2.(PostFieldUpdateNode).getUpdatedField() and
817821
fc.getIndirectionIndex() = 1 + indirectionIndex1 + numberOfLoads
818822
)
819823
or
820824
exists(UnionContent uc | uc = c |
821-
uc.getAField() = node2.getUpdatedField() and
825+
uc.getAField() = node2.(PostFieldUpdateNode).getUpdatedField() and
822826
uc.getIndirectionIndex() = 1 + indirectionIndex1 + numberOfLoads
823827
)
824828
)
829+
or
830+
// models-as-data summarized flow
831+
FlowSummaryImpl::Private::Steps::summaryStoreStep(node1.(FlowSummaryNode).getSummaryNode(), c,
832+
node2.(FlowSummaryNode).getSummaryNode()) and
833+
certain = [true, false] // TODO
825834
}
826835

827836
/**
@@ -908,6 +917,10 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
908917
uc.getIndirectionIndex() = indirectionIndex2 + numberOfLoads
909918
)
910919
)
920+
or
921+
// models-as-data summarized flow
922+
FlowSummaryImpl::Private::Steps::summaryReadStep(node1.(FlowSummaryNode).getSummaryNode(), c,
923+
node2.(FlowSummaryNode).getSummaryNode())
911924
}
912925

913926
/**

0 commit comments

Comments
 (0)