Skip to content

replace assert(false) by UNREACHABLE #1301

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 30, 2017
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
2 changes: 1 addition & 1 deletion src/analyses/constant_propagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void constant_propagator_domaint::assign_rec(
cond = simplify_expr(cond,ns);
}
else
assert(0);
UNREACHABLE;

assign(values, to_symbol_expr(lhs), cond, ns);
}
Expand Down
4 changes: 2 additions & 2 deletions src/analyses/custom_bitvector_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void custom_bitvector_domaint::transform(
else if(identifier=="__CPROVER_clear_may")
mode=modet::CLEAR_MAY;
else
assert(false);
UNREACHABLE;

exprt lhs=code_function_call.arguments()[0];

Expand Down Expand Up @@ -411,7 +411,7 @@ void custom_bitvector_domaint::transform(
else if(statement=="clear_may")
mode=modet::CLEAR_MAY;
else
assert(false);
UNREACHABLE;

exprt lhs=instruction.code.op0();

Expand Down
2 changes: 1 addition & 1 deletion src/analyses/goto_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ void goto_checkt::nan_check(
equal_exprt(expr.op1(), minus_inf)));
}
else
assert(false);
UNREACHABLE;

isnan.make_not();

Expand Down
2 changes: 1 addition & 1 deletion src/analyses/goto_rw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ void goto_rw(goto_programt::const_targett target,
switch(target->type)
{
case NO_INSTRUCTION_TYPE:
assert(false);
UNREACHABLE;
break;

case GOTO:
Expand Down
4 changes: 2 additions & 2 deletions src/analyses/invariant_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ void invariant_sett::strengthen_rec(const exprt &expr)
}
}
else
assert(false);
UNREACHABLE;
}
else if(expr.id()==ID_equal)
{
Expand Down Expand Up @@ -673,7 +673,7 @@ tvt invariant_sett::implies_rec(const exprt &expr) const
else if(expr.id()==ID_notequal)
return is_ne(p);
else
assert(false);
UNREACHABLE;
}

return tvt::unknown();
Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/ansi_c_convert_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ void ansi_c_convert_typet::write(typet &type)
else
type=unsigned_long_long_int_type();
else
assert(false);
UNREACHABLE;
}
else if(gcc_int128_cnt)
{
Expand Down
5 changes: 3 additions & 2 deletions src/ansi-c/ansi_c_declaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Author: Daniel Kroening, [email protected]

#include <util/config.h>
#include <util/std_types.h>
#include <util/invariant.h>

void ansi_c_declaratort::build(irept &src)
{
Expand All @@ -36,7 +37,7 @@ void ansi_c_declaratort::build(irept &src)
else if(t.id().empty() ||
t.is_nil())
{
assert(0);
UNREACHABLE;
}
else if(t.id()==ID_abstract)
{
Expand Down Expand Up @@ -108,7 +109,7 @@ typet ansi_c_declarationt::full_type(
p=&(p->subtypes().back());
}
else
assert(false);
UNREACHABLE;
}

*p=type();
Expand Down
4 changes: 2 additions & 2 deletions src/ansi-c/ansi_c_entry_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ bool ansi_c_entry_point(
max=to_unsignedbv_type(envp_size_symbol.type).largest();
}
else
assert(false);
UNREACHABLE;

exprt max_minus_one=from_integer(max-1, envp_size_symbol.type);

Expand Down Expand Up @@ -431,7 +431,7 @@ bool ansi_c_entry_point(
}
}
else
assert(false);
UNREACHABLE;
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/ansi-c/c_preprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static std::string type_max(const typet &src)
return integer2string(
power(2, to_unsignedbv_type(src).get_width()-1)-1);
else
assert(false);
UNREACHABLE;
}

/// quote a string for bash and CMD
Expand Down Expand Up @@ -766,7 +766,7 @@ bool c_preprocess_gcc_clang(
else if(config.ansi_c.wchar_t_width==config.ansi_c.char_width)
command+=" -D__WCHAR_TYPE__=\""+sig+" char\"";
else
assert(false);
UNREACHABLE;
}

if(config.ansi_c.char_is_unsigned)
Expand Down Expand Up @@ -804,7 +804,7 @@ bool c_preprocess_gcc_clang(
break;

default:
assert(false);
UNREACHABLE;
}

// Standard Defines, ANSI9899 6.10.8
Expand Down
10 changes: 5 additions & 5 deletions src/ansi-c/c_typecast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,11 @@ void c_typecastt::implicit_typecast_arithmetic(
}
return;

case BOOL: assert(false); // should always be promoted to int
case CHAR: assert(false); // should always be promoted to int
case UCHAR: assert(false); // should always be promoted to int
case SHORT: assert(false); // should always be promoted to int
case USHORT: assert(false); // should always be promoted to int
case BOOL: UNREACHABLE; // should always be promoted to int
case CHAR: UNREACHABLE; // should always be promoted to int
case UCHAR: UNREACHABLE; // should always be promoted to int
case SHORT: UNREACHABLE; // should always be promoted to int
case USHORT: UNREACHABLE; // should always be promoted to int
case INT: new_type=signed_int_type(); break;
case UINT: new_type=unsigned_int_type(); break;
case LONG: new_type=signed_long_int_type(); break;
Expand Down
8 changes: 4 additions & 4 deletions src/ansi-c/c_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void c_typecheck_baset::add_rounding_mode(exprt &expr)
else if(expr.id()==ID_minus)
expr.id(ID_floatbv_minus);
else
assert(false);
UNREACHABLE;

expr.op2()=from_integer(0, unsigned_int_type());
}
Expand Down Expand Up @@ -875,7 +875,7 @@ void c_typecheck_baset::typecheck_side_effect_statement_expression(
else if(last_statement==ID_function_call)
{
// this is suspected to be dead
assert(false);
UNREACHABLE;

// make the last statement an expression

Expand Down Expand Up @@ -2852,7 +2852,7 @@ void c_typecheck_baset::typecheck_expr_binary_arithmetic(exprt &expr)
else if(expr.id()==ID_bitxor)
expr.id(ID_xor);
else
assert(false);
UNREACHABLE;
expr.type()=type0;
return;
}
Expand Down Expand Up @@ -3010,7 +3010,7 @@ void c_typecheck_baset::typecheck_expr_pointer_arithmetic(exprt &expr)
else
{
p_op=int_op=nullptr;
assert(false);
UNREACHABLE;
}

const typet &int_op_type=follow(int_op->type());
Expand Down
4 changes: 2 additions & 2 deletions src/ansi-c/c_typecheck_initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ void c_typecheck_baset::designator_enter(
entry.subtype=vector_type.subtype();
}
else
assert(false);
UNREACHABLE;

designator.push_entry(entry);
}
Expand Down Expand Up @@ -478,7 +478,7 @@ exprt::operandst::const_iterator c_typecheck_baset::do_designated_initializer(
dest=&(dest->op0());
}
else
assert(false);
UNREACHABLE;
}

// second phase: assign value
Expand Down
4 changes: 2 additions & 2 deletions src/ansi-c/c_typecheck_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ void c_typecheck_baset::typecheck_custom_type(typet &type)
type.set(ID_f, integer2string(f_int));
}
else
assert(false);
UNREACHABLE;
}

void c_typecheck_baset::typecheck_code_type(code_typet &type)
Expand Down Expand Up @@ -759,7 +759,7 @@ void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type)
else if(compound_symbol.type.id()==ID_union)
compound_symbol.type.id(ID_incomplete_union);
else
assert(false);
UNREACHABLE;

symbolt *new_symbol;
move_symbol(compound_symbol, new_symbol);
Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/expr2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void expr2ct::get_shorthands(const exprt &expr)
ns_collision[symbol->location.get_function()].insert(sh);

if(!shorthands.insert(std::make_pair(*it, sh)).second)
assert(false);
UNREACHABLE;
}

for(find_symbols_sett::const_iterator
Expand Down
2 changes: 1 addition & 1 deletion src/cbmc/all_properties_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class bmc_all_propertiest:
}

// make some poor compilers happy
assert(false);
UNREACHABLE;
return "";
}

Expand Down
2 changes: 1 addition & 1 deletion src/cbmc/counterexample_beautification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ counterexample_beautificationt::get_failed_property(
prop_conv.l_get(it->cond_literal).is_false())
return it;

assert(false);
UNREACHABLE;
return equation.SSA_steps.end();
}

Expand Down
2 changes: 1 addition & 1 deletion src/cbmc/fault_localization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fault_localizationt::get_failed_property()
bmc.prop_conv.l_get(it->cond_literal).is_false())
return it;

assert(false);
UNREACHABLE;
return bmc.equation.SSA_steps.end();
}

Expand Down
2 changes: 1 addition & 1 deletion src/cbmc/symex_coverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ void goto_program_coverage_recordt::compute_coverage_lines(
branches_total+=2;
if(!entry.first->second.conditions.insert(
{it, coverage_conditiont()}).second)
assert(false);
UNREACHABLE;
}

symex_coveraget::coveraget::const_iterator c_entry=
Expand Down
6 changes: 3 additions & 3 deletions src/clobber/clobber_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ void clobber_parse_optionst::report_success()
break;

default:
assert(false);
UNREACHABLE;
}
}

Expand All @@ -458,7 +458,7 @@ void clobber_parse_optionst::show_counterexample(
break;

default:
assert(false);
UNREACHABLE;
}
}

Expand All @@ -481,7 +481,7 @@ void clobber_parse_optionst::report_failure()
break;

default:
assert(false);
UNREACHABLE;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/cpp/cpp_constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ codet cpp_typecheckt::cpp_constructor(
}
else if(tmp_type.id()==ID_union)
{
assert(0); // Todo: union
UNREACHABLE; // Todo: union
}
else if(tmp_type.id()==ID_struct)
{
Expand Down Expand Up @@ -301,7 +301,7 @@ codet cpp_typecheckt::cpp_constructor(
}
}
else
assert(false);
UNREACHABLE;

codet nil;
nil.make_nil();
Expand Down
8 changes: 4 additions & 4 deletions src/cpp/cpp_convert_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Author: Daniel Kroening, [email protected]

#include <cassert>

#include <util/config.h>
#include <util/arith_tools.h>
#include <util/std_types.h>

#include <util/c_types.h>
#include <util/config.h>
#include <util/invariant.h>
#include <util/std_types.h>

#include "cpp_declaration.h"
#include "cpp_name.h"
Expand Down Expand Up @@ -285,7 +285,7 @@ void cpp_convert_typet::read_function_type(const typet &type)
throw "ellipsis only allowed as last parameter";
}
else
assert(false);
UNREACHABLE;
}

// if we just have one parameter of type void, remove it
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_declarator_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ symbolt &cpp_declarator_convertert::convert(
// adjust template type
if(final_type.id()==ID_template)
{
assert(0);
UNREACHABLE;
typet tmp;
tmp.swap(final_type.subtype());
final_type.swap(tmp);
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ std::ostream &operator << (std::ostream &out, cpp_scopet::lookup_kindt kind)
case cpp_scopet::QUALIFIED: return out << "QUALIFIED";
case cpp_scopet::SCOPE_ONLY: return out << "SCOPE_ONLY";
case cpp_scopet::RECURSIVE: return out << "RECURSIVE";
default: assert(false);
default: UNREACHABLE;
}

return out;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void cpp_typecheckt::do_not_typechecked()
cont=true;
}
else
assert(0); // Don't know what to do!
UNREACHABLE; // Don't know what to do!
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class cpp_typecheckt:public c_typecheck_baset

void put_compound_into_scope(const struct_union_typet::componentt &component);
void typecheck_compound_body(symbolt &symbol);
void typecheck_compound_body(struct_union_typet &type) { assert(false); }
void typecheck_compound_body(struct_union_typet &type) { UNREACHABLE; }
void typecheck_enum_body(symbolt &symbol);
void typecheck_method_bodies(method_bodiest &);
void typecheck_compound_bases(struct_typet &type);
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck_bases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void cpp_typecheckt::add_base_components(
component.set_access(ID_private);
}
else
assert(false);
UNREACHABLE;

// put into scope
}
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ bool cpp_typecheckt::dynamic_typecast(
{
if(!e.get_bool(ID_C_lvalue))
return false;
assert(0); // currently not supported
UNREACHABLE; // currently not supported
}
else if(follow(type.subtype()).id()==ID_struct)
{
Expand Down
Loading