@@ -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,93 @@ private class SummarizedCallableWithCallback extends SummarizedCallable::Range {
246252
247253private class FlowSourceFromModel extends FlowSource:: Range {
248254 private string path ;
255+ private Provenance orig ;
256+ private Provenance p_ ;
257+ private boolean isExact_ ;
249258
250259 FlowSourceFromModel ( ) {
251- sourceModel ( path , _, _, _ , _) and
252- this . getCanonicalPath ( ) = path
260+ sourceModel ( path , _, _, orig , _) and
261+ interpretPath ( path , this , orig , p_ , isExact_ )
253262 }
254263
255- override predicate isSource ( string output , string kind , Provenance provenance , string model ) {
264+ override predicate isSource (
265+ string output , string kind , Provenance provenance , boolean isExact , string model
266+ ) {
256267 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" , _, _)
268+ sourceModel ( path , output , kind , orig , madId ) and
269+ model = "MaD:" + madId .toString ( ) and
270+ provenance = p_ and
271+ isExact = isExact_
265272 )
266273 }
267274}
268275
269276private class FlowSinkFromModel extends FlowSink:: Range {
270277 private string path ;
278+ private Provenance orig ;
279+ private Provenance p_ ;
280+ private boolean isExact_ ;
271281
272282 FlowSinkFromModel ( ) {
273- sinkModel ( path , _, _, _ , _) and
274- this . getCanonicalPath ( ) = path
283+ sinkModel ( path , _, _, orig , _) and
284+ interpretPath ( path , this , orig , p_ , isExact_ )
275285 }
276286
277- override predicate isSink ( string input , string kind , Provenance provenance , string model ) {
287+ override predicate isSink (
288+ string input , string kind , Provenance provenance , boolean isExact , string model
289+ ) {
278290 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" , _, _)
291+ sinkModel ( path , input , kind , orig , madId ) and
292+ model = "MaD:" + madId .toString ( ) and
293+ provenance = p_ and
294+ isExact = isExact_
287295 )
288296 }
289297}
290298
291299private class FlowBarrierFromModel extends FlowBarrier:: Range {
292300 private string path ;
301+ private Provenance orig ;
302+ private Provenance p_ ;
303+ private boolean isExact_ ;
293304
294305 FlowBarrierFromModel ( ) {
295- barrierModel ( path , _, _, _ , _) and
296- this . getCanonicalPath ( ) = path
306+ barrierModel ( path , _, _, orig , _) and
307+ interpretPath ( path , this , orig , p_ , isExact_ )
297308 }
298309
299- override predicate isBarrier ( string output , string kind , Provenance provenance , string model ) {
310+ override predicate isBarrier (
311+ string output , string kind , Provenance provenance , boolean isExact , string model
312+ ) {
300313 exists ( QlBuiltins:: ExtensionId madId |
301- barrierModel ( path , output , kind , provenance , madId ) and
302- model = "MaD:" + madId .toString ( )
314+ barrierModel ( path , output , kind , _, madId ) and
315+ model = "MaD:" + madId .toString ( ) and
316+ provenance = p_ and
317+ isExact = isExact_
303318 )
304319 }
305320}
306321
307322private class FlowBarrierGuardFromModel extends FlowBarrierGuard:: Range {
308323 private string path ;
324+ private Provenance orig ;
325+ private Provenance p_ ;
326+ private boolean isExact_ ;
309327
310328 FlowBarrierGuardFromModel ( ) {
311- barrierGuardModel ( path , _, _, _, _ , _) and
312- this . getCanonicalPath ( ) = path
329+ barrierGuardModel ( path , _, _, _, orig , _) and
330+ interpretPath ( path , this , orig , p_ , isExact_ )
313331 }
314332
315333 override predicate isBarrierGuard (
316- string input , string acceptingValue , string kind , Provenance provenance , string model
334+ string input , string acceptingValue , string kind , Provenance provenance , boolean isExact ,
335+ string model
317336 ) {
318337 exists ( QlBuiltins:: ExtensionId madId |
319- barrierGuardModel ( path , input , acceptingValue , kind , provenance , madId ) and
320- model = "MaD:" + madId .toString ( )
338+ barrierGuardModel ( path , input , acceptingValue , kind , _, madId ) and
339+ model = "MaD:" + madId .toString ( ) and
340+ provenance = p_ and
341+ isExact = isExact_
321342 )
322343 }
323344}
0 commit comments