Skip to content

Commit 2ee2a57

Browse files
tautschnigDaniel Kroening
authored and
Daniel Kroening
committed
Enable internal validation for C++ regression tests
We should perform as much sanity checking in regression tests as possible. This required cleaning up unused parameter identifiers and disabling sanity checking of names as is already done for Java, because we similarly have name mangling in C++.
1 parent 8101a98 commit 2ee2a57

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

regression/cbmc-cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ add_test_pl_tests(
44
)
55
else()
66
add_test_pl_tests(
7-
"$<TARGET_FILE:cbmc>"
7+
"$<TARGET_FILE:cbmc> --validate-goto-model --validate-ssa-equation"
88
)
99
endif()

regression/cbmc-cpp/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ else
1010
endif
1111

1212
test:
13-
@../test.pl -e -p -c ../../../src/cbmc/cbmc $(gcc_only)
13+
@../test.pl -e -p -c "../../../src/cbmc/cbmc --validate-goto-model --validate-ssa-equation" $(gcc_only)
1414

1515
tests.log: ../test.pl
16-
@../test.pl -e -p -c ../../../src/cbmc/cbmc $(gcc_only)
16+
@../test.pl -e -p -c "../../../src/cbmc/cbmc --validate-goto-model --validate-ssa-equation" $(gcc_only)
1717

1818
show:
1919
@for dir in *; do \

regression/systemc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
add_test_pl_tests(
2-
"$<TARGET_FILE:cbmc>"
2+
"$<TARGET_FILE:cbmc> --validate-goto-model --validate-ssa-equation"
33
)

regression/systemc/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
default: tests.log
22

33
test:
4-
@../test.pl -e -p -c ../../../src/cbmc/cbmc
4+
@../test.pl -e -p -c "../../../src/cbmc/cbmc --validate-goto-model --validate-ssa-equation"
55

66
tests.log: ../test.pl
7-
@../test.pl -e -p -c ../../../src/cbmc/cbmc
7+
@../test.pl -e -p -c "../../../src/cbmc/cbmc --validate-goto-model --validate-ssa-equation"
88

99
show:
1010
@for dir in *; do \

src/cpp/cpp_declarator_converter.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ void cpp_declarator_convertert::combine_types(
302302
if(symbol.value.is_nil())
303303
{
304304
symbol_parameter.set_base_name(decl_parameter.get_base_name());
305-
symbol_parameter.set_identifier(decl_parameter.get_identifier());
305+
// set an empty identifier when no body is available
306+
symbol_parameter.set_identifier(irep_idt());
306307
symbol_parameter.add_source_location()=
307308
decl_parameter.source_location();
308309
}
@@ -470,6 +471,13 @@ symbolt &cpp_declarator_convertert::convert_new_symbol(
470471

471472
if(member_spec.is_inline())
472473
to_code_type(symbol.type).set_inlined(true);
474+
475+
if(symbol.value.is_nil())
476+
{
477+
// we don't need the identifiers
478+
for(auto &parameter : to_code_type(symbol.type).parameters())
479+
parameter.set_identifier(irep_idt());
480+
}
473481
}
474482
else
475483
{

src/util/symbol.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ bool symbolt::is_well_formed() const
142142
// Exception: Java symbols' base names do not have type signatures
143143
// (for example, they can have name "someclass.method:(II)V" and base name
144144
// "method")
145-
if(!has_suffix(id2string(name), id2string(base_name)) && mode != ID_java)
145+
if(
146+
!has_suffix(id2string(name), id2string(base_name)) && mode != ID_java &&
147+
mode != ID_cpp)
146148
{
147149
bool criterion_must_hold = true;
148150

0 commit comments

Comments
 (0)