Skip to content

Commit 360fabe

Browse files
Merge pull request diffblue#2356 from peterschrammel/fix-goto-simplification
Fix if-then-else simplifications
2 parents e5d1c12 + 4394016 commit 360fabe

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed
299 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class Test {
2+
3+
public int foo(int i) {
4+
int x = 0;
5+
if (i > 0) {
6+
x++;
7+
}
8+
else
9+
{
10+
x--;
11+
}
12+
return x + 1000;
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Test.class
3+
--show-goto-functions --function Test.foo
4+
activate-multi-line-match
5+
EXIT=0
6+
SIGNAL=0
7+
IF \w* <= 0 THEN GOTO 1\n\s*//.*\n\s*//.*\n\s*\w*::
8+
--
9+
IF !\(\w* <= 0\) THEN GOTO 1\n\s*//.*\n.*GOTO 2\n\s*//.*\n\s*//.*\n\s*1: \w*::
10+
^warning: ignoring

src/goto-programs/goto_convert.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1460,8 +1460,10 @@ void goto_convertt::convert_goto(
14601460
const codet &code,
14611461
goto_programt &dest)
14621462
{
1463-
// this instruction will turn into a goto during post-processing
1464-
goto_programt::targett t=dest.add_instruction(NO_INSTRUCTION_TYPE);
1463+
// this instruction will be completed during post-processing
1464+
// it is required to mark this as GOTO in order to enable
1465+
// simplifications in generate_ifthenelse
1466+
goto_programt::targett t = dest.add_instruction(GOTO);
14651467
t->source_location=code.source_location();
14661468
t->code=code;
14671469

0 commit comments

Comments
 (0)