Skip to content

Commit 6f61609

Browse files
Clean-up irep-id emptyness checks in cpp
1 parent 2c7a355 commit 6f61609

10 files changed

+18
-18
lines changed

src/cpp/cpp_declarator.cpp

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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);

0 commit comments

Comments
 (0)