@@ -17,13 +17,19 @@ private import codeql.rust.dataflow.FlowSummary
1717private import Node as Node
1818private import DataFlowImpl
1919private import FlowSummaryImpl as FlowSummaryImpl
20+ private import codeql.rust.internal.CachedStages
2021
2122/** An element, viewed as a node in a data flow graph. */
22- abstract class NodePublic extends TNode {
23+ // It is important to not make this class `abstract`, as it otherwise results in
24+ // a needless charpred, which will result in recomputation of internal non-cached
25+ // predicates
26+ class NodePublic extends TNode {
2327 /** Gets the location of this node. */
28+ cached
2429 abstract Location getLocation ( ) ;
2530
2631 /** Gets a textual representation of this node. */
32+ cached
2733 abstract string toString ( ) ;
2834
2935 /**
@@ -55,17 +61,6 @@ abstract class Node extends NodePublic {
5561 CfgNode getCfgNode ( ) { none ( ) }
5662}
5763
58- /** A node type that is not implemented. */
59- final class NaNode extends Node {
60- NaNode ( ) { none ( ) }
61-
62- override CfgScope getCfgScope ( ) { none ( ) }
63-
64- override string toString ( ) { result = "N/A" }
65-
66- override Location getLocation ( ) { none ( ) }
67- }
68-
6964/** A data flow node used to model flow summaries. */
7065class FlowSummaryNode extends Node , TFlowSummaryNode {
7166 FlowSummaryImpl:: Private:: SummaryNode getSummaryNode ( ) { this = TFlowSummaryNode ( result ) }
@@ -108,6 +103,7 @@ class FlowSummaryNode extends Node, TFlowSummaryNode {
108103 }
109104
110105 override Location getLocation ( ) {
106+ Stages:: DataFlowStage:: ref ( ) and
111107 exists ( this .getSummarizedCallable ( ) ) and
112108 result instanceof EmptyLocation
113109 or
@@ -116,7 +112,10 @@ class FlowSummaryNode extends Node, TFlowSummaryNode {
116112 result = this .getSinkElement ( ) .getLocation ( )
117113 }
118114
119- override string toString ( ) { result = this .getSummaryNode ( ) .toString ( ) }
115+ override string toString ( ) {
116+ Stages:: DataFlowStage:: ref ( ) and
117+ result = this .getSummaryNode ( ) .toString ( )
118+ }
120119}
121120
122121/** A data flow node that corresponds directly to a CFG node for an AST node. */
@@ -440,9 +439,9 @@ private class CapturePostUpdateNode extends PostUpdateNode, CaptureNode {
440439 final override string toString ( ) { result = PostUpdateNode .super .toString ( ) }
441440}
442441
443- final class CastNode = NaNode ;
444-
445- private import codeql.rust.internal.CachedStages
442+ final class CastNode extends ExprNode {
443+ CastNode ( ) { none ( ) }
444+ }
446445
447446cached
448447newtype TNode =
0 commit comments