@@ -779,22 +779,33 @@ module TestPostProcessing {
779
779
)
780
780
}
781
781
782
- private string getTagRegex ( ) {
783
- exists ( string sourceSinkTags |
784
- (
785
- getQueryKind ( ) = "problem"
786
- or
787
- not exists ( getSourceTag ( _) ) and
788
- not exists ( getSinkTag ( _) )
789
- ) and
790
- sourceSinkTags = ""
791
- or
792
- sourceSinkTags = "|" + getSourceTag ( _) + "|" + getSinkTag ( _)
782
+ bindingset [ x, y]
783
+ private int exactDivide ( int x , int y ) { x % y = 0 and result = x / y }
784
+
785
+ /** Gets the `n`th related location selected in `row`. */
786
+ private TestLocation getRelatedLocation ( int row , int n , string element ) {
787
+ n >= 0 and
788
+ exists ( int column |
789
+ mainQueryResult ( row , column , result ) and
790
+ queryResults ( mainResultSet ( ) , row , column + 1 , element )
793
791
|
794
- result = "(Alert" + sourceSinkTags + ")(\\[(.*)\\])?"
792
+ getQueryKind ( ) = "path-problem" and
793
+ n = exactDivide ( column - 8 , 3 )
794
+ or
795
+ getQueryKind ( ) = "problem" and
796
+ n = exactDivide ( column - 3 , 3 )
795
797
)
796
798
}
797
799
800
+ private string getAnActiveTag ( ) {
801
+ result = [ "Alert" , "RelatedLocation" ]
802
+ or
803
+ getQueryKind ( ) = "path-problem" and
804
+ result = [ "Source" , "Sink" ]
805
+ }
806
+
807
+ private string getTagRegex ( ) { result = "(" + concat ( getAnActiveTag ( ) , "|" ) + ")(\\[(.*)\\])?" }
808
+
798
809
/**
799
810
* A configuration for matching `// $ Source=foo` comments against actual
800
811
* path-problem sources.
@@ -878,6 +889,18 @@ module TestPostProcessing {
878
889
not hasPathProblemSink ( row , location , _, _)
879
890
}
880
891
892
+ private predicate hasRelatedLocation (
893
+ int row , TestLocation location , string element , string tag
894
+ ) {
895
+ getQueryKind ( ) = [ "problem" , "path-problem" ] and
896
+ location = getRelatedLocation ( row , _, element ) and
897
+ hasExpectationWithValue ( "RelatedLocation" , _) and
898
+ tag = "RelatedLocation" and
899
+ not hasAlert ( row , location , _, _) and
900
+ not hasPathProblemSource ( row , location , _, _, _) and
901
+ not hasPathProblemSink ( row , location , _, _)
902
+ }
903
+
881
904
/**
882
905
* Gets the expected value for result row `row`, if any. This value must
883
906
* match the value at the corresponding path-problem source (if it is
@@ -899,6 +922,8 @@ module TestPostProcessing {
899
922
hasPathProblemSink ( row , location , element , tag )
900
923
or
901
924
hasAlert ( row , location , element , tag )
925
+ or
926
+ hasRelatedLocation ( row , location , element , tag )
902
927
|
903
928
not exists ( getValue ( row ) ) and value = ""
904
929
or
0 commit comments