@@ -4,70 +4,47 @@ private import semmle.code.java.dataflow.FlowSummary
4
4
private import semmle.code.java.dataflow.TypeFlow
5
5
private import DataFlowPrivate
6
6
private import FlowSummaryImpl as FlowSummaryImpl
7
+ private import DataFlowImplCommon as DataFlowImplCommon
7
8
8
9
cached
9
- private module Cached {
10
- cached
11
- newtype TNode =
12
- TExprNode ( Expr e ) {
13
- not e .getType ( ) instanceof VoidType and
14
- not e .getParent * ( ) instanceof Annotation
15
- } or
16
- TExplicitParameterNode ( Parameter p ) {
17
- exists ( p .getCallable ( ) .getBody ( ) ) or p .getCallable ( ) instanceof SummarizedCallable
18
- } or
19
- TImplicitVarargsArray ( Call c ) {
20
- c .getCallee ( ) .isVarargs ( ) and
21
- not exists ( Argument arg | arg .getCall ( ) = c and arg .isExplicitVarargsArray ( ) )
22
- } or
23
- TInstanceParameterNode ( Callable c ) {
24
- ( exists ( c .getBody ( ) ) or c instanceof SummarizedCallable ) and
25
- not c .isStatic ( )
26
- } or
27
- TImplicitInstanceAccess ( InstanceAccessExt ia ) { not ia .isExplicit ( _) } or
28
- TMallocNode ( ClassInstanceExpr cie ) or
29
- TExplicitExprPostUpdate ( Expr e ) {
30
- explicitInstanceArgument ( _, e )
31
- or
32
- e instanceof Argument and not e .getType ( ) instanceof ImmutableType
33
- or
34
- exists ( FieldAccess fa | fa .getField ( ) instanceof InstanceField and e = fa .getQualifier ( ) )
35
- or
36
- exists ( ArrayAccess aa | e = aa .getArray ( ) )
37
- } or
38
- TImplicitExprPostUpdate ( InstanceAccessExt ia ) {
39
- implicitInstanceArgument ( _, ia )
40
- or
41
- exists ( FieldAccess fa |
42
- fa .getField ( ) instanceof InstanceField and ia .isImplicitFieldQualifier ( fa )
43
- )
44
- } or
45
- TSummaryInternalNode ( SummarizedCallable c , FlowSummaryImpl:: Private:: SummaryNodeState state ) {
46
- FlowSummaryImpl:: Private:: summaryNodeRange ( c , state )
47
- }
48
-
49
- cached
50
- predicate summaryOutNodeCached ( DataFlowCall c , Node out ) {
51
- FlowSummaryImpl:: Private:: summaryOutNode ( c , out , _)
52
- }
53
-
54
- cached
55
- predicate summaryArgumentNodeCached ( DataFlowCall c , Node arg , int i ) {
56
- FlowSummaryImpl:: Private:: summaryArgumentNode ( c , arg , i )
57
- }
58
-
59
- cached
60
- predicate summaryPostUpdateNodeCached ( Node post , ParameterNode pre ) {
61
- FlowSummaryImpl:: Private:: summaryPostUpdateNode ( post , pre )
62
- }
63
-
64
- cached
65
- predicate summaryReturnNodeCached ( Node ret ) {
66
- FlowSummaryImpl:: Private:: summaryReturnNode ( ret , _)
10
+ newtype TNode =
11
+ TExprNode ( Expr e ) {
12
+ DataFlowImplCommon:: forceCachingInSameStage ( ) and
13
+ not e .getType ( ) instanceof VoidType and
14
+ not e .getParent * ( ) instanceof Annotation
15
+ } or
16
+ TExplicitParameterNode ( Parameter p ) {
17
+ exists ( p .getCallable ( ) .getBody ( ) ) or p .getCallable ( ) instanceof SummarizedCallable
18
+ } or
19
+ TImplicitVarargsArray ( Call c ) {
20
+ c .getCallee ( ) .isVarargs ( ) and
21
+ not exists ( Argument arg | arg .getCall ( ) = c and arg .isExplicitVarargsArray ( ) )
22
+ } or
23
+ TInstanceParameterNode ( Callable c ) {
24
+ ( exists ( c .getBody ( ) ) or c instanceof SummarizedCallable ) and
25
+ not c .isStatic ( )
26
+ } or
27
+ TImplicitInstanceAccess ( InstanceAccessExt ia ) { not ia .isExplicit ( _) } or
28
+ TMallocNode ( ClassInstanceExpr cie ) or
29
+ TExplicitExprPostUpdate ( Expr e ) {
30
+ explicitInstanceArgument ( _, e )
31
+ or
32
+ e instanceof Argument and not e .getType ( ) instanceof ImmutableType
33
+ or
34
+ exists ( FieldAccess fa | fa .getField ( ) instanceof InstanceField and e = fa .getQualifier ( ) )
35
+ or
36
+ exists ( ArrayAccess aa | e = aa .getArray ( ) )
37
+ } or
38
+ TImplicitExprPostUpdate ( InstanceAccessExt ia ) {
39
+ implicitInstanceArgument ( _, ia )
40
+ or
41
+ exists ( FieldAccess fa |
42
+ fa .getField ( ) instanceof InstanceField and ia .isImplicitFieldQualifier ( fa )
43
+ )
44
+ } or
45
+ TSummaryInternalNode ( SummarizedCallable c , FlowSummaryImpl:: Private:: SummaryNodeState state ) {
46
+ FlowSummaryImpl:: Private:: summaryNodeRange ( c , state )
67
47
}
68
- }
69
-
70
- private import Cached
71
48
72
49
private predicate explicitInstanceArgument ( Call call , Expr instarg ) {
73
50
call instanceof MethodAccess and
@@ -404,13 +381,15 @@ module Private {
404
381
override string toString ( ) { result = "[summary] " + state + " in " + c }
405
382
406
383
/** Holds if this summary node is the `i`th argument of `call`. */
407
- predicate isArgumentOf ( DataFlowCall call , int i ) { summaryArgumentNodeCached ( call , this , i ) }
384
+ predicate isArgumentOf ( DataFlowCall call , int i ) {
385
+ FlowSummaryImpl:: Private:: summaryArgumentNode ( call , this , i )
386
+ }
408
387
409
388
/** Holds if this summary node is a return node. */
410
- predicate isReturn ( ) { summaryReturnNodeCached ( this ) }
389
+ predicate isReturn ( ) { FlowSummaryImpl :: Private :: summaryReturnNode ( this , _ ) }
411
390
412
391
/** Holds if this summary node is an out node for `call`. */
413
- predicate isOut ( DataFlowCall call ) { summaryOutNodeCached ( call , this ) }
392
+ predicate isOut ( DataFlowCall call ) { FlowSummaryImpl :: Private :: summaryOutNode ( call , this , _ ) }
414
393
}
415
394
416
395
SummaryNode getSummaryNode ( SummarizedCallable c , FlowSummaryImpl:: Private:: SummaryNodeState state ) {
@@ -439,7 +418,7 @@ private class MallocNode extends Node, TMallocNode {
439
418
private class SummaryPostUpdateNode extends SummaryNode , PostUpdateNode {
440
419
private Node pre ;
441
420
442
- SummaryPostUpdateNode ( ) { summaryPostUpdateNodeCached ( this , pre ) }
421
+ SummaryPostUpdateNode ( ) { FlowSummaryImpl :: Private :: summaryPostUpdateNode ( this , pre ) }
443
422
444
423
override Node getPreUpdateNode ( ) { result = pre }
445
424
}
0 commit comments