Skip to content

Commit 47bac0d

Browse files
Change return value of get_children_trans to set
The disjuncts created by instanceof removal depended on the class loading order, causing goto-diff to think that there was a change in the classes.
1 parent 10ca1cd commit 47bac0d

File tree

6 files changed

+13
-20
lines changed

6 files changed

+13
-20
lines changed

src/analyses/uncaught_exceptions_analysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void uncaught_exceptions_domaint::transform(
7777
join(type_id);
7878
// we must consider all the subtypes given that
7979
// the runtime type is a subtype of the static type
80-
std::vector<irep_idt> subtypes=
80+
class_hierarchyt::idst subtypes =
8181
class_hierarchy.get_children_trans(type_id);
8282
join(subtypes);
8383
}
@@ -98,7 +98,7 @@ void uncaught_exceptions_domaint::transform(
9898
for(const auto &exc : exception_list)
9999
{
100100
last_caught.insert(exc.id());
101-
std::vector<irep_idt> subtypes=
101+
class_hierarchyt::idst subtypes =
102102
class_hierarchy.get_children_trans(exc.id());
103103
last_caught.insert(subtypes.begin(), subtypes.end());
104104
}

src/goto-programs/class_hierarchy.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void class_hierarchyt::operator()(const symbol_tablet &symbol_table)
3939
if(parent.empty())
4040
continue;
4141

42-
class_map[parent].children.push_back(symbol_pair.first);
43-
class_map[symbol_pair.first].parents.push_back(parent);
42+
class_map[parent].children.insert(symbol_pair.first);
43+
class_map[symbol_pair.first].parents.insert(parent);
4444
}
4545
}
4646
}
@@ -94,7 +94,7 @@ void class_hierarchyt::get_children_trans_rec(
9494
const entryt &entry=it->second;
9595

9696
for(const auto &child : entry.children)
97-
dest.push_back(child);
97+
dest.insert(child);
9898

9999
// recursive calls
100100
for(const auto &child : entry.children)
@@ -116,7 +116,7 @@ void class_hierarchyt::get_parents_trans_rec(
116116
const entryt &entry=it->second;
117117

118118
for(const auto &child : entry.parents)
119-
dest.push_back(child);
119+
dest.insert(child);
120120

121121
// recursive calls
122122
for(const auto &child : entry.parents)

src/goto-programs/class_hierarchy.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Date: April 2016
1616

1717
#include <iosfwd>
1818
#include <map>
19+
#include <set>
1920
#include <unordered_map>
2021

2122
#include <util/graph.h>
@@ -24,7 +25,7 @@ Date: April 2016
2425
class class_hierarchyt
2526
{
2627
public:
27-
typedef std::vector<irep_idt> idst;
28+
typedef std::set<irep_idt> idst;
2829

2930
class entryt
3031
{

src/goto-programs/remove_instanceof.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ std::size_t remove_instanceoft::lower_instanceof(
8484
"instanceof second operand should have a simple type");
8585
const irep_idt &target_name=
8686
to_symbol_type(target_type).get_identifier();
87-
std::vector<irep_idt> children=
87+
class_hierarchyt::idst children =
8888
class_hierarchy.get_children_trans(target_name);
89-
children.push_back(target_name);
89+
children.insert(target_name);
9090

9191
// Insert an instruction before the new check that assigns the clsid we're
9292
// checking for to a temporary, as GOTO program if-expressions should

src/goto-programs/resolve_inherited_component.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ resolve_inherited_componentt::inherited_componentt
7878
else
7979
{
8080
if(!parents.empty())
81-
classes_to_visit.push_back(parents.front());
81+
classes_to_visit.push_back(*parents.begin());
8282
}
8383
}
8484

unit/java_bytecode/java_bytecode_convert_method/convert_invoke_dynamic.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,12 @@ void validate_lambda_assignment(
9292
class_hierarchy(symbol_table);
9393

9494
const auto &parents = class_hierarchy.get_parents_trans(tmp_class_identifier);
95-
REQUIRE_THAT(
96-
parents,
97-
// NOLINTNEXTLINE(whitespace/braces)
98-
Catch::Matchers::Vector::ContainsElementMatcher<irep_idt>{
99-
test_data.lambda_interface});
95+
REQUIRE(parents.count(test_data.lambda_interface) > 0);
10096

10197
const auto &interface_children =
10298
class_hierarchy.get_children_trans(test_data.lambda_interface);
10399

104-
REQUIRE_THAT(
105-
interface_children,
106-
// NOLINTNEXTLINE(whitespace/braces)
107-
Catch::Matchers::Vector::ContainsElementMatcher<irep_idt>{
108-
tmp_class_identifier});
100+
REQUIRE(interface_children.count(tmp_class_identifier) > 0);
109101

110102
const java_class_typet::componentt super_class_component =
111103
require_type::require_component(tmp_lambda_class_type, "@java.lang.Object");

0 commit comments

Comments
 (0)