@@ -61,6 +61,20 @@ module Public {
61
61
62
62
/** Gets a summary component for a return of kind `rk`. */
63
63
SummaryComponent return ( ReturnKind rk ) { result = TReturnSummaryComponent ( rk ) }
64
+
65
+ /** Gets a summary component for synthetic global `sg`. */
66
+ SummaryComponent syntheticGlobal ( SyntheticGlobal sg ) {
67
+ result = TSyntheticGlobalSummaryComponent ( sg )
68
+ }
69
+
70
+ /**
71
+ * A synthetic global. This represents some form of global state, which
72
+ * summaries can read and write individually.
73
+ */
74
+ abstract class SyntheticGlobal extends string {
75
+ bindingset [ this ]
76
+ SyntheticGlobal ( ) { any ( ) }
77
+ }
64
78
}
65
79
66
80
/**
@@ -256,6 +270,7 @@ module Private {
256
270
TParameterSummaryComponent ( ArgumentPosition pos ) or
257
271
TArgumentSummaryComponent ( ParameterPosition pos ) or
258
272
TReturnSummaryComponent ( ReturnKind rk ) or
273
+ TSyntheticGlobalSummaryComponent ( SummaryComponent:: SyntheticGlobal sg ) or
259
274
TWithoutContentSummaryComponent ( ContentSet c ) or
260
275
TWithContentSummaryComponent ( ContentSet c )
261
276
@@ -563,6 +578,11 @@ module Private {
563
578
getCallbackReturnType ( getNodeType ( summaryNodeInputState ( pragma [ only_bind_out ] ( c ) ,
564
579
s .tail ( ) ) ) , rk )
565
580
)
581
+ or
582
+ exists ( SummaryComponent:: SyntheticGlobal sg |
583
+ head = TSyntheticGlobalSummaryComponent ( sg ) and
584
+ result = getSyntheticGlobalType ( sg )
585
+ )
566
586
)
567
587
or
568
588
n = summaryNodeOutputState ( c , s ) and
@@ -582,6 +602,11 @@ module Private {
582
602
getCallbackParameterType ( getNodeType ( summaryNodeInputState ( pragma [ only_bind_out ] ( c ) ,
583
603
s .tail ( ) ) ) , pos )
584
604
)
605
+ or
606
+ exists ( SummaryComponent:: SyntheticGlobal sg |
607
+ head = TSyntheticGlobalSummaryComponent ( sg ) and
608
+ result = getSyntheticGlobalType ( sg )
609
+ )
585
610
)
586
611
)
587
612
}
@@ -692,6 +717,18 @@ module Private {
692
717
)
693
718
}
694
719
720
+ /**
721
+ * Holds if there is a jump step from `pred` to `succ`, which is synthesized
722
+ * from a flow summary.
723
+ */
724
+ predicate summaryJumpStep ( Node pred , Node succ ) {
725
+ exists ( SummaryComponentStack s |
726
+ s = SummaryComponentStack:: singleton ( SummaryComponent:: syntheticGlobal ( _) ) and
727
+ pred = summaryNodeOutputState ( _, s ) and
728
+ succ = summaryNodeInputState ( _, s )
729
+ )
730
+ }
731
+
695
732
/**
696
733
* Holds if values stored inside content `c` are cleared at `n`. `n` is a
697
734
* synthesized summary node, so in order for values to be cleared at calls
@@ -871,18 +908,28 @@ module Private {
871
908
AccessPathRange ( ) { relevantSpec ( this ) }
872
909
}
873
910
874
- /** Holds if specification component `c ` parses as parameter `n `. */
911
+ /** Holds if specification component `token ` parses as parameter `pos `. */
875
912
predicate parseParam ( AccessPathToken token , ArgumentPosition pos ) {
876
913
token .getName ( ) = "Parameter" and
877
914
pos = parseParamBody ( token .getAnArgument ( ) )
878
915
}
879
916
880
- /** Holds if specification component `c ` parses as argument `n `. */
917
+ /** Holds if specification component `token ` parses as argument `pos `. */
881
918
predicate parseArg ( AccessPathToken token , ParameterPosition pos ) {
882
919
token .getName ( ) = "Argument" and
883
920
pos = parseArgBody ( token .getAnArgument ( ) )
884
921
}
885
922
923
+ /** Holds if specification component `token` parses as synthetic global `sg`. */
924
+ predicate parseSynthGlobal ( AccessPathToken token , string sg ) {
925
+ token .getName ( ) = "SyntheticGlobal" and
926
+ sg = token .getAnArgument ( )
927
+ }
928
+
929
+ private class SyntheticGlobalFromAccessPath extends SummaryComponent:: SyntheticGlobal {
930
+ SyntheticGlobalFromAccessPath ( ) { parseSynthGlobal ( _, this ) }
931
+ }
932
+
886
933
private SummaryComponent interpretComponent ( AccessPathToken token ) {
887
934
exists ( ParameterPosition pos |
888
935
parseArg ( token , pos ) and result = SummaryComponent:: argument ( pos )
@@ -894,6 +941,10 @@ module Private {
894
941
or
895
942
token = "ReturnValue" and result = SummaryComponent:: return ( getReturnValueKind ( ) )
896
943
or
944
+ exists ( string sg |
945
+ parseSynthGlobal ( token , sg ) and result = SummaryComponent:: syntheticGlobal ( sg )
946
+ )
947
+ or
897
948
result = interpretComponentSpecific ( token )
898
949
}
899
950
0 commit comments