@@ -779,22 +779,33 @@ module TestPostProcessing {
779779 )
780780 }
781781
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 )
793791 |
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 )
795797 )
796798 }
797799
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+
798809 /**
799810 * A configuration for matching `// $ Source=foo` comments against actual
800811 * path-problem sources.
@@ -878,6 +889,18 @@ module TestPostProcessing {
878889 not hasPathProblemSink ( row , location , _, _)
879890 }
880891
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+
881904 /**
882905 * Gets the expected value for result row `row`, if any. This value must
883906 * match the value at the corresponding path-problem source (if it is
@@ -899,6 +922,8 @@ module TestPostProcessing {
899922 hasPathProblemSink ( row , location , element , tag )
900923 or
901924 hasAlert ( row , location , element , tag )
925+ or
926+ hasRelatedLocation ( row , location , element , tag )
902927 |
903928 not exists ( getValue ( row ) ) and value = ""
904929 or
0 commit comments