Skip to content

Commit 33206c1

Browse files
committed
Expand typedef names in GraphML output
typedefs are not meaningful when taken out of context.
1 parent 59e340b commit 33206c1

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

regression/cbmc/graphml_witness2/main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
#include <stdlib.h>
2+
13
extern void __VERIFIER_error();
24

3-
static float one(float *foo)
5+
static size_t one(size_t *foo)
46
{
57
return *foo;
68
}
79

8-
static float two(float *foo)
10+
static size_t two(size_t *foo)
911
{
1012
return *foo;
1113
}
1214

13-
float x = 0;
15+
size_t x = 0;
1416

1517
void step()
1618
{
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
CORE
22
main.c
3-
--graphml-witness - --unwindset main.0:1 --unwinding-assertions
3+
--graphml-witness - --unwindset main.0:1 --unwinding-assertions --stack-trace
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7-
<data key="assumption">foo = \(\(float \*\)0\);</data>
7+
<data key="assumption">foo = \(\(unsigned long( long)? int \*\)0\);</data>
88
<data key="assumption.scope">one</data>
99
--
1010
^warning: ignoring
11+
__CPROVER_size_t
12+
--
13+
In the GraphML witness, typedef names should be expanded.

regression/memory-analyzer/cycles/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
cycles.gb
33
--breakpoint process_buffer --symbols buffer
4-
cycle_buffer_entry_t tmp;
4+
struct cycle_buffer_entry tmp;
55
char tmp\$0\[\];
66
struct cycle_buffer_entry tmp\$1;
77
char tmp\$2\[\];

src/ansi-c/expr2c.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ expr2c_configurationt expr2c_configurationt::default_configuration
4444
"TRUE",
4545
"FALSE",
4646
true,
47+
false,
4748
false
4849
};
4950

@@ -55,6 +56,7 @@ expr2c_configurationt expr2c_configurationt::clean_configuration
5556
"1",
5657
"0",
5758
false,
59+
true,
5860
true
5961
};
6062

@@ -198,7 +200,7 @@ std::string expr2ct::convert_rec(
198200

199201
std::string d = declarator.empty() ? declarator : " " + declarator;
200202

201-
if(src.find(ID_C_typedef).is_not_nil())
203+
if(!configuration.expand_typedef && src.find(ID_C_typedef).is_not_nil())
202204
{
203205
return q+id2string(src.get(ID_C_typedef))+d;
204206
}

src/ansi-c/expr2c.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,27 @@ struct expr2c_configurationt final
4242
/// When printing an enum-typed constant, print the integer representation
4343
bool print_enum_int_value;
4444

45+
/// Print the expanded type instead of a typedef name, even when a typedef is
46+
/// present
47+
bool expand_typedef;
48+
4549
expr2c_configurationt(
4650
const bool include_struct_padding_components,
4751
const bool print_struct_body_in_type,
4852
const bool include_array_size,
4953
const std::string &true_string,
5054
const std::string &false_string,
5155
const bool use_library_macros,
52-
const bool print_enum_int_value)
56+
const bool print_enum_int_value,
57+
const bool expand_typedef)
5358
: include_struct_padding_components(include_struct_padding_components),
5459
print_struct_body_in_type(print_struct_body_in_type),
5560
include_array_size(include_array_size),
5661
true_string(true_string),
5762
false_string(false_string),
5863
use_library_macros(use_library_macros),
59-
print_enum_int_value(print_enum_int_value)
64+
print_enum_int_value(print_enum_int_value),
65+
expand_typedef(expand_typedef)
6066
{
6167
}
6268

0 commit comments

Comments
 (0)