Skip to content

Commit 35403d4

Browse files
committed
C++: Fix IR printing when multiple edges point to the same block
1 parent e43f7fb commit 35403d4

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/PrintIR.qll

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,18 @@ query predicate edges(PrintableIRBlock pred, PrintableIRBlock succ, string key,
427427
succBlock = succ.getBlock() and
428428
predBlock.getSuccessor(kind) = succBlock and
429429
(
430-
(
431-
key = "semmle.label" and
430+
key = "semmle.label" and
431+
exists(string kinds |
432+
kinds =
433+
concat(EdgeKind k |
434+
predBlock.getSuccessor(k) = succBlock
435+
|
436+
k.toString(), "|" order by k.toString()
437+
)
438+
|
432439
if predBlock.getBackEdgeSuccessor(kind) = succBlock
433-
then value = kind.toString() + " (back edge)"
434-
else value = kind.toString()
440+
then value = kinds + " (back edge)"
441+
else value = kinds
435442
)
436443
or
437444
key = "semmle.order" and

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/PrintIR.qll

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,18 @@ query predicate edges(PrintableIRBlock pred, PrintableIRBlock succ, string key,
427427
succBlock = succ.getBlock() and
428428
predBlock.getSuccessor(kind) = succBlock and
429429
(
430-
(
431-
key = "semmle.label" and
430+
key = "semmle.label" and
431+
exists(string kinds |
432+
kinds =
433+
concat(EdgeKind k |
434+
predBlock.getSuccessor(k) = succBlock
435+
|
436+
k.toString(), "|" order by k.toString()
437+
)
438+
|
432439
if predBlock.getBackEdgeSuccessor(kind) = succBlock
433-
then value = kind.toString() + " (back edge)"
434-
else value = kind.toString()
440+
then value = kinds + " (back edge)"
441+
else value = kinds
435442
)
436443
or
437444
key = "semmle.order" and

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/PrintIR.qll

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,18 @@ query predicate edges(PrintableIRBlock pred, PrintableIRBlock succ, string key,
427427
succBlock = succ.getBlock() and
428428
predBlock.getSuccessor(kind) = succBlock and
429429
(
430-
(
431-
key = "semmle.label" and
430+
key = "semmle.label" and
431+
exists(string kinds |
432+
kinds =
433+
concat(EdgeKind k |
434+
predBlock.getSuccessor(k) = succBlock
435+
|
436+
k.toString(), "|" order by k.toString()
437+
)
438+
|
432439
if predBlock.getBackEdgeSuccessor(kind) = succBlock
433-
then value = kind.toString() + " (back edge)"
434-
else value = kind.toString()
440+
then value = kinds + " (back edge)"
441+
else value = kinds
435442
)
436443
or
437444
key = "semmle.order" and

0 commit comments

Comments
 (0)