Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
No redundant local namespace, comparison over irep_idts
  • Loading branch information
tautschnig committed Jun 11, 2018
1 parent 774060b commit ec5425e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
9 changes: 3 additions & 6 deletions src/cpp/cpp_typecheck_compound_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
throw 0;
}

if(is_constructor &&
base_name!=id2string(symbol.base_name))
if(is_constructor && base_name != symbol.base_name)
{
error().source_location=cpp_name.source_location();
error() << "member function must return a value or void" << eom;
Expand Down Expand Up @@ -425,7 +424,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
}

if(is_typedef)
component.set("is_type", true);
component.set(ID_is_type, true);

if(is_mutable)
component.set("is_mutable", true);
Expand Down Expand Up @@ -615,11 +614,9 @@ void cpp_typecheckt::typecheck_compound_declarator(

// do the body of the function
typecast_exprt late_cast(
lookup(args[0].get(ID_C_identifier)).symbol_expr(),
to_code_type(component.type()).parameters()[0].type());

late_cast.op0()=
namespacet(symbol_table).lookup(
args[0].get(ID_C_identifier)).symbol_expr();

if(code_type.return_type().id()!=ID_empty &&
code_type.return_type().id()!=ID_destructor)
Expand Down
8 changes: 3 additions & 5 deletions src/cpp/cpp_typecheck_constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,10 @@ void cpp_typecheckt::default_cpctor(
cppname.move_to_sub(name);

const symbolt &virtual_table_symbol_type =
namespacet(symbol_table).lookup(
mem_it->type().subtype().get(ID_identifier));
lookup(mem_it->type().subtype().get(ID_identifier));

const symbolt &virtual_table_symbol_var =
namespacet(symbol_table).lookup(
id2string(virtual_table_symbol_type.name) + "@" +
const symbolt &virtual_table_symbol_var = lookup(
id2string(virtual_table_symbol_type.name) + "@" +
id2string(symbol.name));

exprt var=virtual_table_symbol_var.symbol_expr();
Expand Down
9 changes: 4 additions & 5 deletions src/cpp/cpp_typecheck_destructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ codet cpp_typecheckt::dtor(const symbolt &symbol)
cppname.move_to_sub(name);

const symbolt &virtual_table_symbol_type =
namespacet(symbol_table).lookup(
cit->type().subtype().get(ID_identifier));
lookup(cit->type().subtype().get(ID_identifier));

const symbolt &virtual_table_symbol_var =
namespacet(symbol_table).lookup(
id2string(virtual_table_symbol_type.name)+"@"+id2string(symbol.name));
const symbolt &virtual_table_symbol_var = lookup(
id2string(virtual_table_symbol_type.name) + "@" +
id2string(symbol.name));

exprt var=virtual_table_symbol_var.symbol_expr();
address_of_exprt address(var);
Expand Down
7 changes: 3 additions & 4 deletions src/cpp/cpp_typecheck_virtual_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ void cpp_typecheckt::do_virtual_table(const symbolt &symbol)
{
const std::map<irep_idt, exprt> &value_map=cit->second;

const symbolt &late_cast_symb=namespacet(symbol_table).lookup(cit->first);
const symbolt &vt_symb_type=
namespacet(symbol_table).lookup(
"virtual_table::"+id2string(late_cast_symb.name));
const symbolt &late_cast_symb = lookup(cit->first);
const symbolt &vt_symb_type =
lookup("virtual_table::" + id2string(late_cast_symb.name));

symbolt vt_symb_var;
vt_symb_var.name=
Expand Down

0 comments on commit ec5425e

Please sign in to comment.