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

Skip to content

Commit 50ad4cf

Browse files
committed
C++: Add comments to {Array,Pointer}StoreNode and arrayStoreStepChi.
1 parent 0c14e2b commit 50ad4cf

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,15 @@ private predicate arrayStoreStepChi(Node node1, ArrayContent a, PostUpdateNode n
244244
node1.asInstruction() = store and
245245
(
246246
// `x[i] = taint()`
247+
// This matches the characteristic predicate in `ArrayStoreNode`.
247248
store.getDestinationAddress() instanceof PointerAddInstruction
248249
or
249250
// `*p = taint()`
251+
// This matches the characteristic predicate in `PointerStoreNode`.
250252
store.getDestinationAddress().(CopyValueInstruction).getUnary() instanceof LoadInstruction
251253
) and
254+
// This `ChiInstruction` will always have a non-conflated result because both `ArrayStoreNode`
255+
// and `PointerStoreNode` require it in their characteristic predicates.
252256
node2.asInstruction().(ChiInstruction).getPartial() = store
253257
)
254258
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ private class ExplicitSingleFieldStoreQualifierNode extends PartialDefinitionNod
389389
}
390390
}
391391

392+
/**
393+
* The `PostUpdateNode` that is the target of a `arrayStoreStepChi` store step. The overriden
394+
* `ChiInstruction` corresponds to the instruction represented by `node2` in `arrayStoreStepChi`.
395+
*/
392396
private class ArrayStoreNode extends PartialDefinitionNode {
393397
override ChiInstruction instr;
394398
PointerAddInstruction add;
@@ -406,6 +410,10 @@ private class ArrayStoreNode extends PartialDefinitionNode {
406410
override Expr getDefinedExpr() { result = add.getLeft().getUnconvertedResultExpression() }
407411
}
408412

413+
/**
414+
* The `PostUpdateNode` that is the target of a `arrayStoreStepChi` store step. The overriden
415+
* `ChiInstruction` corresponds to the instruction represented by `node2` in `arrayStoreStepChi`.
416+
*/
409417
private class PointerStoreNode extends PostUpdateNode {
410418
override ChiInstruction instr;
411419

0 commit comments

Comments
 (0)