Skip to content

Commit 30739e6

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 3cb60fc commit 30739e6

File tree

12 files changed

+22
-16
lines changed

12 files changed

+22
-16
lines changed
709 Bytes
Binary file not shown.

regression/ansi-c/arch_flags_mcpu_bad/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This tests the -mcpu=cortex=a15 flag that should activate ARM-32 mode.
1111
The object file 'object.intel' was compiled from 'source.c' with goto-cc
1212
on a 64-bit platform:
1313

14-
goto-cc -c source.c
14+
goto-cc -c source.c -o object.intel
1515

1616
preproc.i is already pre-processed so that it can be linked in without
1717
needing to invoke a pre-processor from a cross-compile toolchain on your
703 Bytes
Binary file not shown.
Binary file not shown.

regression/ansi-c/arch_flags_mthumb_bad/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This tests the -mthumb flag that should activate ARM-32 mode. The object
1111
file 'object.intel' was compiled from 'source.c' with goto-cc on a
1212
64-bit platform:
1313

14-
goto-cc -c source.c
14+
goto-cc -c source.c -o object.intel
1515

1616
preproc.i is already pre-processed so that it can be linked in without
1717
needing to invoke a pre-processor from a cross-compile toolchain on your
702 Bytes
Binary file not shown.

src/ansi-c/expr2c.cpp

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

15331533
if(!component_name.empty())
15341534
{
1535-
const exprt &comp_expr = struct_union_type.get_component(component_name);
1535+
const auto &comp_expr = struct_union_type.get_component(component_name);
15361536

15371537
if(comp_expr.is_nil())
15381538
return convert_norep(src, precedence);
15391539

1540-
if(!comp_expr.get(ID_pretty_name).empty())
1541-
dest+=comp_expr.get_string(ID_pretty_name);
1540+
if(!comp_expr.get_pretty_name().empty())
1541+
dest += id2string(comp_expr.get_pretty_name());
15421542
else
15431543
dest+=id2string(component_name);
15441544

@@ -1550,9 +1550,12 @@ std::string expr2ct::convert_member(
15501550
if(n>=struct_union_type.components().size())
15511551
return convert_norep(src, precedence);
15521552

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

1555-
dest+=comp_expr.get_string(ID_pretty_name);
1555+
if(!comp_expr.get_pretty_name().empty())
1556+
dest += id2string(comp_expr.get_pretty_name());
1557+
else
1558+
dest += id2string(comp_expr.get_name());
15561559

15571560
return dest;
15581561
}

src/cpp/expr2cpp.cpp

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

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

src/goto-instrument/alignment_checks.cpp

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

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

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
@@ -347,7 +347,7 @@ IREP_ID_TWO(mult, *)
347347
IREP_ID_TWO(div, /)
348348
IREP_ID_TWO(power, **)
349349
IREP_ID_ONE(factorial_power)
350-
IREP_ID_ONE(pretty_name)
350+
IREP_ID_TWO(C_pretty_name, #pretty_name)
351351
IREP_ID_TWO(C_class, #class)
352352
IREP_ID_TWO(C_field, #field)
353353
IREP_ID_TWO(C_interface, #interface)

src/util/std_types.h

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

8484
const irep_idt &get_base_name() const
8585
{
86-
return get(ID_base_name);
86+
return get(ID_C_base_name);
8787
}
8888

8989
void set_base_name(const irep_idt &base_name)
9090
{
91-
return set(ID_base_name, base_name);
91+
return set(ID_C_base_name, base_name);
9292
}
9393

9494
const irep_idt &get_access() const
@@ -103,12 +103,12 @@ class struct_union_typet:public typet
103103

104104
const irep_idt &get_pretty_name() const
105105
{
106-
return get(ID_pretty_name);
106+
return get(ID_C_pretty_name);
107107
}
108108

109109
void set_pretty_name(const irep_idt &name)
110110
{
111-
return set(ID_pretty_name, name);
111+
return set(ID_C_pretty_name, name);
112112
}
113113

114114
bool get_anonymous() const

0 commit comments

Comments
 (0)