Skip to content

add typing for convert_dowhile #2837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions src/goto-programs/goto_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ void goto_convertt::convert(
else if(statement==ID_while)
convert_while(to_code_while(code), dest, mode);
else if(statement==ID_dowhile)
convert_dowhile(code, dest, mode);
convert_dowhile(to_code_dowhile(code), dest, mode);
else if(statement==ID_switch)
convert_switch(to_code_switch(code), dest, mode);
else if(statement==ID_break)
Expand Down Expand Up @@ -1131,21 +1131,14 @@ void goto_convertt::convert_while(
}

void goto_convertt::convert_dowhile(
const codet &code,
const code_dowhilet &code,
goto_programt &dest,
const irep_idt &mode)
{
if(code.operands().size()!=2)
{
error().source_location=code.find_source_location();
error() << "dowhile takes two operands" << eom;
throw 0;
}

// save source location
source_locationt condition_location=code.op0().find_source_location();
source_locationt condition_location=code.cond().find_source_location();

exprt cond=code.op0();
exprt cond=code.cond();

goto_programt sideeffects;
clean_expr(cond, sideeffects, mode);
Expand Down Expand Up @@ -1183,7 +1176,7 @@ void goto_convertt::convert_dowhile(

// do the w label
goto_programt tmp_w;
convert(to_code(code.op1()), tmp_w, mode);
convert(code.body(), tmp_w, mode);
goto_programt::targett w=tmp_w.instructions.begin();

// y: if(c) goto w;
Expand Down
6 changes: 4 additions & 2 deletions src/goto-programs/goto_convert_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,10 @@ class goto_convertt:public messaget
const code_whilet &code,
goto_programt &dest,
const irep_idt &mode);
void
convert_dowhile(const codet &code, goto_programt &dest, const irep_idt &mode);
void convert_dowhile(
const code_dowhilet &code,
goto_programt &dest,
const irep_idt &mode);
void convert_assume(
const code_assumet &code,
goto_programt &dest,
Expand Down