Skip to content

Commit

Permalink
Remove unnecessary temporary variable in hooks.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
artemagvanian committed Jul 12, 2024
1 parent 0b24435 commit 19cf091
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions kani-compiler/src/codegen_cprover_gotoc/overrides/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,10 @@ impl GotocHook for Check {

let (msg, reach_stmt) = gcx.codegen_reachability_check(msg, span);

// Since `cond` might have side effects, assign it to a temporary
// variable so that it's evaluated once, then assert it
// TODO: I don't think `cond` can have side effects, this is MIR, it's going to be temps
let (tmp, decl) = gcx.decl_temp_variable(cond.typ().clone(), Some(cond), caller_loc);
Stmt::block(
vec![
reach_stmt,
decl,
gcx.codegen_assert(tmp, PropertyClass::Assertion, &msg, caller_loc),
gcx.codegen_assert(cond, PropertyClass::Assertion, &msg, caller_loc),
Stmt::goto(bb_label(target), caller_loc),
],
caller_loc,
Expand Down

0 comments on commit 19cf091

Please sign in to comment.