Skip to content

Commit

Permalink
Merge pull request diffblue#2356 from peterschrammel/fix-goto-simplif…
Browse files Browse the repository at this point in the history
…ication

Fix if-then-else simplifications
  • Loading branch information
peterschrammel authored Jun 15, 2018
2 parents e5d1c12 + 4394016 commit 360fabe
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
Binary file added jbmc/regression/jbmc/JumpSimplification/Test.class
Binary file not shown.
14 changes: 14 additions & 0 deletions jbmc/regression/jbmc/JumpSimplification/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Test {

public int foo(int i) {
int x = 0;
if (i > 0) {
x++;
}
else
{
x--;
}
return x + 1000;
}
}
10 changes: 10 additions & 0 deletions jbmc/regression/jbmc/JumpSimplification/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
Test.class
--show-goto-functions --function Test.foo
activate-multi-line-match
EXIT=0
SIGNAL=0
IF \w* <= 0 THEN GOTO 1\n\s*//.*\n\s*//.*\n\s*\w*::
--
IF !\(\w* <= 0\) THEN GOTO 1\n\s*//.*\n.*GOTO 2\n\s*//.*\n\s*//.*\n\s*1: \w*::
^warning: ignoring
6 changes: 4 additions & 2 deletions src/goto-programs/goto_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,8 +1460,10 @@ void goto_convertt::convert_goto(
const codet &code,
goto_programt &dest)
{
// this instruction will turn into a goto during post-processing
goto_programt::targett t=dest.add_instruction(NO_INSTRUCTION_TYPE);
// this instruction will be completed during post-processing
// it is required to mark this as GOTO in order to enable
// simplifications in generate_ifthenelse
goto_programt::targett t = dest.add_instruction(GOTO);
t->source_location=code.source_location();
t->code=code;

Expand Down

0 comments on commit 360fabe

Please sign in to comment.