Skip to content

Commit d189ba5

Browse files
authored
Merge pull request github#11341 from hvitved/cfg/multi-edge-workaround
CFG: Workaround in test output for origin/target pairs with multiple edges
2 parents 78ad9ba + 0d89f57 commit d189ba5

File tree

6 files changed

+37
-25
lines changed

6 files changed

+37
-25
lines changed

csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraphImplShared.qll

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,9 +907,13 @@ module TestOutput {
907907

908908
query predicate edges(RelevantNode pred, RelevantNode succ, string attr, string val) {
909909
attr = "semmle.label" and
910-
exists(SuccessorType t | succ = getASuccessor(pred, t) |
911-
if successorTypeIsSimple(t) then val = "" else val = t.toString()
912-
)
910+
val =
911+
strictconcat(SuccessorType t, string s |
912+
succ = getASuccessor(pred, t) and
913+
if successorTypeIsSimple(t) then s = "" else s = t.toString()
914+
|
915+
s, ", " order by s
916+
)
913917
or
914918
attr = "semmle.order" and
915919
val =

csharp/ql/test/library-tests/controlflow/graph/NodeGraph.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,7 +2775,7 @@ Assert.cs:
27752775
#-----| true -> access to parameter b2
27762776

27772777
# 140| [assertion failure] access to parameter b2
2778-
#-----| false -> [assertion failure] access to parameter b3
2778+
#-----| false, true -> [assertion failure] access to parameter b3
27792779

27802780
# 140| access to parameter b2
27812781
#-----| false -> [assertion success] access to parameter b3
@@ -4924,7 +4924,7 @@ ExitMethods.cs:
49244924
#-----| -> ...;
49254925

49264926
# 22| call to method ErrorAlways
4927-
#-----| exception(Exception) -> exit M3 (abnormal)
4927+
#-----| exception(ArgumentException), exception(Exception) -> exit M3 (abnormal)
49284928

49294929
# 22| ...;
49304930
#-----| -> true

ruby/ql/lib/codeql/ruby/controlflow/internal/ControlFlowGraphImplShared.qll

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,9 +907,13 @@ module TestOutput {
907907

908908
query predicate edges(RelevantNode pred, RelevantNode succ, string attr, string val) {
909909
attr = "semmle.label" and
910-
exists(SuccessorType t | succ = getASuccessor(pred, t) |
911-
if successorTypeIsSimple(t) then val = "" else val = t.toString()
912-
)
910+
val =
911+
strictconcat(SuccessorType t, string s |
912+
succ = getASuccessor(pred, t) and
913+
if successorTypeIsSimple(t) then s = "" else s = t.toString()
914+
|
915+
s, ", " order by s
916+
)
913917
or
914918
attr = "semmle.order" and
915919
val =

ruby/ql/test/library-tests/controlflow/graph/Cfg.expected

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ case.rb:
811811
#-----| -> [ ..., * ]
812812

813813
# 35| [ ..., * ]
814-
#-----| match -> x
814+
#-----| false, match, true -> x
815815
#-----| no-match -> in ... then ...
816816

817817
# 35| x
@@ -821,7 +821,7 @@ case.rb:
821821
#-----| -> [ ..., * ]
822822

823823
# 36| [ ..., * ]
824-
#-----| match -> x
824+
#-----| false, match, true -> x
825825
#-----| no-match -> in ... then ...
826826

827827
# 36| x
@@ -836,7 +836,7 @@ case.rb:
836836

837837
# 37| [ ..., * ]
838838
#-----| raise -> exit case_match_array (abnormal)
839-
#-----| match -> a
839+
#-----| false, match, true -> a
840840

841841
# 37| a
842842
#-----| match -> b
@@ -881,7 +881,7 @@ case.rb:
881881

882882
# 43| [ *,...,* ]
883883
#-----| raise -> exit case_match_find (abnormal)
884-
#-----| match -> x
884+
#-----| false, match, true -> x
885885

886886
# 43| x
887887
#-----| -> 1
@@ -931,7 +931,7 @@ case.rb:
931931
#-----| no-match -> in ... then ...
932932

933933
# 49| { ..., ** }
934-
#-----| match -> 1
934+
#-----| false, match, true -> 1
935935
#-----| no-match -> in ... then ...
936936

937937
# 49| 1
@@ -952,7 +952,7 @@ case.rb:
952952
#-----| no-match -> in ... then ...
953953

954954
# 50| { ..., ** }
955-
#-----| match -> 1
955+
#-----| false, match, true -> 1
956956
#-----| no-match -> in ... then ...
957957

958958
# 50| 1
@@ -968,7 +968,7 @@ case.rb:
968968

969969
# 51| { ..., ** }
970970
#-----| raise -> exit case_match_hash (abnormal)
971-
#-----| match -> case ...
971+
#-----| false, match, true -> case ...
972972

973973
# 55| case_match_variable
974974
#-----| -> case_match_underscore
@@ -1372,7 +1372,7 @@ case.rb:
13721372

13731373
# 91| { ..., ** }
13741374
#-----| raise -> exit case_match_various (abnormal)
1375-
#-----| match -> case ...
1375+
#-----| false, match, true -> case ...
13761376

13771377
# 95| case_match_guard_no_else
13781378
#-----| -> exit case.rb (normal)
@@ -2559,7 +2559,7 @@ cfg.rb:
25592559
#-----| -> type
25602560

25612561
# 101| value
2562-
#-----| no-match -> 42
2562+
#-----| false, no-match, true -> 42
25632563
#-----| match -> key
25642564

25652565
# 101| 42
@@ -6535,7 +6535,7 @@ raise.rb:
65356535
#-----| -> m11
65366536

65376537
# 121| p
6538-
#-----| no-match -> self
6538+
#-----| false, no-match, true -> self
65396539
#-----| match -> self
65406540

65416541
# 121| call to raise

swift/ql/lib/codeql/swift/controlflow/internal/ControlFlowGraphImplShared.qll

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,9 +907,13 @@ module TestOutput {
907907

908908
query predicate edges(RelevantNode pred, RelevantNode succ, string attr, string val) {
909909
attr = "semmle.label" and
910-
exists(SuccessorType t | succ = getASuccessor(pred, t) |
911-
if successorTypeIsSimple(t) then val = "" else val = t.toString()
912-
)
910+
val =
911+
strictconcat(SuccessorType t, string s |
912+
succ = getASuccessor(pred, t) and
913+
if successorTypeIsSimple(t) then s = "" else s = t.toString()
914+
|
915+
s, ", " order by s
916+
)
913917
or
914918
attr = "semmle.order" and
915919
val =

swift/ql/test/library-tests/controlflow/graph/Cfg.expected

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,14 @@ cfg.swift:
250250
#-----| match -> 0
251251

252252
# 33| .error1
253-
#-----| no-match -> ... is ...
253+
#-----| match, no-match -> ... is ...
254254

255255
# 33| ... is ...
256-
#-----| no-match -> call to isZero(x:)
256+
#-----| match, no-match -> call to isZero(x:)
257257
#-----| no-match -> case ...
258258

259259
# 33| .error2
260-
#-----| no-match -> ... is ...
260+
#-----| match, no-match -> ... is ...
261261

262262
# 33| ... is ... where ...
263263
#-----| -> .error2
@@ -1577,7 +1577,7 @@ cfg.swift:
15771577
#-----| -> =~ ... where ...
15781578

15791579
# 144| =~ ...
1580-
#-----| no-match -> ... .&&(_:_:) ...
1580+
#-----| match, no-match -> ... .&&(_:_:) ...
15811581
#-----| no-match -> case ...
15821582

15831583
# 144| x

0 commit comments

Comments
 (0)