Skip to content

Commit 26ef31c

Browse files
Use invariant instead of abort()
1 parent fe40b19 commit 26ef31c

File tree

4 files changed

+22
-27
lines changed

4 files changed

+22
-27
lines changed

src/cpp/cpp_typecheck_expr.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include "cpp_typecheck.h"
1313

14-
#include <cstdlib>
14+
#ifdef DEBUG
15+
#include <iostream>
16+
#endif
1517

1618
#include <util/pointer_offset_size.h>
1719
#include <util/std_types.h>
@@ -20,6 +22,7 @@ Author: Daniel Kroening, [email protected]
2022
#include <util/config.h>
2123
#include <util/simplify_expr.h>
2224
#include <util/base_type.h>
25+
#include <util/invariant.h>
2326

2427
#include <util/c_types.h>
2528
#include <ansi-c/c_qualifiers.h>
@@ -69,25 +72,27 @@ void cpp_typecheckt::typecheck_expr_main(exprt &expr)
6972
typecheck_expr_explicit_constructor_call(expr);
7073
else if(expr.is_nil())
7174
{
72-
#if 0
75+
#ifdef DEBUG
76+
std::cerr << "E: " << expr.pretty() << '\n';
7377
std::cerr << "cpp_typecheckt::typecheck_expr_main got nil\n";
74-
#endif
75-
abort();
78+
#endif
79+
UNREACHABLE;
7680
}
7781
else if(expr.id()==ID_code)
7882
{
79-
#if 0
83+
#ifdef DEBUG
84+
std::cerr << "E: " << expr.pretty() << '\n';
8085
std::cerr << "cpp_typecheckt::typecheck_expr_main got code\n";
81-
#endif
82-
abort();
86+
#endif
87+
UNREACHABLE;
8388
}
8489
else if(expr.id()==ID_symbol)
8590
{
86-
#if 0
87-
std::cout << "E: " << expr.pretty() << '\n';
91+
// ignore here
92+
#ifdef DEBUG
93+
std::cerr << "E: " << expr.pretty() << '\n';
8894
std::cerr << "cpp_typecheckt::typecheck_expr_main got symbol\n";
89-
abort();
90-
#endif
95+
#endif
9196
}
9297
else if(expr.id()=="__is_base_of")
9398
{

src/goto-symex/goto_symex_state.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,9 @@ void goto_symex_statet::level0t::operator()(
5050
return;
5151

5252
const symbolt *s;
53-
54-
if(ns.lookup(obj_identifier, s))
55-
{
56-
std::cerr << "level0: failed to find " << obj_identifier << '\n';
57-
abort();
58-
}
53+
const bool found_l0 = !ns.lookup(obj_identifier, s);
54+
DATA_INVARIANT(
55+
found_l0, "level0: failed to find " + id2string(obj_identifier));
5956

6057
// don't rename shared variables or functions
6158
if(s->type.id()==ID_code ||

src/solvers/refinement/refine_arithmetic.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@ void bv_refinementt::check_SAT(approximationt &a)
226226
<< "==" << integer2binary(result.pack(), spec.width()) << eom;
227227
#endif
228228

229-
// if(a.over_state==1) { debug() << "DISAGREEMENT!\n"; exit(1); }
230-
231229
if(a.over_state<config_.max_node_refinement)
232230
{
233231
bvt r;

src/util/cmdline.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ Author: Daniel Kroening, [email protected]
88

99
#include "cmdline.h"
1010

11-
#include <cassert>
12-
#include <cstdlib>
13-
#include <iostream>
11+
#include <util/invariant.h>
1412

1513
cmdlinet::cmdlinet()
1614
{
@@ -124,11 +122,8 @@ bool cmdlinet::parse(int argc, const char **argv, const char *optstring)
124122
{
125123
optiont option;
126124

127-
if(optstring[0]==':')
128-
{
129-
std::cerr << "cmdlinet::parse: Invalid option string\n";
130-
abort();
131-
}
125+
DATA_INVARIANT(
126+
optstring[0] != ':', "cmdlinet::parse: Invalid option string\n");
132127

133128
if(optstring[0]=='(')
134129
{

0 commit comments

Comments
 (0)