Skip to content

Commit 8c49470

Browse files
committed
C++: Fix IR printing when multiple edges point to the same block
1 parent f491672 commit 8c49470

File tree

5 files changed

+37
-16
lines changed

5 files changed

+37
-16
lines changed

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

+11-4
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

+11-4
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

+11-4
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/test/library-tests/ir/ir/aliased_ir.expected

+2-2
Original file line numberDiff line numberDiff line change
@@ -38831,7 +38831,7 @@ try_except.c:
3883138831
# 23| v23_3(void) = Call[ProbeFunction] : func:r23_1, 0:r23_2
3883238832
# 23| m23_4(unknown) = ^CallSideEffect : ~m21_5
3883338833
# 23| m23_5(unknown) = Chi : total:m21_5, partial:m23_4
38834-
#-----| SEH Exception -> Block 4
38834+
#-----| Goto|SEH Exception -> Block 4
3883538835

3883638836
# 26| Block 4
3883738837
# 26| m26_1(unknown) = Phi : from 0:~m21_5, from 3:~m23_5
@@ -39028,7 +39028,7 @@ try_except.cpp:
3902839028
# 23| v23_3(void) = Call[ProbeFunction] : func:r23_1, 0:r23_2
3902939029
# 23| m23_4(unknown) = ^CallSideEffect : ~m21_5
3903039030
# 23| m23_5(unknown) = Chi : total:m21_5, partial:m23_4
39031-
#-----| SEH Exception -> Block 4
39031+
#-----| Goto|SEH Exception -> Block 4
3903239032

3903339033
# 26| Block 4
3903439034
# 26| m26_1(unknown) = Phi : from 0:~m21_5, from 3:~m23_5

cpp/ql/test/library-tests/ir/ir/raw_ir.expected

+2-2
Original file line numberDiff line numberDiff line change
@@ -37077,7 +37077,7 @@ try_except.c:
3707737077
# 23| r23_2(int) = Constant[0] :
3707837078
# 23| v23_3(void) = Call[ProbeFunction] : func:r23_1, 0:r23_2
3707937079
# 23| mu23_4(unknown) = ^CallSideEffect : ~m?
37080-
#-----| SEH Exception -> Block 4
37080+
#-----| Goto|SEH Exception -> Block 4
3708137081

3708237082
# 26| Block 4
3708337083
# 26| r26_1(glval<unknown>) = FunctionAddress[sink] :
@@ -37266,7 +37266,7 @@ try_except.cpp:
3726637266
# 23| r23_2(int) = Constant[0] :
3726737267
# 23| v23_3(void) = Call[ProbeFunction] : func:r23_1, 0:r23_2
3726837268
# 23| mu23_4(unknown) = ^CallSideEffect : ~m?
37269-
#-----| SEH Exception -> Block 4
37269+
#-----| Goto|SEH Exception -> Block 4
3727037270

3727137271
# 26| Block 4
3727237272
# 26| r26_1(glval<unknown>) = FunctionAddress[sink] :

0 commit comments

Comments
 (0)