Skip to content

Clean up irep id emptyness checks #997

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 9 commits into from
Jun 11, 2017
10 changes: 5 additions & 5 deletions src/analyses/goto_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,21 +1689,21 @@ void goto_checkt::goto_check(
{
i_it->source_location.id(irep_idt());

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

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

if(it->source_location.get_function()!=irep_idt())
if(!it->source_location.get_function().empty())
i_it->source_location.set_function(
it->source_location.get_function());

if(it->source_location.get_column()!=irep_idt())
if(!it->source_location.get_column().empty())
i_it->source_location.set_column(it->source_location.get_column());
}

if(i_it->function==irep_idt())
if(i_it->function.empty())
i_it->function=it->function;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/ansi_c_declaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void ansi_c_declaratort::build(irept &src)
t.make_nil();
break;
}
else if(t.id()==irep_idt() ||
else if(t.id().empty() ||
t.is_nil())
{
assert(0);
Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/c_typecheck_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ void c_typecheck_baset::typecheck_function_body(symbolt &symbol)
p_it++)
{
// may be anonymous
if(p_it->get_base_name()==irep_idt())
if(p_it->get_base_name().empty())
{
irep_idt base_name="#anon"+std::to_string(anon_counter++);
p_it->set_base_name(base_name);
Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/c_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ void c_typecheck_baset::typecheck_expr_member(exprt &expr)
// copy method identifier
const irep_idt &identifier=component.get(ID_C_identifier);

if(identifier!=irep_idt())
if(!identifier.empty())
expr.set(ID_C_identifier, identifier);

const irep_idt &access=component.get_access();
Expand Down
6 changes: 3 additions & 3 deletions src/ansi-c/c_typecheck_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type)
irep_idt identifier=declaration.declarator().get_name();

// abstract or not?
if(identifier==irep_idt())
if(identifier.empty())
{
// abstract
parameter.add_source_location()=declaration.type().source_location();
Expand Down Expand Up @@ -550,7 +550,7 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
{
// not a constant and not infinity

assert(current_symbol_id!=irep_idt());
assert(!current_symbol_id.empty());

const symbolt &base_symbol=lookup(current_symbol_id);

Expand Down Expand Up @@ -862,7 +862,7 @@ void c_typecheck_baset::typecheck_compound_body(
// scan for anonymous members, and name them
for(auto &member : components)
{
if(member.get_name()!=irep_idt())
if(!member.get_name().empty())
continue;

member.set_name("$anon"+std::to_string(anon_member_counter++));
Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/type2name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static std::string type2name(
if(!type.source_location().get_function().empty())
result+='l';

if(type.id()==irep_idt())
if(type.id().empty())
throw "empty type encountered";
else if(type.id()==ID_empty)
result+='V';
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_declarator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ typet cpp_declaratort::merge_type(const typet &declaration_type) const
}
else
{
assert(t.id()!=irep_idt());
assert(!t.id().empty());
p=&t.subtype();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_exception_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void cpp_exception_list_rec(
// grab C/C++ type
irep_idt c_type=src.get(ID_C_c_type);

if(c_type!=irep_idt())
if(!c_type.empty())
{
dest.push_back(id2string(c_type)+suffix);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_instantiate_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ const symbolt &cpp_typecheckt::instantiate_template(
bool is_static=new_decl.storage_spec().is_static();
irep_idt access = new_decl.get(ID_C_access);

assert(access != irep_idt());
assert(!access.empty());
assert(symb.type.id()==ID_struct);

typecheck_compound_declarator(
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/cpp_type2name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ std::string cpp_type2name(const typet &type)
// we try to use #c_type
const irep_idt c_type=type.get(ID_C_c_type);

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

if(c_type!=irep_idt())
if(!c_type.empty())
result+=id2string(c_type);
else
result+="double";
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 @@ -71,7 +71,7 @@ void cpp_typecheckt::typecheck_compound_bases(struct_typet &type)
bool virtual_base = base_it->get_bool(ID_virtual);
irep_idt class_access = base_it->get(ID_protection);

if(class_access==irep_idt())
if(class_access.empty())
class_access = default_class_access;

base_symbol_expr.id(ID_base);
Expand Down
8 changes: 4 additions & 4 deletions src/cpp/cpp_typecheck_compound_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
{
irep_idt base_name=arg.get_base_name();

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

symbolt arg_symb;
Expand Down Expand Up @@ -769,7 +769,7 @@ void cpp_typecheckt::put_compound_into_scope(
const irep_idt &name=compound.get_name();

// nothing to do if no base_name (e.g., an anonymous bitfield)
if(base_name==irep_idt())
if(base_name.empty())
return;

if(compound.type().id()==ID_code)
Expand Down Expand Up @@ -983,7 +983,7 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol)
continue;
}

if(declaration.type().id()==irep_idt()) // empty?
if(declaration.type().id().empty())
continue;

bool is_typedef=declaration.is_typedef();
Expand Down Expand Up @@ -1259,7 +1259,7 @@ void cpp_typecheckt::typecheck_member_function(

if(component.get_bool(ID_is_static))
{
if(method_qualifier.id()!=irep_idt())
if(!method_qualifier.id().empty())
{
error().source_location=component.source_location();
error() << "method is static -- no qualifiers allowed" << eom;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr)
}

for(const operator_entryt *e=operators;
e->id!=irep_idt();
!e->id.empty();
e++)
if(expr.id()==e->id)
{
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Author: Daniel Kroening, [email protected]

void cpp_typecheckt::typecheck_type(typet &type)
{
assert(type.id()!=irep_idt());
assert(!type.id().empty());
assert(type.is_not_nil());

try
Expand Down
6 changes: 3 additions & 3 deletions src/cpp/expr2cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ std::string expr2cppt::convert_rec(
{
return q+convert(src.subtype())+" &&"+d;
}
else if(src.get(ID_C_c_type)!=irep_idt())
else if(!src.get(ID_C_c_type).empty())
{
const irep_idt c_type=src.get(ID_C_c_type);

Expand Down Expand Up @@ -208,7 +208,7 @@ std::string expr2cppt::convert_rec(
else
dest+="struct";

if(symbol.pretty_name!=irep_idt())
if(!symbol.pretty_name.empty())
dest+=" "+id2string(symbol.pretty_name);

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

dest+="enum";

if(symbol.pretty_name!=irep_idt())
if(!symbol.pretty_name.empty())
dest+=" "+id2string(symbol.pretty_name);

dest+=d;
Expand Down
6 changes: 3 additions & 3 deletions src/cpp/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ class Parser // NOLINT(readability/identifiers)
{
typet *p=&dest;

while(p->id()!=irep_idt() && p->is_not_nil())
while(!p->id().empty() && p->is_not_nil())
{
if(p->id()==ID_merged_type)
{
Expand Down Expand Up @@ -2224,7 +2224,7 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p)
default: type_id=irep_idt();
}

if(type_id!=irep_idt())
if(!type_id.empty())
{
cpp_tokent tk;
typet kw;
Expand Down Expand Up @@ -3467,7 +3467,7 @@ bool Parser::rOperatorName(irept &name)
return rCastOperatorName(name);
}

assert(operator_id!=irep_idt());
assert(!operator_id.empty());
lex.get_token(tk);
name=irept(operator_id);
set_location(name, tk);
Expand Down
10 changes: 5 additions & 5 deletions src/goto-programs/goto_inline_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void goto_inlinet::parameter_assignments(

const irep_idt &identifier=parameter.get_identifier();

if(identifier==irep_idt())
if(identifier.empty())
{
error().source_location=source_location;
error() << "no identifier for function parameter" << eom;
Expand Down Expand Up @@ -182,7 +182,7 @@ void goto_inlinet::parameter_destruction(

const irep_idt &identifier=parameter.get_identifier();

if(identifier==irep_idt())
if(identifier.empty())
{
error().source_location=source_location;
error() << "no identifier for function parameter" << eom;
Expand Down Expand Up @@ -328,13 +328,13 @@ void replace_location(

dest=new_location;

if(comment!=irep_idt())
if(!comment.empty())
dest.set_comment(comment);

if(property_class!=irep_idt())
if(!property_class.empty())
dest.set_property_class(property_class);

if(property_id!=irep_idt())
if(!property_id.empty())
dest.set_property_id(property_id);
}

Expand Down
2 changes: 1 addition & 1 deletion src/goto-symex/symex_builtin_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void goto_symext::symex_gcc_builtin_va_arg_next(

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

if(id!=irep_idt())
if(!id.empty())
{
// strip last name off id to get function name
std::size_t pos=id2string(id).rfind("::");
Expand Down
2 changes: 1 addition & 1 deletion src/goto-symex/symex_function_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void goto_symext::parameter_assignments(

const irep_idt &identifier=parameter.get_identifier();

if(identifier==irep_idt())
if(identifier.empty())
throw "no identifier for function parameter";

const symbolt &symbol=ns.lookup(identifier);
Expand Down
2 changes: 1 addition & 1 deletion src/java_bytecode/java_bytecode_convert_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2309,7 +2309,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
if(v.is_parameter)
continue;
// Skip anonymous variables:
if(v.symbol_expr.get_identifier()==irep_idt())
if(v.symbol_expr.get_identifier().empty())
continue;
auto &block=get_block_for_pcrange(
root,
Expand Down
8 changes: 4 additions & 4 deletions src/java_bytecode/java_bytecode_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ static void get_virtual_method_targets(
assert(called_function.id()==ID_virtual_function);

const auto &call_class=called_function.get(ID_C_class);
assert(call_class!=irep_idt());
assert(!call_class.empty());
const auto &call_basename=called_function.get(ID_component_name);
assert(call_basename!=irep_idt());
assert(!call_basename.empty());

auto old_size=needed_methods.size();

Expand All @@ -218,7 +218,7 @@ static void get_virtual_method_targets(
call_basename,
child_class,
symbol_table);
if(child_method!=irep_idt())
if(!child_method.empty())
needed_methods.push_back(child_method);
}

Expand All @@ -231,7 +231,7 @@ static void get_virtual_method_targets(
call_basename,
parent_class_id,
symbol_table);
if(parent_method!=irep_idt())
if(!parent_method.empty())
{
needed_methods.push_back(parent_method);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/java_bytecode/java_bytecode_parse_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void java_bytecode_parse_treet::methodt::output(std::ostream &out) const

for(const auto &i : instructions)
{
if(i.source_location.get_line()!=irep_idt())
if(!i.source_location.get_line().empty())
out << " // " << i.source_location << '\n';

out << " " << i.address << ": ";
Expand Down
2 changes: 1 addition & 1 deletion src/path-symex/build_goto_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void build_goto_trace(
const irep_idt &comment=
instruction.source_location.get_comment();

if(comment!=irep_idt())
if(!comment.empty())
trace_step.comment=id2string(comment);
else
trace_step.comment="assertion";
Expand Down
2 changes: 1 addition & 1 deletion src/path-symex/path_symex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ void path_symext::function_call_rec(
const code_typet::parametert &function_parameter=function_parameters[i];
irep_idt identifier=function_parameter.get_identifier();

if(identifier==irep_idt())
if(identifier.empty())
throw "function_call " + id2string(function_identifier)
+ " no identifier for function parameter";

Expand Down
2 changes: 1 addition & 1 deletion src/path-symex/path_symex_state_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ exprt path_symex_statet::read_symbol_member_index(
else
{
// we do some SSA symbol
if(var_state.ssa_symbol.get_identifier()==irep_idt())
if(var_state.ssa_symbol.get_identifier().empty())
{
// produce one
var_state.ssa_symbol=var_info.ssa_symbol();
Expand Down
2 changes: 1 addition & 1 deletion src/path-symex/var_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var_mapt::var_infot &var_mapt::operator()(
const irep_idt &suffix,
const typet &type)
{
assert(symbol!=irep_idt());
assert(!symbol.empty());

std::string full_identifier=
id2string(symbol)+id2string(suffix);
Expand Down
2 changes: 1 addition & 1 deletion src/pointer-analysis/add_failed_symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ exprt get_failed_symbol(
const symbolt &symbol=ns.lookup(expr);
irep_idt failed_symbol_id=symbol.type.get(ID_C_failed_symbol);

if(failed_symbol_id==irep_idt())
if(failed_symbol_id.empty())
return nil_exprt();

const symbolt &failed_symbol=ns.lookup(failed_symbol_id);
Expand Down
Loading