@@ -645,29 +645,21 @@ module TestPostProcessing {
645
645
private import InlineExpectationsTest as InlineExpectationsTest
646
646
private import InlineExpectationsTest:: Make< Input >
647
647
648
- bindingset [ loc]
649
- private predicate parseLocation (
650
- string loc , string file , int startLine , int startColumn , int endLine , int endColumn
651
- ) {
652
- exists ( string regexp |
653
- regexp = "(.*):(-?\\d+):(-?\\d+):(-?\\d+):(-?\\d+)" and
654
- file = loc .regexpCapture ( regexp , 1 ) and
655
- startLine = loc .regexpCapture ( regexp , 2 ) .toInt ( ) and
656
- startColumn = loc .regexpCapture ( regexp , 3 ) .toInt ( ) and
657
- endLine = loc .regexpCapture ( regexp , 4 ) .toInt ( ) and
658
- endColumn = loc .regexpCapture ( regexp , 5 ) .toInt ( )
659
- )
660
- }
661
-
662
- /** Holds if the given location strings refer to the same lines, but possibly with different column numbers. */
648
+ /** Holds if the given locations refer to the same lines, but possibly with different column numbers. */
663
649
bindingset [ loc1, loc2]
664
- private predicate sameLineInfo ( string loc1 , string loc2 ) {
650
+ pragma [ inline_late]
651
+ private predicate sameLineInfo ( Input:: Location loc1 , Input:: Location loc2 ) {
665
652
exists ( string file , int line1 , int line2 |
666
- parseLocation ( loc1 , file , line1 , _, line2 , _) and
667
- parseLocation ( loc2 , file , line1 , _, line2 , _)
653
+ loc1 . hasLocationInfo ( file , line1 , _, line2 , _) and
654
+ loc2 . hasLocationInfo ( file , line1 , _, line2 , _)
668
655
)
669
656
}
670
657
658
+ pragma [ nomagic]
659
+ private predicate mainQueryResult ( int row , int column , Input:: Location loc ) {
660
+ queryResults ( mainResultSet ( ) , row , column , Input2:: getRelativeUrl ( loc ) )
661
+ }
662
+
671
663
/**
672
664
* Gets the tag to be used for the path-problem source at result row `row`.
673
665
*
@@ -676,9 +668,9 @@ module TestPostProcessing {
676
668
*/
677
669
private string getSourceTag ( int row ) {
678
670
getQueryKind ( ) = "path-problem" and
679
- exists ( string sourceLoc , string selectLoc |
680
- queryResults ( mainResultSet ( ) , row , 0 , selectLoc ) and
681
- queryResults ( mainResultSet ( ) , row , 2 , sourceLoc ) and
671
+ exists ( Input :: Location sourceLoc , Input :: Location selectLoc |
672
+ mainQueryResult ( row , 0 , selectLoc ) and
673
+ mainQueryResult ( row , 2 , sourceLoc ) and
682
674
if sameLineInfo ( selectLoc , sourceLoc ) then result = "Alert" else result = "Source"
683
675
)
684
676
}
@@ -744,13 +736,10 @@ module TestPostProcessing {
744
736
int row , Input:: Location location , string element , string tag , string value
745
737
) {
746
738
getQueryKind ( ) = "path-problem" and
747
- exists ( string loc |
748
- queryResults ( mainResultSet ( ) , row , 2 , loc ) and
749
- queryResults ( mainResultSet ( ) , row , 3 , element ) and
750
- tag = getSourceTag ( row ) and
751
- value = "" and
752
- Input2:: getRelativeUrl ( location ) = loc
753
- )
739
+ mainQueryResult ( row , 2 , location ) and
740
+ queryResults ( mainResultSet ( ) , row , 3 , element ) and
741
+ tag = getSourceTag ( row ) and
742
+ value = ""
754
743
}
755
744
756
745
predicate hasActualResult ( Input:: Location location , string element , string tag , string value ) {
@@ -784,24 +773,18 @@ module TestPostProcessing {
784
773
int row , Input:: Location location , string element , string tag
785
774
) {
786
775
getQueryKind ( ) = "path-problem" and
787
- exists ( string loc |
788
- queryResults ( mainResultSet ( ) , row , 4 , loc ) and
789
- queryResults ( mainResultSet ( ) , row , 5 , element ) and
790
- tag = getSinkTag ( row ) and
791
- Input2:: getRelativeUrl ( location ) = loc
792
- )
776
+ mainQueryResult ( row , 4 , location ) and
777
+ queryResults ( mainResultSet ( ) , row , 5 , element ) and
778
+ tag = getSinkTag ( row )
793
779
}
794
780
795
781
private predicate hasAlert ( int row , Input:: Location location , string element , string tag ) {
796
782
getQueryKind ( ) = [ "problem" , "path-problem" ] and
797
- exists ( string loc |
798
- queryResults ( mainResultSet ( ) , row , 0 , loc ) and
799
- queryResults ( mainResultSet ( ) , row , 2 , element ) and
800
- tag = "Alert" and
801
- Input2:: getRelativeUrl ( location ) = loc and
802
- not hasPathProblemSource ( row , location , _, _, _) and
803
- not hasPathProblemSink ( row , location , _, _)
804
- )
783
+ mainQueryResult ( row , 0 , location ) and
784
+ queryResults ( mainResultSet ( ) , row , 2 , element ) and
785
+ tag = "Alert" and
786
+ not hasPathProblemSource ( row , location , _, _, _) and
787
+ not hasPathProblemSink ( row , location , _, _)
805
788
}
806
789
807
790
/**
0 commit comments