Skip to content

Commit 49bceb2

Browse files
authored
Merge pull request #1172 from diffblue/revert-1159-use-nullptr-master
Revert "[depends: #1063] Use nullptr to represent null pointers (targets master)"
2 parents 747db78 + 6fea4fa commit 49bceb2

File tree

83 files changed

+296
-324
lines changed

Some content is hidden

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

83 files changed

+296
-324
lines changed

src/analyses/goto_check.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class goto_checkt
3737
const namespacet &_ns,
3838
const optionst &_options):
3939
ns(_ns),
40-
local_bitvector_analysis(nullptr)
40+
local_bitvector_analysis(0)
4141
{
4242
enable_bounds_check=_options.get_bool_option("bounds-check");
4343
enable_pointer_check=_options.get_bool_option("pointer-check");

src/analyses/goto_rw.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,9 @@ void rw_range_sett::add(
463463
{
464464
objectst::iterator entry=(mode==get_modet::LHS_W ? w_range_set : r_range_set).
465465
insert(
466-
std::pair<const irep_idt&, range_domain_baset*>(
467-
identifier, nullptr)).first;
466+
std::pair<const irep_idt&, range_domain_baset*>(identifier, 0)).first;
468467

469-
if(entry->second==nullptr)
468+
if(entry->second==0)
470469
entry->second=new range_domaint();
471470

472471
static_cast<range_domaint*>(entry->second)->push_back(
@@ -664,10 +663,9 @@ void rw_guarded_range_set_value_sett::add(
664663
{
665664
objectst::iterator entry=(mode==get_modet::LHS_W ? w_range_set : r_range_set).
666665
insert(
667-
std::pair<const irep_idt&, range_domain_baset*>(
668-
identifier, nullptr)).first;
666+
std::pair<const irep_idt&, range_domain_baset*>(identifier, 0)).first;
669667

670-
if(entry->second==nullptr)
668+
if(entry->second==0)
671669
entry->second=new guarded_range_domaint();
672670

673671
static_cast<guarded_range_domaint*>(entry->second)->insert(

src/analyses/goto_rw.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class rw_range_sett
108108

109109
const range_domaint &get_ranges(objectst::const_iterator it) const
110110
{
111-
PRECONDITION(dynamic_cast<range_domaint*>(it->second)!=nullptr);
111+
assert(dynamic_cast<range_domaint*>(it->second)!=0);
112112
return *static_cast<range_domaint*>(it->second);
113113
}
114114

@@ -277,7 +277,7 @@ class rw_guarded_range_set_value_sett:public rw_range_set_value_sett
277277

278278
const guarded_range_domaint &get_ranges(objectst::const_iterator it) const
279279
{
280-
PRECONDITION(dynamic_cast<guarded_range_domaint*>(it->second)!=nullptr);
280+
assert(dynamic_cast<guarded_range_domaint*>(it->second)!=0);
281281
return *static_cast<guarded_range_domaint*>(it->second);
282282
}
283283

src/analyses/invariant_set.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ bool invariant_sett::get_object(
144144
const exprt &expr,
145145
unsigned &n) const
146146
{
147-
PRECONDITION(object_store!=nullptr);
147+
assert(object_store!=NULL);
148148
return object_store->get(expr, n);
149149
}
150150

@@ -315,8 +315,7 @@ void invariant_sett::output(
315315
return;
316316
}
317317

318-
INVARIANT(
319-
object_store!=nullptr, nullptr_exceptiont("Object store is null"));
318+
assert(object_store!=NULL);
320319

321320
for(unsigned i=0; i<eq_set.size(); i++)
322321
if(eq_set.is_root(i) &&
@@ -900,7 +899,7 @@ std::string invariant_sett::to_string(
900899
unsigned a,
901900
const irep_idt &identifier) const
902901
{
903-
PRECONDITION(object_store!=nullptr);
902+
assert(object_store!=NULL);
904903
return object_store->to_string(a, identifier);
905904
}
906905

src/analyses/invariant_set.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ Author: Daniel Kroening, [email protected]
2222

2323
#include "interval_template.h"
2424

25-
#define nullptr_exceptiont(str) str
26-
2725
class inv_object_storet
2826
{
2927
public:
@@ -100,9 +98,9 @@ class invariant_sett
10098
invariant_sett():
10199
threaded(false),
102100
is_false(false),
103-
value_sets(nullptr),
104-
object_store(nullptr),
105-
ns(nullptr)
101+
value_sets(NULL),
102+
object_store(NULL),
103+
ns(NULL)
106104
{
107105
}
108106

src/analyses/local_may_alias.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class local_may_aliast
9494
class local_may_alias_factoryt
9595
{
9696
public:
97-
local_may_alias_factoryt():goto_functions(nullptr)
97+
local_may_alias_factoryt():goto_functions(NULL)
9898
{
9999
}
100100

@@ -109,7 +109,7 @@ class local_may_alias_factoryt
109109

110110
local_may_aliast &operator()(const irep_idt &fkt)
111111
{
112-
PRECONDITION(goto_functions!=nullptr);
112+
assert(goto_functions!=NULL);
113113
fkt_mapt::iterator f_it=fkt_map.find(fkt);
114114
if(f_it!=fkt_map.end())
115115
return *f_it->second;

src/analyses/reaching_definitions.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ void rd_range_domaint::transform(
5151
{
5252
reaching_definitions_analysist *rd=
5353
dynamic_cast<reaching_definitions_analysist*>(&ai);
54-
INVARIANT(
55-
rd!=nullptr,
56-
bad_cast_exceptiont("ai has type reaching_definitions_analysist"));
54+
assert(rd!=0);
5755

5856
assert(bv_container);
5957

@@ -300,9 +298,7 @@ void rd_range_domaint::transform_assign(
300298
const symbolt *symbol_ptr;
301299
if(ns.lookup(identifier, symbol_ptr))
302300
continue;
303-
INVARIANT(
304-
symbol_ptr!=nullptr,
305-
nullptr_exceptiont("Symbol is in symbol table"));
301+
assert(symbol_ptr!=0);
306302

307303
const range_domaint &ranges=rw_set.get_ranges(it);
308304

src/analyses/reaching_definitions.h

+5-10
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ class is_threadedt;
2626
class dirtyt;
2727
class reaching_definitions_analysist;
2828

29-
#define bad_cast_exceptiont(str) str
30-
#define nullptr_exceptiont(str) str
31-
3229
// requirement: V has a member "identifier" of type irep_idt
3330
template<typename V>
3431
class sparse_bitvector_analysist
@@ -105,7 +102,7 @@ class rd_range_domaint:public ai_domain_baset
105102
rd_range_domaint():
106103
ai_domain_baset(),
107104
has_values(false),
108-
bv_container(nullptr)
105+
bv_container(0)
109106
{
110107
}
111108

@@ -246,9 +243,9 @@ class reaching_definitions_analysist:
246243
explicit reaching_definitions_analysist(const namespacet &_ns):
247244
concurrency_aware_ait<rd_range_domaint>(),
248245
ns(_ns),
249-
value_sets(nullptr),
250-
is_threaded(nullptr),
251-
is_dirty(nullptr)
246+
value_sets(0),
247+
is_threaded(0),
248+
is_dirty(0)
252249
{
253250
}
254251

@@ -262,9 +259,7 @@ class reaching_definitions_analysist:
262259
statet &s=concurrency_aware_ait<rd_range_domaint>::get_state(l);
263260

264261
rd_range_domaint *rd_state=dynamic_cast<rd_range_domaint*>(&s);
265-
INVARIANT(
266-
rd_state!=nullptr,
267-
bad_cast_exceptiont("rd_state has type rd_range_domaint"));
262+
assert(rd_state!=0);
268263

269264
rd_state->set_bitvector_container(*this);
270265

src/ansi-c/c_preprocess.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ bool c_preprocess(
344344
static bool is_dot_i_file(const std::string &path)
345345
{
346346
const char *ext=strrchr(path.c_str(), '.');
347-
if(ext==nullptr)
347+
if(ext==NULL)
348348
return false;
349349
if(std::string(ext)==".i" ||
350350
std::string(ext)==".ii")
@@ -889,7 +889,7 @@ bool c_preprocess_gcc_clang(
889889

890890
FILE *stream=popen(command.c_str(), "r");
891891

892-
if(stream!=nullptr)
892+
if(stream!=NULL)
893893
{
894894
int ch;
895895
while((ch=fgetc(stream))!=EOF)
@@ -1011,7 +1011,7 @@ bool c_preprocess_arm(
10111011

10121012
FILE *stream=popen(command.c_str(), "r");
10131013

1014-
if(stream!=nullptr)
1014+
if(stream!=NULL)
10151015
{
10161016
int ch;
10171017
while((ch=fgetc(stream))!=EOF)

src/ansi-c/cprover_library.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ std::string get_cprover_library_text(
3838
std::size_t count=0;
3939

4040
for(cprover_library_entryt *e=cprover_library;
41-
e->function!=nullptr;
41+
e->function!=NULL;
4242
e++)
4343
{
4444
irep_idt id=e->function;

src/ansi-c/expr2c.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2664,7 +2664,7 @@ std::string expr2ct::convert_code_decl(
26642664

26652665
std::string dest=indent_str(indent);
26662666

2667-
const symbolt *symbol=nullptr;
2667+
const symbolt *symbol=0;
26682668
if(!ns.lookup(to_symbol_expr(src.op0()).get_identifier(), symbol))
26692669
{
26702670
if(symbol->is_file_local &&

src/big-int/bigint-test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static void
161161
run_clisp_tests (char const *fn)
162162
{
163163
FILE *f = fopen (fn, "rt");
164-
if (f == nullptr)
164+
if (f == 0)
165165
{
166166
fprintf (stderr, "Error opening %s: %s.\n", fn, strerror (errno));
167167
return;

src/big-int/bigint.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ digit_div (onedig_t *r, const onedig_t *y, unsigned yl, onedig_t *q, unsigned ql
266266
--qh;
267267
add_back (r, y, yl);
268268
}
269-
if (q != nullptr)
269+
if (q != 0)
270270
q[i] = qh;
271271
}
272272
}
@@ -580,7 +580,7 @@ char *
580580
BigInt::as_string (char *p, unsigned l, onedig_t b) const
581581
{
582582
if (l < 2)
583-
return nullptr; // Not enough room for number.
583+
return 0; // Not enough room for number.
584584
p[--l] = '\0';
585585
// Check for zero. Would otherwise print as empty string.
586586
unsigned len = length;
@@ -598,7 +598,7 @@ BigInt::as_string (char *p, unsigned l, onedig_t b) const
598598
do
599599
{
600600
if (l == 0)
601-
return nullptr;
601+
return 0;
602602
onedig_t r = digit_div (dig, len, b);
603603
p[--l] = r < 10 ? r + '0' : 'A' + r - 10;
604604
if (dig[len-1] == 0)
@@ -608,7 +608,7 @@ BigInt::as_string (char *p, unsigned l, onedig_t b) const
608608
// Maybe attach sign.
609609
if (!positive){
610610
if (l == 0)
611-
return nullptr;
611+
return 0;
612612
else
613613
p[--l] = '-';
614614
}
@@ -1268,7 +1268,7 @@ BigInt::operator%= (BigInt const &y)
12681268
}
12691269
if (a[al-1] >= b[bl-1])
12701270
a[al++] = 0;
1271-
digit_div (a, b, bl, nullptr, al - bl);
1271+
digit_div (a, b, bl, 0, al - bl);
12721272
length = bl;
12731273
adjust();
12741274
if (scale != 1)

src/cbmc/cbmc_parse_options.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ int cbmc_parse_optionst::get_goto_program(
569569

570570
languaget *language=get_language_from_filename(filename);
571571

572-
if(language==nullptr)
572+
if(language==NULL)
573573
{
574574
error() << "failed to figure out type of file `"
575575
<< filename << "'" << eom;
@@ -718,7 +718,7 @@ void cbmc_parse_optionst::preprocessing()
718718

719719
languaget *ptr=get_language_from_filename(filename);
720720

721-
if(ptr==nullptr)
721+
if(ptr==NULL)
722722
{
723723
error() << "failed to figure out type of file" << eom;
724724
return;

src/clobber/clobber_parse_options.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ bool clobber_parse_optionst::get_goto_program(
250250

251251
languaget *language=get_language_from_filename(filename);
252252

253-
if(language==nullptr)
253+
if(language==NULL)
254254
{
255255
error() << "failed to figure out type of file `" << filename << "'"
256256
<< eom;

src/cpp/cpp_id.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ cpp_idt::cpp_idt():
2424
id_class(id_classt::UNKNOWN),
2525
this_expr(static_cast<const exprt &>(get_nil_irep())),
2626
compound_counter(0),
27-
parent(nullptr)
27+
parent(NULL)
2828
{
2929
}
3030

src/cpp/cpp_id.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Author: Daniel Kroening, [email protected]
2020
#include <iosfwd>
2121

2222
#include <util/expr.h>
23-
#include <util/invariant.h>
2423
#include <util/std_types.h>
2524

2625
class cpp_scopet;
@@ -82,7 +81,7 @@ class cpp_idt
8281

8382
cpp_idt &get_parent() const
8483
{
85-
PRECONDITION(parent!=nullptr);
84+
assert(parent!=NULL);
8685
return *parent;
8786
}
8887

src/cpp/cpp_instantiate_template.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ const symbolt &cpp_typecheckt::class_template_symbol(
130130
cpp_scopet *template_scope=
131131
static_cast<cpp_scopet *>(cpp_scopes.id_map[template_symbol.name]);
132132

133-
INVARIANT(
134-
template_scope!=nullptr, nullptr_exceptiont("template_scope is null"));
133+
assert(template_scope!=NULL);
135134

136135
irep_idt identifier=
137136
id2string(template_scope->prefix)+
@@ -277,16 +276,15 @@ const symbolt &cpp_typecheckt::instantiate_template(
277276
cpp_scopet *template_scope=
278277
static_cast<cpp_scopet *>(cpp_scopes.id_map[template_symbol.name]);
279278

280-
if(template_scope==nullptr)
279+
if(template_scope==NULL)
281280
{
282281
error().source_location=source_location;
283282
error() << "identifier: " << template_symbol.name << '\n'
284283
<< "template instantiation error: scope not found" << eom;
285284
throw 0;
286285
}
287286

288-
INVARIANT(
289-
template_scope!=nullptr, nullptr_exceptiont("template_scope is null"));
287+
assert(template_scope!=NULL);
290288

291289
// produce new declaration
292290
cpp_declarationt new_decl=to_cpp_declaration(template_symbol.type);

src/cpp/cpp_language.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ bool cpp_languaget::preprocess(
6565
// check extension
6666

6767
const char *ext=strrchr(path.c_str(), '.');
68-
if(ext!=nullptr && std::string(ext)==".ipp")
68+
if(ext!=NULL && std::string(ext)==".ipp")
6969
{
7070
std::ifstream infile(path);
7171

src/cpp/cpp_typecheck.h

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ Author: Daniel Kroening, [email protected]
3030
#include "cpp_template_type.h"
3131
#include "cpp_util.h"
3232

33-
#define nullptr_exceptiont(str) str
34-
3533
bool cpp_typecheck(
3634
cpp_parse_treet &cpp_parse_tree,
3735
symbol_tablet &symbol_table,

src/cpp/cpp_typecheck_compound_type.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void cpp_typecheckt::typecheck_compound_type(
110110
// get the tag name
111111
bool has_tag=type.find(ID_tag).is_not_nil();
112112
irep_idt base_name;
113-
cpp_scopet *dest_scope=nullptr;
113+
cpp_scopet *dest_scope=NULL;
114114
bool has_body=type.find(ID_body).is_not_nil();
115115
bool tag_only_declaration=type.get_bool(ID_C_tag_only_declaration);
116116

0 commit comments

Comments
 (0)