@@ -10,8 +10,6 @@ private import codeql.dataflow.DataFlow as DF
10
10
11
11
signature predicate interpretModelForTestSig ( QlBuiltins:: ExtensionId madId , string model ) ;
12
12
13
- signature predicate queryResultsSig ( string relation , int row , int column , string data ) ;
14
-
15
13
signature class PathNodeSig {
16
14
string toString ( ) ;
17
15
}
@@ -85,45 +83,57 @@ module ShowProvenance<
85
83
query predicate subpaths = PathGraph:: subpaths / 4 ;
86
84
}
87
85
88
- /** Transforms a `PathGraph` by printing the provenance information. */
89
- module TranslateProvenanceResults<
90
- interpretModelForTestSig / 2 interpretModelForTest, queryResultsSig / 4 queryResults>
91
- {
92
- private int provenanceColumn ( ) { result = 5 }
86
+ /**
87
+ * Provides logic for creating a `@kind test-postprocess` query that prints
88
+ * the provenance information.
89
+ */
90
+ module TestPostProcessing {
91
+ external predicate queryResults ( string relation , int row , int column , string data ) ;
93
92
94
- private predicate provenance ( string model ) { queryResults ( "edges" , _ , provenanceColumn ( ) , model ) }
93
+ external predicate queryRelations ( string relation ) ;
95
94
96
- private module Models = TranslateModels< interpretModelForTest / 2 , provenance / 1 > ;
95
+ /** Transforms a `PathGraph` by printing the provenance information. */
96
+ module TranslateProvenanceResults< interpretModelForTestSig / 2 interpretModelForTest> {
97
+ private int provenanceColumn ( ) { result = 5 }
98
+
99
+ private predicate provenance ( string model ) {
100
+ queryResults ( "edges" , _, provenanceColumn ( ) , model )
101
+ }
102
+
103
+ private module Models = TranslateModels< interpretModelForTest / 2 , provenance / 1 > ;
104
+
105
+ private newtype TModelRow = TMkModelRow ( int r , string model ) { Models:: models ( r , model ) }
97
106
98
- private newtype TModelRow = TMkModelRow ( int r , string model ) { Models:: models ( r , model ) }
107
+ private predicate rankedModels ( int i , int r , string model ) {
108
+ TMkModelRow ( r , model ) =
109
+ rank [ i ] ( TModelRow row , int r0 , string model0 |
110
+ row = TMkModelRow ( r0 , model0 )
111
+ |
112
+ row order by r0 , model0
113
+ )
114
+ }
99
115
100
- private predicate rankedModels ( int i , int r , string model ) {
101
- TMkModelRow ( r , model ) =
102
- rank [ i ] ( TModelRow row , int r0 , string model0 |
103
- row = TMkModelRow ( r0 , model0 )
116
+ predicate results ( string relation , int row , int column , string data ) {
117
+ queryResults ( relation , row , column , data ) and
118
+ ( relation != "edges" or column != provenanceColumn ( ) )
119
+ or
120
+ exists ( string model |
121
+ relation = "edges" and
122
+ column = provenanceColumn ( ) and
123
+ queryResults ( relation , row , column , model ) and
124
+ Models:: translateModels ( model , data )
125
+ )
126
+ or
127
+ exists ( int r , string model |
128
+ relation = "models" and
129
+ rankedModels ( row , r , model )
104
130
|
105
- row order by r0 , model0
131
+ column = 0 and data = r .toString ( )
132
+ or
133
+ column = 1 and data = model
106
134
)
107
- }
135
+ }
108
136
109
- predicate results ( string relation , int row , int column , string data ) {
110
- queryResults ( relation , row , column , data ) and
111
- ( relation != "edges" or column != provenanceColumn ( ) )
112
- or
113
- exists ( string model |
114
- relation = "edges" and
115
- column = provenanceColumn ( ) and
116
- queryResults ( relation , row , column , model ) and
117
- Models:: translateModels ( model , data )
118
- )
119
- or
120
- exists ( int r , string model |
121
- relation = "models" and
122
- rankedModels ( row , r , model )
123
- |
124
- column = 0 and data = r .toString ( )
125
- or
126
- column = 1 and data = model
127
- )
137
+ query predicate resultRelations ( string relation ) { queryRelations ( relation ) }
128
138
}
129
139
}
0 commit comments