Skip to content

Commit 9d8d81a

Browse files
author
Daniel Kroening
authored
Merge pull request #997 from peterschrammel/clean-up-irep-id-empty
Clean up irep id emptyness checks
2 parents 74e21ce + 248eed6 commit 9d8d81a

33 files changed

+57
-57
lines changed

src/analyses/goto_check.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1689,21 +1689,21 @@ void goto_checkt::goto_check(
16891689
{
16901690
i_it->source_location.id(irep_idt());
16911691

1692-
if(it->source_location.get_file()!=irep_idt())
1692+
if(!it->source_location.get_file().empty())
16931693
i_it->source_location.set_file(it->source_location.get_file());
16941694

1695-
if(it->source_location.get_line()!=irep_idt())
1695+
if(!it->source_location.get_line().empty())
16961696
i_it->source_location.set_line(it->source_location.get_line());
16971697

1698-
if(it->source_location.get_function()!=irep_idt())
1698+
if(!it->source_location.get_function().empty())
16991699
i_it->source_location.set_function(
17001700
it->source_location.get_function());
17011701

1702-
if(it->source_location.get_column()!=irep_idt())
1702+
if(!it->source_location.get_column().empty())
17031703
i_it->source_location.set_column(it->source_location.get_column());
17041704
}
17051705

1706-
if(i_it->function==irep_idt())
1706+
if(i_it->function.empty())
17071707
i_it->function=it->function;
17081708
}
17091709

src/ansi-c/ansi_c_declaration.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void ansi_c_declaratort::build(irept &src)
3333
t.make_nil();
3434
break;
3535
}
36-
else if(t.id()==irep_idt() ||
36+
else if(t.id().empty() ||
3737
t.is_nil())
3838
{
3939
assert(0);

src/ansi-c/c_typecheck_base.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ void c_typecheck_baset::typecheck_function_body(symbolt &symbol)
539539
p_it++)
540540
{
541541
// may be anonymous
542-
if(p_it->get_base_name()==irep_idt())
542+
if(p_it->get_base_name().empty())
543543
{
544544
irep_idt base_name="#anon"+std::to_string(anon_counter++);
545545
p_it->set_base_name(base_name);

src/ansi-c/c_typecheck_expr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ void c_typecheck_baset::typecheck_expr_member(exprt &expr)
15221522
// copy method identifier
15231523
const irep_idt &identifier=component.get(ID_C_identifier);
15241524

1525-
if(identifier!=irep_idt())
1525+
if(!identifier.empty())
15261526
expr.set(ID_C_identifier, identifier);
15271527

15281528
const irep_idt &access=component.get_access();

src/ansi-c/c_typecheck_type.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type)
428428
irep_idt identifier=declaration.declarator().get_name();
429429

430430
// abstract or not?
431-
if(identifier==irep_idt())
431+
if(identifier.empty())
432432
{
433433
// abstract
434434
parameter.add_source_location()=declaration.type().source_location();
@@ -550,7 +550,7 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
550550
{
551551
// not a constant and not infinity
552552

553-
assert(current_symbol_id!=irep_idt());
553+
assert(!current_symbol_id.empty());
554554

555555
const symbolt &base_symbol=lookup(current_symbol_id);
556556

@@ -862,7 +862,7 @@ void c_typecheck_baset::typecheck_compound_body(
862862
// scan for anonymous members, and name them
863863
for(auto &member : components)
864864
{
865-
if(member.get_name()!=irep_idt())
865+
if(!member.get_name().empty())
866866
continue;
867867

868868
member.set_name("$anon"+std::to_string(anon_member_counter++));

src/ansi-c/type2name.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static std::string type2name(
110110
if(!type.source_location().get_function().empty())
111111
result+='l';
112112

113-
if(type.id()==irep_idt())
113+
if(type.id().empty())
114114
throw "empty type encountered";
115115
else if(type.id()==ID_empty)
116116
result+='V';

src/cpp/cpp_declarator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ typet cpp_declaratort::merge_type(const typet &declaration_type) const
4949
}
5050
else
5151
{
52-
assert(t.id()!=irep_idt());
52+
assert(!t.id().empty());
5353
p=&t.subtype();
5454
}
5555
}

src/cpp/cpp_exception_id.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void cpp_exception_list_rec(
5959
// grab C/C++ type
6060
irep_idt c_type=src.get(ID_C_c_type);
6161

62-
if(c_type!=irep_idt())
62+
if(!c_type.empty())
6363
{
6464
dest.push_back(id2string(c_type)+suffix);
6565
return;

src/cpp/cpp_instantiate_template.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ const symbolt &cpp_typecheckt::instantiate_template(
485485
bool is_static=new_decl.storage_spec().is_static();
486486
irep_idt access = new_decl.get(ID_C_access);
487487

488-
assert(access != irep_idt());
488+
assert(!access.empty());
489489
assert(symb.type.id()==ID_struct);
490490

491491
typecheck_compound_declarator(

src/cpp/cpp_type2name.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ std::string cpp_type2name(const typet &type)
119119
// we try to use #c_type
120120
const irep_idt c_type=type.get(ID_C_c_type);
121121

122-
if(c_type!=irep_idt())
122+
if(!c_type.empty())
123123
result+=id2string(c_type);
124124
else if(type.id()==ID_unsignedbv)
125125
result+="unsigned_int";
@@ -131,7 +131,7 @@ std::string cpp_type2name(const typet &type)
131131
// we try to use #c_type
132132
const irep_idt c_type=type.get(ID_C_c_type);
133133

134-
if(c_type!=irep_idt())
134+
if(!c_type.empty())
135135
result+=id2string(c_type);
136136
else
137137
result+="double";

src/cpp/cpp_typecheck_bases.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void cpp_typecheckt::typecheck_compound_bases(struct_typet &type)
7171
bool virtual_base = base_it->get_bool(ID_virtual);
7272
irep_idt class_access = base_it->get(ID_protection);
7373

74-
if(class_access==irep_idt())
74+
if(class_access.empty())
7575
class_access = default_class_access;
7676

7777
base_symbol_expr.id(ID_base);

src/cpp/cpp_typecheck_compound_type.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
602602
{
603603
irep_idt base_name=arg.get_base_name();
604604

605-
if(base_name==irep_idt())
605+
if(base_name.empty())
606606
base_name="arg"+std::to_string(i++);
607607

608608
symbolt arg_symb;
@@ -769,7 +769,7 @@ void cpp_typecheckt::put_compound_into_scope(
769769
const irep_idt &name=compound.get_name();
770770

771771
// nothing to do if no base_name (e.g., an anonymous bitfield)
772-
if(base_name==irep_idt())
772+
if(base_name.empty())
773773
return;
774774

775775
if(compound.type().id()==ID_code)
@@ -983,7 +983,7 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol)
983983
continue;
984984
}
985985

986-
if(declaration.type().id()==irep_idt()) // empty?
986+
if(declaration.type().id().empty())
987987
continue;
988988

989989
bool is_typedef=declaration.is_typedef();
@@ -1259,7 +1259,7 @@ void cpp_typecheckt::typecheck_member_function(
12591259

12601260
if(component.get_bool(ID_is_static))
12611261
{
1262-
if(method_qualifier.id()!=irep_idt())
1262+
if(!method_qualifier.id().empty())
12631263
{
12641264
error().source_location=component.source_location();
12651265
error() << "method is static -- no qualifiers allowed" << eom;

src/cpp/cpp_typecheck_expr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr)
571571
}
572572

573573
for(const operator_entryt *e=operators;
574-
e->id!=irep_idt();
574+
!e->id.empty();
575575
e++)
576576
if(expr.id()==e->id)
577577
{

src/cpp/cpp_typecheck_type.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Author: Daniel Kroening, [email protected]
2020

2121
void cpp_typecheckt::typecheck_type(typet &type)
2222
{
23-
assert(type.id()!=irep_idt());
23+
assert(!type.id().empty());
2424
assert(type.is_not_nil());
2525

2626
try

src/cpp/expr2cpp.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ std::string expr2cppt::convert_rec(
150150
{
151151
return q+convert(src.subtype())+" &&"+d;
152152
}
153-
else if(src.get(ID_C_c_type)!=irep_idt())
153+
else if(!src.get(ID_C_c_type).empty())
154154
{
155155
const irep_idt c_type=src.get(ID_C_c_type);
156156

@@ -208,7 +208,7 @@ std::string expr2cppt::convert_rec(
208208
else
209209
dest+="struct";
210210

211-
if(symbol.pretty_name!=irep_idt())
211+
if(!symbol.pretty_name.empty())
212212
dest+=" "+id2string(symbol.pretty_name);
213213

214214
dest+=d;
@@ -221,7 +221,7 @@ std::string expr2cppt::convert_rec(
221221

222222
dest+="enum";
223223

224-
if(symbol.pretty_name!=irep_idt())
224+
if(!symbol.pretty_name.empty())
225225
dest+=" "+id2string(symbol.pretty_name);
226226

227227
dest+=d;

src/cpp/parse.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class Parser // NOLINT(readability/identifiers)
398398
{
399399
typet *p=&dest;
400400

401-
while(p->id()!=irep_idt() && p->is_not_nil())
401+
while(!p->id().empty() && p->is_not_nil())
402402
{
403403
if(p->id()==ID_merged_type)
404404
{
@@ -2224,7 +2224,7 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p)
22242224
default: type_id=irep_idt();
22252225
}
22262226

2227-
if(type_id!=irep_idt())
2227+
if(!type_id.empty())
22282228
{
22292229
cpp_tokent tk;
22302230
typet kw;
@@ -3467,7 +3467,7 @@ bool Parser::rOperatorName(irept &name)
34673467
return rCastOperatorName(name);
34683468
}
34693469

3470-
assert(operator_id!=irep_idt());
3470+
assert(!operator_id.empty());
34713471
lex.get_token(tk);
34723472
name=irept(operator_id);
34733473
set_location(name, tk);

src/goto-programs/goto_inline_class.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void goto_inlinet::parameter_assignments(
5757

5858
const irep_idt &identifier=parameter.get_identifier();
5959

60-
if(identifier==irep_idt())
60+
if(identifier.empty())
6161
{
6262
error().source_location=source_location;
6363
error() << "no identifier for function parameter" << eom;
@@ -182,7 +182,7 @@ void goto_inlinet::parameter_destruction(
182182

183183
const irep_idt &identifier=parameter.get_identifier();
184184

185-
if(identifier==irep_idt())
185+
if(identifier.empty())
186186
{
187187
error().source_location=source_location;
188188
error() << "no identifier for function parameter" << eom;
@@ -328,13 +328,13 @@ void replace_location(
328328

329329
dest=new_location;
330330

331-
if(comment!=irep_idt())
331+
if(!comment.empty())
332332
dest.set_comment(comment);
333333

334-
if(property_class!=irep_idt())
334+
if(!property_class.empty())
335335
dest.set_property_class(property_class);
336336

337-
if(property_id!=irep_idt())
337+
if(!property_id.empty())
338338
dest.set_property_id(property_id);
339339
}
340340

src/goto-symex/symex_builtin_functions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void goto_symext::symex_gcc_builtin_va_arg_next(
221221

222222
exprt rhs=zero_initializer(lhs.type(), code.source_location(), ns);
223223

224-
if(id!=irep_idt())
224+
if(!id.empty())
225225
{
226226
// strip last name off id to get function name
227227
std::size_t pos=id2string(id).rfind("::");

src/goto-symex/symex_function_call.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void goto_symext::parameter_assignments(
6262

6363
const irep_idt &identifier=parameter.get_identifier();
6464

65-
if(identifier==irep_idt())
65+
if(identifier.empty())
6666
throw "no identifier for function parameter";
6767

6868
const symbolt &symbol=ns.lookup(identifier);

src/java_bytecode/java_bytecode_convert_method.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2309,7 +2309,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
23092309
if(v.is_parameter)
23102310
continue;
23112311
// Skip anonymous variables:
2312-
if(v.symbol_expr.get_identifier()==irep_idt())
2312+
if(v.symbol_expr.get_identifier().empty())
23132313
continue;
23142314
auto &block=get_block_for_pcrange(
23152315
root,

src/java_bytecode/java_bytecode_language.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ static void get_virtual_method_targets(
203203
assert(called_function.id()==ID_virtual_function);
204204

205205
const auto &call_class=called_function.get(ID_C_class);
206-
assert(call_class!=irep_idt());
206+
assert(!call_class.empty());
207207
const auto &call_basename=called_function.get(ID_component_name);
208-
assert(call_basename!=irep_idt());
208+
assert(!call_basename.empty());
209209

210210
auto old_size=needed_methods.size();
211211

@@ -218,7 +218,7 @@ static void get_virtual_method_targets(
218218
call_basename,
219219
child_class,
220220
symbol_table);
221-
if(child_method!=irep_idt())
221+
if(!child_method.empty())
222222
needed_methods.push_back(child_method);
223223
}
224224

@@ -231,7 +231,7 @@ static void get_virtual_method_targets(
231231
call_basename,
232232
parent_class_id,
233233
symbol_table);
234-
if(parent_method!=irep_idt())
234+
if(!parent_method.empty())
235235
{
236236
needed_methods.push_back(parent_method);
237237
break;

src/java_bytecode/java_bytecode_parse_tree.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void java_bytecode_parse_treet::methodt::output(std::ostream &out) const
157157

158158
for(const auto &i : instructions)
159159
{
160-
if(i.source_location.get_line()!=irep_idt())
160+
if(!i.source_location.get_line().empty())
161161
out << " // " << i.source_location << '\n';
162162

163163
out << " " << i.address << ": ";

src/path-symex/build_goto_trace.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void build_goto_trace(
105105
const irep_idt &comment=
106106
instruction.source_location.get_comment();
107107

108-
if(comment!=irep_idt())
108+
if(!comment.empty())
109109
trace_step.comment=id2string(comment);
110110
else
111111
trace_step.comment="assertion";

src/path-symex/path_symex.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ void path_symext::function_call_rec(
699699
const code_typet::parametert &function_parameter=function_parameters[i];
700700
irep_idt identifier=function_parameter.get_identifier();
701701

702-
if(identifier==irep_idt())
702+
if(identifier.empty())
703703
throw "function_call " + id2string(function_identifier)
704704
+ " no identifier for function parameter";
705705

src/path-symex/path_symex_state_read.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ exprt path_symex_statet::read_symbol_member_index(
407407
else
408408
{
409409
// we do some SSA symbol
410-
if(var_state.ssa_symbol.get_identifier()==irep_idt())
410+
if(var_state.ssa_symbol.get_identifier().empty())
411411
{
412412
// produce one
413413
var_state.ssa_symbol=var_info.ssa_symbol();

src/path-symex/var_map.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var_mapt::var_infot &var_mapt::operator()(
2222
const irep_idt &suffix,
2323
const typet &type)
2424
{
25-
assert(symbol!=irep_idt());
25+
assert(!symbol.empty());
2626

2727
std::string full_identifier=
2828
id2string(symbol)+id2string(suffix);

src/pointer-analysis/add_failed_symbols.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ exprt get_failed_symbol(
7676
const symbolt &symbol=ns.lookup(expr);
7777
irep_idt failed_symbol_id=symbol.type.get(ID_C_failed_symbol);
7878

79-
if(failed_symbol_id==irep_idt())
79+
if(failed_symbol_id.empty())
8080
return nil_exprt();
8181

8282
const symbolt &failed_symbol=ns.lookup(failed_symbol_id);

0 commit comments

Comments
 (0)