Skip to content

Use irep id defs for all #comments #2590

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 1 commit into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -836,7 +836,7 @@ void c_typecheck_baset::typecheck_expr_symbol(exprt &expr)
if(expr.type().id()==ID_code) // function designator
{ // special case: this is sugar for &f
address_of_exprt tmp(expr, pointer_type(expr.type()));
tmp.set("#implicit", true);
tmp.set(ID_C_implicit, true);
tmp.add_source_location()=expr.source_location();
expr=tmp;
}
Expand Down
8 changes: 4 additions & 4 deletions src/cpp/cpp_constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ codet cpp_typecheckt::cpp_constructor(
// The purpose of the tag #array_ini is to rule out ill-formed
// programs.

if(!operands.empty() && !operands.front().get_bool("#array_ini"))
if(!operands.empty() && !operands.front().get_bool(ID_C_array_ini))
{
error().source_location=source_location;
error() << "bad array initializer" << eom;
Expand All @@ -65,7 +65,7 @@ codet cpp_typecheckt::cpp_constructor(
const exprt &size_expr=
to_array_type(tmp_type).size();

if(size_expr.id()=="infinity")
if(size_expr.id() == ID_infinity)
{
// don't initialize
codet nil;
Expand All @@ -91,8 +91,8 @@ codet cpp_typecheckt::cpp_constructor(
exprt op_tc=operands.front();
typecheck_expr(op_tc);
// Override constantness
object_tc.type().set("#constant", false);
object_tc.set("#lvalue", true);
object_tc.type().set("ID_C_constant", false);
object_tc.set("ID_C_lvalue", true);
side_effect_exprt assign("assign");
assign.add_source_location()=source_location;
assign.copy_to_operands(object_tc, op_tc);
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/cpp_declarator_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ symbolt &cpp_declarator_convertert::convert(
if(!storage_spec.is_extern())
symbol.is_extern = false;

if(declarator.get_bool("#template_case"))
if(declarator.get_bool(ID_C_template_case))
return symbol;

combine_types(declarator.name().source_location(), final_type, symbol);
Expand Down Expand Up @@ -258,7 +258,7 @@ void cpp_declarator_convertert::combine_types(
if(decl_parameter.type()!=symbol_parameter.type())
{
// The 'this' parameter of virtual functions mismatches
if(i!=0 || !symbol_code_type.get_bool("#is_virtual"))
if(i != 0 || !symbol_code_type.get_bool(ID_C_is_virtual))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the C++ front-end be generating ID_C_* things for C++ features?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That _C_ isn't C the language, it's "Comment". C the language seems to usually use a lowercase 'c' in irep identifiers.

{
cpp_typecheck.error().source_location=source_location;
cpp_typecheck.error() << "symbol `" << symbol.display_name()
Expand Down
12 changes: 6 additions & 6 deletions src/cpp/cpp_typecheck_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
// Let's first typecheck the operands.
Forall_operands(it, code)
{
const bool has_array_ini = it->get_bool("#array_ini");
const bool has_array_ini = it->get_bool(ID_C_array_ini);
typecheck_expr(*it);
if(has_array_ini)
it->set("#array_ini", true);
it->set(ID_C_array_ini, true);
}

// The initializer may be a data member (non-type)
Expand Down Expand Up @@ -228,7 +228,7 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
// done building the expression, check the argument types
typecheck_function_call_arguments(function_call);

if(symbol_expr.get_bool("#not_accessible"))
if(symbol_expr.get_bool(ID_C_not_accessible))
{
irep_idt access = symbol_expr.get(ID_C_access);

Expand Down Expand Up @@ -312,9 +312,9 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
reference_initializer(code.op0(), symbol_expr.type());

// assign the pointers
symbol_expr.type().remove("#reference");
symbol_expr.set("#lvalue", true);
code.op0().type().remove("#reference");
symbol_expr.type().remove(ID_C_reference);
symbol_expr.set(ID_C_lvalue, true);
code.op0().type().remove(ID_C_reference);

side_effect_exprt assign(ID_assign);
assign.add_source_location() = code.source_location();
Expand Down
26 changes: 12 additions & 14 deletions src/cpp/cpp_typecheck_compound_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
if(cpp_name.is_operator())
{
component.set("is_operator", true);
component.type().set("#is_operator", true);
component.type().set(ID_C_is_operator, true);
}

if(is_cast_operator)
Expand All @@ -442,7 +442,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
if(is_static)
{
component.set(ID_is_static, true);
component.type().set("#is_static", true);
component.type().set(ID_C_is_static, true);
}

if(is_typedef)
Expand Down Expand Up @@ -517,7 +517,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
else // virtual
{
component.type().set(ID_C_is_virtual, true);
component.type().set("#virtual_name", virtual_name);
component.type().set(ID_C_virtual_name, virtual_name);

// Check if it is a pure virtual method
if(value.is_not_nil() && value.id() == ID_constant)
Expand Down Expand Up @@ -888,9 +888,9 @@ void cpp_typecheckt::typecheck_friend_declaration(
// typecheck ftype

// TODO
// typecheck_type(ftype);
// assert(ftype.id()==ID_symbol);
// symbol.type.add("#friends").move_to_sub(ftype);
// typecheck_type(ftype);
// assert(ftype.id()==ID_symbol);
// symbol.type.add("ID_C_friends").move_to_sub(ftype);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if updating commented out TODO code is better or worse than not updating it. Hmmm... I think updating is probably the right thing to do.


return;
}
Expand All @@ -914,7 +914,7 @@ void cpp_typecheckt::typecheck_friend_declaration(
declaration.type(), declaration.storage_spec(),
declaration.member_spec(), sub_it);
exprt symb_expr=cpp_symbol_expr(conv_symb);
symbol.type.add("#friends").move_to_sub(symb_expr);
symbol.type.add(ID_C_friends).move_to_sub(symb_expr);
}
else
{
Expand All @@ -929,7 +929,7 @@ void cpp_typecheckt::typecheck_friend_declaration(

exprt symb_expr=cpp_symbol_expr(conv_symb);

symbol.type.add("#friends").move_to_sub(symb_expr);
symbol.type.add(ID_C_friends).move_to_sub(symb_expr);
}
}
}
Expand Down Expand Up @@ -1462,7 +1462,7 @@ void cpp_typecheckt::convert_anon_struct_union_member(

put_compound_into_scope(component);

struct_union_symbol.type.set("#unnamed_object", base_name);
struct_union_symbol.type.set(ID_C_unnamed_object, base_name);
}

bool cpp_typecheckt::get_component(
Expand Down Expand Up @@ -1496,7 +1496,7 @@ bool cpp_typecheckt::get_component(
{
if(disable_access_control)
{
member.set("#not_accessible", true);
member.set(ID_C_not_accessible, true);
member.set(ID_C_access, component.get(ID_access));
}
else
Expand All @@ -1520,8 +1520,7 @@ bool cpp_typecheckt::get_component(

return true; // component found
}
else if(
follow(component.type()).find("#unnamed_object").is_not_nil())
else if(follow(component.type()).find(ID_C_unnamed_object).is_not_nil())
{
// could be anonymous union or struct

Expand Down Expand Up @@ -1597,8 +1596,7 @@ bool cpp_typecheckt::check_component_access(
}

// check friendship
const irept::subt &friends=
struct_union_type.find("#friends").get_sub();
const irept::subt &friends = struct_union_type.find(ID_C_friends).get_sub();

forall_irep(f_it, friends)
{
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/cpp_typecheck_constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ void cpp_typecheckt::default_cpctor(
memberexpr.add_source_location()=source_location;

if(mem_it->type().id()==ID_array)
memberexpr.set("#array_ini", true);
memberexpr.set(ID_C_array_ini, true);

mem_init.move_to_operands(memberexpr);
initializers.move_to_sub(mem_init);
Expand Down Expand Up @@ -386,7 +386,7 @@ void cpp_typecheckt::default_assignop(

declarator_type.id(ID_function_type);
declarator_type.subtype()=reference_type(nil_typet());
declarator_type.subtype().add("#qualifier").make_nil();
declarator_type.subtype().add(ID_C_qualifier).make_nil();

exprt &args=static_cast<exprt&>(declarator.type().add(ID_parameters));
args.add_source_location()=source_location;
Expand Down
6 changes: 3 additions & 3 deletions src/cpp/cpp_typecheck_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,9 +1258,9 @@ bool cpp_typecheckt::reference_binding(
expr.set(ID_C_lvalue, true);
else if(expr.get(ID_statement)==ID_function_call)
expr.set(ID_C_lvalue, true);
else if(expr.get_bool("#temporary_avoided"))
else if(expr.get_bool(ID_C_temporary_avoided))
{
expr.remove("#temporary_avoided");
expr.remove(ID_C_temporary_avoided);
exprt temporary;
new_temporary(expr.source_location(), expr.type(), expr, temporary);
expr.swap(temporary);
Expand Down Expand Up @@ -1965,7 +1965,7 @@ bool cpp_typecheckt::static_typecast(
else
{
// try to avoid temporary
new_expr.set("#temporary_avoided", true);
new_expr.set(ID_C_temporary_avoided, true);
if(new_expr.get_bool(ID_C_lvalue))
new_expr.remove(ID_C_lvalue);
}
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/cpp_typecheck_declaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ void cpp_typecheckt::convert_anonymous_union(
id.is_member=true;
}

symbol_table.get_writeable_ref(union_symbol.name).type.set(
"#unnamed_object", symbol.base_name);
symbol_table.get_writeable_ref(union_symbol.name)
.type.set(ID_C_unnamed_object, symbol.base_name);

code.swap(new_code);
}
Expand Down
32 changes: 15 additions & 17 deletions src/cpp/cpp_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2017,8 +2017,8 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
{
if(expr.function().type().find("to-member").is_not_nil())
{
const exprt &bound=
static_cast<const exprt &>(expr.function().type().find("#bound"));
const exprt &bound =
static_cast<const exprt &>(expr.function().type().find(ID_C_bound));

if(bound.is_nil())
{
Expand All @@ -2032,7 +2032,7 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
expr.arguments().insert(expr.arguments().begin(), bound);

// we don't need the object any more
expr.function().type().remove("#bound");
expr.function().type().remove(ID_C_bound);
}

// do implicit dereference
Expand Down Expand Up @@ -2060,8 +2060,7 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
}
else if(expr.function().type().id()==ID_code)
{
if(expr.function().type().get_bool("#is_virtual") &&
!is_qualified)
if(expr.function().type().get_bool(ID_C_is_virtual) && !is_qualified)
{
exprt vtptr_member;
if(op0.id()==ID_member || op0.id()==ID_ptrmember)
Expand Down Expand Up @@ -2093,9 +2092,9 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
vtptr_member.set(ID_component_name, vtable_name);

// look for the right entry
irep_idt vtentry_component_name=
vt_compo.type().subtype().get_string(ID_identifier)+"::"+
expr.function().type().get_string("#virtual_name");
irep_idt vtentry_component_name =
vt_compo.type().subtype().get_string(ID_identifier) +
"::" + expr.function().type().get_string(ID_C_virtual_name);

exprt vtentry_member(ID_ptrmember);
vtentry_member.copy_to_operands(vtptr_member);
Expand Down Expand Up @@ -2190,10 +2189,10 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
member);

// special case for the initialization of parents
if(member.get_bool("#not_accessible"))
if(member.get_bool(ID_C_not_accessible))
{
assert(member.get(ID_C_access)!="");
tmp_object_expr.set("#not_accessible", true);
tmp_object_expr.set(ID_C_not_accessible, true);
tmp_object_expr.set(ID_C_access, member.get(ID_C_access));
}

Expand Down Expand Up @@ -2307,7 +2306,7 @@ void cpp_typecheckt::typecheck_function_call_arguments(
exprt::operandst::iterator arg_it=expr.arguments().begin();
for(const auto &parameter : parameters)
{
if(parameter.get_bool("#call_by_value"))
if(parameter.get_bool(ID_C_call_by_value))
{
assert(is_reference(parameter.type()));

Expand Down Expand Up @@ -2383,7 +2382,7 @@ void cpp_typecheckt::typecheck_method_application(

const symbolt &symbol=lookup(member_expr.get(ID_component_name));
symbolt &method_symbol=symbol_table.get_writeable_ref(symbol.name);
const symbolt &tag_symbol=lookup(symbol.type.get("#member_name"));
const symbolt &tag_symbol = lookup(symbol.type.get(ID_C_member_name));

// build the right template map
// if this is an instantiated template class method
Expand All @@ -2409,15 +2408,15 @@ void cpp_typecheckt::typecheck_method_application(
new_function.add_source_location()=member_expr.source_location();
expr.function().swap(new_function);

if(!expr.function().type().get_bool("#is_static"))
if(!expr.function().type().get_bool(ID_C_is_static))
{
const code_typet &func_type=to_code_type(symbol.type);
typet this_type=func_type.parameters().front().type();

// Special case. Make it a reference.
assert(this_type.id()==ID_pointer);
this_type.set(ID_C_reference, true);
this_type.set("#this", true);
this_type.set(ID_C_this, true);

if(expr.arguments().size()==func_type.parameters().size())
{
Expand Down Expand Up @@ -2690,7 +2689,7 @@ void cpp_typecheckt::convert_pmop(exprt &expr)
}

exprt tmp(expr.op1());
tmp.type().set("#bound", expr.op0());
tmp.type().set(ID_C_bound, expr.op0());
expr.swap(tmp);
return;
}
Expand All @@ -2714,8 +2713,7 @@ void cpp_typecheckt::typecheck_expr_function_identifier(exprt &expr)

void cpp_typecheckt::typecheck_expr(exprt &expr)
{
bool override_constantness=
expr.get_bool("#override_constantness");
bool override_constantness = expr.get_bool(ID_C_override_constantness);

// We take care of an ambiguity in the C++ grammar.
// Needs to be done before the operands!
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck_fargs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ bool cpp_typecheck_fargst::match(
if(it==ops.begin() && parameter.get(ID_C_base_name)==ID_this)
{
type.set(ID_C_reference, true);
type.set("#this", true);
type.set(ID_C_this, true);
}

unsigned rank=0;
Expand Down
7 changes: 4 additions & 3 deletions src/cpp/cpp_typecheck_resolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ exprt cpp_typecheck_resolvet::resolve(
}

// we do some checks before we return
if(result.get_bool("#not_accessible"))
if(result.get_bool(ID_C_not_accessible))
{
#if 0
if(!fail_with_exception)
Expand Down Expand Up @@ -2223,8 +2223,9 @@ bool cpp_typecheck_resolvet::disambiguate_functions(
}
else
{
if(expr.type().get_bool("#is_operator") &&
fargs.operands.size() == parameters.size())
if(
expr.type().get_bool(ID_C_is_operator) &&
fargs.operands.size() == parameters.size())
{
return fargs.match(type, args_distance, cpp_typecheck);
}
Expand Down
2 changes: 1 addition & 1 deletion src/goto-programs/builtin_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ void goto_convertt::do_function_call_symbol(
const exprt::operandst &arguments,
goto_programt &dest)
{
if(function.get_bool("#invalid_object"))
if(function.get_bool(ID_C_invalid_object))
return; // ignore

// lookup symbol
Expand Down
2 changes: 1 addition & 1 deletion src/goto-symex/build_goto_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void set_internal_dynamic_object(
const symbolt *symbol;
if(!ns.lookup(id, symbol))
{
bool result=symbol->type.get_bool("#dynamic");
bool result = symbol->type.get_bool(ID_C_dynamic);
if(result)
goto_trace_step.internal=true;
}
Expand Down
Loading