Skip to content

Commit a43b83e

Browse files
committed
Make componentt::{base,pretty}_name comments
The only semantically relevant name information is the ID_name entry. Two components should not be considered different when they only differ in their base_name or pretty_name. Thus, use ID_C_base_name and ID_C_pretty_name, respectively, to store these. The goto binary version is incremented as goto binaries compiled before this patch are incompatible with the changes introduced here. Fixes: #5818
1 parent b1d99cb commit a43b83e

File tree

10 files changed

+20
-14
lines changed

10 files changed

+20
-14
lines changed
-357 Bytes
Binary file not shown.
-348 Bytes
Binary file not shown.
-357 Bytes
Binary file not shown.
-350 Bytes
Binary file not shown.

src/ansi-c/expr2c.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -1565,13 +1565,13 @@ std::string expr2ct::convert_member(
15651565

15661566
if(!component_name.empty())
15671567
{
1568-
const exprt &comp_expr = struct_union_type.get_component(component_name);
1568+
const auto &comp_expr = struct_union_type.get_component(component_name);
15691569

15701570
if(comp_expr.is_nil())
15711571
return convert_norep(src, precedence);
15721572

1573-
if(!comp_expr.get(ID_pretty_name).empty())
1574-
dest+=comp_expr.get_string(ID_pretty_name);
1573+
if(!comp_expr.get_pretty_name().empty())
1574+
dest += id2string(comp_expr.get_pretty_name());
15751575
else
15761576
dest+=id2string(component_name);
15771577

@@ -1583,9 +1583,12 @@ std::string expr2ct::convert_member(
15831583
if(n>=struct_union_type.components().size())
15841584
return convert_norep(src, precedence);
15851585

1586-
const exprt &comp_expr = struct_union_type.components()[n];
1586+
const auto &comp_expr = struct_union_type.components()[n];
15871587

1588-
dest+=comp_expr.get_string(ID_pretty_name);
1588+
if(!comp_expr.get_pretty_name().empty())
1589+
dest += id2string(comp_expr.get_pretty_name());
1590+
else
1591+
dest += id2string(comp_expr.get_name());
15891592

15901593
return dest;
15911594
}

src/cpp/expr2cpp.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ std::string expr2cppt::convert_struct(
9595

9696
dest+=sep;
9797
dest+='.';
98-
dest += c.get_string(ID_pretty_name);
98+
if(!c.get_pretty_name().empty())
99+
dest += id2string(c.get_pretty_name());
100+
else
101+
dest += id2string(c.get_name());
99102
dest+='=';
100103
dest+=tmp;
101104
}

src/goto-instrument/alignment_checks.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ void print_struct_alignment_problems(
8181
<< symbol_pair.second.location << '\n';
8282
}
8383

84-
out << "members " << it_mem->get_pretty_name() << " and "
85-
<< it_next->get_pretty_name() << " might interfere\n";
84+
out << "members " << it_mem->get_name() << " and "
85+
<< it_next->get_name() << " might interfere\n";
8686
}
8787
}
8888
}

src/goto-programs/write_goto_binary.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Author: CM Wintersteiger
1212
#ifndef CPROVER_GOTO_PROGRAMS_WRITE_GOTO_BINARY_H
1313
#define CPROVER_GOTO_PROGRAMS_WRITE_GOTO_BINARY_H
1414

15-
#define GOTO_BINARY_VERSION 5
15+
#define GOTO_BINARY_VERSION 6
1616

1717
#include <iosfwd>
1818
#include <string>

src/util/irep_ids.def

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ IREP_ID_TWO(mult, *)
353353
IREP_ID_TWO(div, /)
354354
IREP_ID_TWO(power, **)
355355
IREP_ID_ONE(factorial_power)
356-
IREP_ID_ONE(pretty_name)
356+
IREP_ID_TWO(C_pretty_name, #pretty_name)
357357
IREP_ID_TWO(C_class, #class)
358358
IREP_ID_TWO(C_field, #field)
359359
IREP_ID_TWO(C_interface, #interface)

src/util/std_types.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ class struct_union_typet:public typet
8888

8989
const irep_idt &get_base_name() const
9090
{
91-
return get(ID_base_name);
91+
return get(ID_C_base_name);
9292
}
9393

9494
void set_base_name(const irep_idt &base_name)
9595
{
96-
return set(ID_base_name, base_name);
96+
return set(ID_C_base_name, base_name);
9797
}
9898

9999
const irep_idt &get_access() const
@@ -108,12 +108,12 @@ class struct_union_typet:public typet
108108

109109
const irep_idt &get_pretty_name() const
110110
{
111-
return get(ID_pretty_name);
111+
return get(ID_C_pretty_name);
112112
}
113113

114114
void set_pretty_name(const irep_idt &name)
115115
{
116-
return set(ID_pretty_name, name);
116+
return set(ID_C_pretty_name, name);
117117
}
118118

119119
bool get_anonymous() const

0 commit comments

Comments
 (0)