@@ -174,6 +174,26 @@ predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
174174 )
175175}
176176
177+ bindingset [ path]
178+ pragma [ inline_late]
179+ private Function interpretPath0 ( string path ) { path = result .getCanonicalPath ( ) }
180+
181+ bindingset [ path, orig]
182+ pragma [ inline_late]
183+ predicate interpretPath ( string path , Function f , Provenance orig , Provenance p , boolean isExact ) {
184+ exists ( Function f0 | f0 = interpretPath0 ( path ) |
185+ f = f0 and
186+ isExact = true and
187+ p = orig
188+ or
189+ f .implements ( f0 ) and
190+ isExact = false and
191+ // making inherited models generated means that source code definitions and
192+ // exact generated models take precedence
193+ p = "hq-generated"
194+ )
195+ }
196+
177197private class SummarizedCallableFromModel extends SummarizedCallable:: Range {
178198 string input_ ;
179199 string output_ ;
@@ -183,19 +203,9 @@ private class SummarizedCallableFromModel extends SummarizedCallable::Range {
183203 QlBuiltins:: ExtensionId madId ;
184204
185205 SummarizedCallableFromModel ( ) {
186- exists ( string path , Function f , Provenance p |
206+ exists ( string path , Provenance p |
187207 summaryModel ( path , input_ , output_ , kind , p , madId ) and
188- f .getCanonicalPath ( ) = path
189- |
190- this = f and
191- isExact_ = true and
192- p_ = p
193- or
194- this .implements ( f ) and
195- isExact_ = false and
196- // making inherited models generated means that source code definitions and
197- // exact generated models take precedence
198- p_ = "hq-generated"
208+ interpretPath ( path , this , p , p_ , isExact_ )
199209 )
200210 }
201211
@@ -246,78 +256,97 @@ private class SummarizedCallableWithCallback extends SummarizedCallable::Range {
246256
247257private class FlowSourceFromModel extends FlowSource:: Range {
248258 private string path ;
259+ private string kind_ ;
260+ private Provenance orig ;
261+ private Provenance p_ ;
262+ private boolean isExact_ ;
249263
250264 FlowSourceFromModel ( ) {
251- sourceModel ( path , _, _ , _ , _) and
252- this . getCanonicalPath ( ) = path
265+ sourceModel ( path , _, kind_ , orig , _) and
266+ interpretPath ( path , this , orig , p_ , isExact_ )
253267 }
254268
255- override predicate isSource ( string output , string kind , Provenance provenance , string model ) {
269+ override predicate isSource (
270+ string output , string kind , Provenance provenance , boolean isExact , string model
271+ ) {
256272 exists ( QlBuiltins:: ExtensionId madId |
257- sourceModel ( path , output , kind , provenance , madId ) and
258- model = "MaD:" + madId .toString ( )
259- ) and
260- // Only apply generated models when no neutral model exists
261- // (the shared code only applies neutral models to summaries at present)
262- not (
263- provenance .isGenerated ( ) and
264- neutralModel ( path , "source" , _, _)
273+ sourceModel ( path , output , kind , orig , madId ) and
274+ model = "MaD:" + madId .toString ( ) and
275+ kind = kind_ and
276+ provenance = p_ and
277+ isExact = isExact_
265278 )
266279 }
267280}
268281
269282private class FlowSinkFromModel extends FlowSink:: Range {
270283 private string path ;
284+ private string kind_ ;
285+ private Provenance orig ;
286+ private Provenance p_ ;
287+ private boolean isExact_ ;
271288
272289 FlowSinkFromModel ( ) {
273- sinkModel ( path , _, _ , _ , _) and
274- this . getCanonicalPath ( ) = path
290+ sinkModel ( path , _, kind_ , orig , _) and
291+ interpretPath ( path , this , orig , p_ , isExact_ )
275292 }
276293
277- override predicate isSink ( string input , string kind , Provenance provenance , string model ) {
294+ override predicate isSink (
295+ string input , string kind , Provenance provenance , boolean isExact , string model
296+ ) {
278297 exists ( QlBuiltins:: ExtensionId madId |
279- sinkModel ( path , input , kind , provenance , madId ) and
280- model = "MaD:" + madId .toString ( )
281- ) and
282- // Only apply generated models when no neutral model exists
283- // (the shared code only applies neutral models to summaries at present)
284- not (
285- provenance .isGenerated ( ) and
286- neutralModel ( path , "sink" , _, _)
298+ sinkModel ( path , input , kind , orig , madId ) and
299+ model = "MaD:" + madId .toString ( ) and
300+ kind = kind_ and
301+ provenance = p_ and
302+ isExact = isExact_
287303 )
288304 }
289305}
290306
291307private class FlowBarrierFromModel extends FlowBarrier:: Range {
292308 private string path ;
309+ private Provenance orig ;
310+ private Provenance p_ ;
311+ private boolean isExact_ ;
293312
294313 FlowBarrierFromModel ( ) {
295- barrierModel ( path , _, _, _ , _) and
296- this . getCanonicalPath ( ) = path
314+ barrierModel ( path , _, _, orig , _) and
315+ interpretPath ( path , this , orig , p_ , isExact_ )
297316 }
298317
299- override predicate isBarrier ( string output , string kind , Provenance provenance , string model ) {
318+ override predicate isBarrier (
319+ string output , string kind , Provenance provenance , boolean isExact , string model
320+ ) {
300321 exists ( QlBuiltins:: ExtensionId madId |
301- barrierModel ( path , output , kind , provenance , madId ) and
302- model = "MaD:" + madId .toString ( )
322+ barrierModel ( path , output , kind , orig , madId ) and
323+ model = "MaD:" + madId .toString ( ) and
324+ provenance = p_ and
325+ isExact = isExact_
303326 )
304327 }
305328}
306329
307330private class FlowBarrierGuardFromModel extends FlowBarrierGuard:: Range {
308331 private string path ;
332+ private Provenance orig ;
333+ private Provenance p_ ;
334+ private boolean isExact_ ;
309335
310336 FlowBarrierGuardFromModel ( ) {
311- barrierGuardModel ( path , _, _, _, _ , _) and
312- this . getCanonicalPath ( ) = path
337+ barrierGuardModel ( path , _, _, _, orig , _) and
338+ interpretPath ( path , this , orig , p_ , isExact_ )
313339 }
314340
315341 override predicate isBarrierGuard (
316- string input , string acceptingValue , string kind , Provenance provenance , string model
342+ string input , string acceptingValue , string kind , Provenance provenance , boolean isExact ,
343+ string model
317344 ) {
318345 exists ( QlBuiltins:: ExtensionId madId |
319- barrierGuardModel ( path , input , acceptingValue , kind , provenance , madId ) and
320- model = "MaD:" + madId .toString ( )
346+ barrierGuardModel ( path , input , acceptingValue , kind , orig , madId ) and
347+ model = "MaD:" + madId .toString ( ) and
348+ provenance = p_ and
349+ isExact = isExact_
321350 )
322351 }
323352}
0 commit comments