Skip to content

Commit 4cbfc30

Browse files
committed
C++: Hide dataflow nodes if they're just used for flow-through for read steps or store steps.
1 parent 8c9e817 commit 4cbfc30

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,17 @@ predicate isImmutableOrUnobservable(Node n) {
299299
}
300300

301301
/** Holds if `n` should be hidden from path explanations. */
302-
predicate nodeIsHidden(Node n) { n instanceof OperandNode and not n instanceof ArgumentNode }
302+
predicate nodeIsHidden(Node n) {
303+
n instanceof OperandNode and not n instanceof ArgumentNode
304+
or
305+
StoreNodeFlow::flowThrough(n, _) and
306+
not StoreNodeFlow::flowOutOf(n, _) and
307+
not StoreNodeFlow::flowInto(_, n)
308+
or
309+
ReadNodeFlow::flowThrough(n, _) and
310+
not ReadNodeFlow::flowOutOf(n, _) and
311+
not ReadNodeFlow::flowInto(_, n)
312+
}
303313

304314
class LambdaCallKind = Unit;
305315

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,10 @@ private predicate adjacentDefUseFlow(Node nodeFrom, Node nodeTo) {
840840
)
841841
}
842842

843-
private module ReadNodeFlow {
843+
/**
844+
* INTERNAL: Do not use.
845+
*/
846+
module ReadNodeFlow {
844847
/** Holds if the read node `nodeTo` should receive flow from `nodeFrom`. */
845848
predicate flowInto(Node nodeFrom, ReadNode nodeTo) {
846849
nodeTo.isInitial() and

0 commit comments

Comments
 (0)