Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4f30f4d

Browse files
committedJun 15, 2022
Replace assert(...) by macros from invariant.h
While new/modified code shouldn't use assert(...) anyway, we had several existing uses of assert. Once we remove nonstd/optional.h, we will no longer implicitly include cassert, implying that a lot of #include <cassert> changes will be necessary. Instead of adding these, go all the way and fix the undesired uses of assert.
1 parent a914ead commit 4f30f4d

File tree

118 files changed

+651
-576
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+651
-576
lines changed
 

‎jbmc/src/java_bytecode/character_refine_preprocess.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ codet character_refine_preprocesst::convert_char_function(
2727
conversion_inputt &target)
2828
{
2929
const code_function_callt &function_call=target;
30-
assert(function_call.arguments().size()==1);
30+
PRECONDITION(function_call.arguments().size() == 1);
3131
const exprt &arg=function_call.arguments()[0];
3232
const exprt &result=function_call.lhs();
3333
const typet &type=result.type();
@@ -111,7 +111,7 @@ codet character_refine_preprocesst::convert_char_value(
111111
codet character_refine_preprocesst::convert_compare(conversion_inputt &target)
112112
{
113113
const code_function_callt &function_call=target;
114-
assert(function_call.arguments().size()==2);
114+
PRECONDITION(function_call.arguments().size() == 2);
115115
const exprt &char1=function_call.arguments()[0];
116116
const exprt &char2=function_call.arguments()[1];
117117
const exprt &result=function_call.lhs();
@@ -223,7 +223,7 @@ codet character_refine_preprocesst::convert_digit_int(conversion_inputt &target)
223223
codet character_refine_preprocesst::convert_for_digit(conversion_inputt &target)
224224
{
225225
const code_function_callt &function_call=target;
226-
assert(function_call.arguments().size()==2);
226+
PRECONDITION(function_call.arguments().size() == 2);
227227
const exprt &digit=function_call.arguments()[0];
228228
const exprt &result=function_call.lhs();
229229
const typet &type=result.type();
@@ -586,7 +586,7 @@ codet character_refine_preprocesst::convert_is_ideographic(
586586
conversion_inputt &target)
587587
{
588588
const code_function_callt &function_call=target;
589-
assert(function_call.arguments().size()==1);
589+
PRECONDITION(function_call.arguments().size() == 1);
590590
const exprt &arg=function_call.arguments()[0];
591591
const exprt &result=function_call.lhs();
592592
exprt is_ideograph=in_interval_expr(arg, 0x4E00, 0x9FFF);
@@ -600,7 +600,7 @@ codet character_refine_preprocesst::convert_is_ISO_control_char(
600600
conversion_inputt &target)
601601
{
602602
const code_function_callt &function_call=target;
603-
assert(function_call.arguments().size()==1);
603+
PRECONDITION(function_call.arguments().size() == 1);
604604
const exprt &arg=function_call.arguments()[0];
605605
const exprt &result=function_call.lhs();
606606
or_exprt iso(
@@ -758,7 +758,7 @@ codet character_refine_preprocesst::convert_is_low_surrogate(
758758
conversion_inputt &target)
759759
{
760760
const code_function_callt &function_call=target;
761-
assert(function_call.arguments().size()==1);
761+
PRECONDITION(function_call.arguments().size() == 1);
762762
const exprt &arg=function_call.arguments()[0];
763763
const exprt &result=function_call.lhs();
764764
exprt is_low_surrogate=in_interval_expr(arg, 0xDC00, 0xDFFF);
@@ -895,7 +895,7 @@ codet character_refine_preprocesst::convert_is_surrogate_pair(
895895
conversion_inputt &target)
896896
{
897897
const code_function_callt &function_call=target;
898-
assert(function_call.arguments().size()==2);
898+
PRECONDITION(function_call.arguments().size() == 2);
899899
const exprt &arg0=function_call.arguments()[0];
900900
const exprt &arg1=function_call.arguments()[1];
901901
const exprt &result=function_call.lhs();

‎jbmc/src/java_bytecode/expr2java.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ std::string expr2javat::convert_struct(
117117
const struct_typet::componentst &components=
118118
struct_type.components();
119119

120-
assert(components.size()==src.operands().size());
120+
DATA_INVARIANT(
121+
components.size() == src.operands().size(),
122+
"inconsistent number of components");
121123

122124
exprt::operandst::const_iterator o_it=src.operands().begin();
123125

0 commit comments

Comments
 (0)