Skip to content

Commit 8d0b23b

Browse files
committed
Change asserts to invariants
1 parent a7afc6c commit 8d0b23b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/goto-diff/unified_diff.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,27 @@ unified_difft::goto_program_difft unified_difft::get_diff(
7171
{
7272
case differencet::SAME:
7373
dest.push_back(std::make_pair(new_it, differencet::SAME));
74-
assert(old_it != old_goto_program.instructions.end());
74+
INVARIANT(
75+
old_it != old_goto_program.instructions.end(),
76+
"Old iterator reached the final goto instruction");
7577
++old_it;
76-
assert(new_it != new_goto_program.instructions.end());
78+
INVARIANT(
79+
new_it != new_goto_program.instructions.end(),
80+
"New iterator reached the final goto instruction");
7781
++new_it;
7882
break;
7983
case differencet::DELETED:
8084
dest.push_back(std::make_pair(old_it, differencet::DELETED));
81-
assert(old_it != old_goto_program.instructions.end());
85+
INVARIANT(
86+
old_it != old_goto_program.instructions.end(),
87+
"Old iterator reached the final goto instruction");
8288
++old_it;
8389
break;
8490
case differencet::NEW:
8591
dest.push_back(std::make_pair(new_it, differencet::NEW));
86-
assert(new_it != new_goto_program.instructions.end());
92+
INVARIANT(
93+
new_it != new_goto_program.instructions.end(),
94+
"New iterator reached the final goto instruction");
8795
++new_it;
8896
break;
8997
}
@@ -336,7 +344,8 @@ bool unified_difft::operator()()
336344
unified_diff(itn->first, empty, itn->second->second.body);
337345
else
338346
{
339-
assert(ito->first == itn->first);
347+
INVARIANT(
348+
ito->first == itn->first, "Old and new function names do not match");
340349
unified_diff(
341350
itn->first, ito->second->second.body, itn->second->second.body);
342351
++ito;

0 commit comments

Comments
 (0)