@@ -174,6 +174,22 @@ predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
174174 )
175175}
176176
177+ bindingset [ path, orig]
178+ pragma [ inline_late]
179+ predicate interpretPath ( string path , Function f , Provenance orig , Provenance p , boolean isExact ) {
180+ exists ( Function f0 | f0 .getCanonicalPath ( ) = path |
181+ f = f0 and
182+ isExact = true and
183+ p = orig
184+ or
185+ f .implements ( f0 ) and
186+ isExact = false and
187+ // making inherited models generated means that source code definitions and
188+ // exact generated models take precedence
189+ p = "hq-generated"
190+ )
191+ }
192+
177193private class SummarizedCallableFromModel extends SummarizedCallable:: Range {
178194 string input_ ;
179195 string output_ ;
@@ -183,19 +199,9 @@ private class SummarizedCallableFromModel extends SummarizedCallable::Range {
183199 QlBuiltins:: ExtensionId madId ;
184200
185201 SummarizedCallableFromModel ( ) {
186- exists ( string path , Function f , Provenance p |
202+ exists ( string path , Provenance p |
187203 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"
204+ interpretPath ( path , this , p , p_ , isExact_ )
199205 )
200206 }
201207
@@ -246,78 +252,97 @@ private class SummarizedCallableWithCallback extends SummarizedCallable::Range {
246252
247253private class FlowSourceFromModel extends FlowSource:: Range {
248254 private string path ;
255+ private string kind_ ;
256+ private Provenance orig ;
257+ private Provenance p_ ;
258+ private boolean isExact_ ;
249259
250260 FlowSourceFromModel ( ) {
251- sourceModel ( path , _, _ , _ , _) and
252- this . getCanonicalPath ( ) = path
261+ sourceModel ( path , _, kind_ , orig , _) and
262+ interpretPath ( path , this , orig , p_ , isExact_ )
253263 }
254264
255- override predicate isSource ( string output , string kind , Provenance provenance , string model ) {
265+ override predicate isSource (
266+ string output , string kind , Provenance provenance , boolean isExact , string model
267+ ) {
256268 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" , _, _)
269+ sourceModel ( path , output , kind , orig , madId ) and
270+ model = "MaD:" + madId .toString ( ) and
271+ kind = kind_ and
272+ provenance = p_ and
273+ isExact = isExact_
265274 )
266275 }
267276}
268277
269278private class FlowSinkFromModel extends FlowSink:: Range {
270279 private string path ;
280+ private string kind_ ;
281+ private Provenance orig ;
282+ private Provenance p_ ;
283+ private boolean isExact_ ;
271284
272285 FlowSinkFromModel ( ) {
273- sinkModel ( path , _, _ , _ , _) and
274- this . getCanonicalPath ( ) = path
286+ sinkModel ( path , _, kind_ , orig , _) and
287+ interpretPath ( path , this , orig , p_ , isExact_ )
275288 }
276289
277- override predicate isSink ( string input , string kind , Provenance provenance , string model ) {
290+ override predicate isSink (
291+ string input , string kind , Provenance provenance , boolean isExact , string model
292+ ) {
278293 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" , _, _)
294+ sinkModel ( path , input , kind , orig , madId ) and
295+ model = "MaD:" + madId .toString ( ) and
296+ kind = kind_ and
297+ provenance = p_ and
298+ isExact = isExact_
287299 )
288300 }
289301}
290302
291303private class FlowBarrierFromModel extends FlowBarrier:: Range {
292304 private string path ;
305+ private Provenance orig ;
306+ private Provenance p_ ;
307+ private boolean isExact_ ;
293308
294309 FlowBarrierFromModel ( ) {
295- barrierModel ( path , _, _, _ , _) and
296- this . getCanonicalPath ( ) = path
310+ barrierModel ( path , _, _, orig , _) and
311+ interpretPath ( path , this , orig , p_ , isExact_ )
297312 }
298313
299- override predicate isBarrier ( string output , string kind , Provenance provenance , string model ) {
314+ override predicate isBarrier (
315+ string output , string kind , Provenance provenance , boolean isExact , string model
316+ ) {
300317 exists ( QlBuiltins:: ExtensionId madId |
301- barrierModel ( path , output , kind , provenance , madId ) and
302- model = "MaD:" + madId .toString ( )
318+ barrierModel ( path , output , kind , orig , madId ) and
319+ model = "MaD:" + madId .toString ( ) and
320+ provenance = p_ and
321+ isExact = isExact_
303322 )
304323 }
305324}
306325
307326private class FlowBarrierGuardFromModel extends FlowBarrierGuard:: Range {
308327 private string path ;
328+ private Provenance orig ;
329+ private Provenance p_ ;
330+ private boolean isExact_ ;
309331
310332 FlowBarrierGuardFromModel ( ) {
311- barrierGuardModel ( path , _, _, _, _ , _) and
312- this . getCanonicalPath ( ) = path
333+ barrierGuardModel ( path , _, _, _, orig , _) and
334+ interpretPath ( path , this , orig , p_ , isExact_ )
313335 }
314336
315337 override predicate isBarrierGuard (
316- string input , string acceptingValue , string kind , Provenance provenance , string model
338+ string input , string acceptingValue , string kind , Provenance provenance , boolean isExact ,
339+ string model
317340 ) {
318341 exists ( QlBuiltins:: ExtensionId madId |
319- barrierGuardModel ( path , input , acceptingValue , kind , provenance , madId ) and
320- model = "MaD:" + madId .toString ( )
342+ barrierGuardModel ( path , input , acceptingValue , kind , orig , madId ) and
343+ model = "MaD:" + madId .toString ( ) and
344+ provenance = p_ and
345+ isExact = isExact_
321346 )
322347 }
323348}
0 commit comments