@@ -225,7 +225,7 @@ typedef unordered_map<string, method_decl_sptr> string_member_function_sptr_map;
/// Convenience typedef for a map which key is a string and which
/// value is a point to @ref var_decl.
-typedef unordered_map<string, const var_decl*> string_var_ptr_map;
+typedef unordered_map<string, var_decl_sptr> string_var_ptr_map;
/// Convenience typedef for a pair of pointer to @ref var_decl
/// representing a @ref var_decl change. The first member of the pair
@@ -34,10 +34,10 @@ public:
typedef std::unordered_set<const function_decl*> functions_set;
///Convenience typedef for std::vector<abigail::ir::var_decl*>
- typedef vector<const var_decl*> variables;
+ typedef vector<var_decl_sptr> variables;
/// Convenience typedef for std::unordered_set<const var_decl*>.
- typedef std::unordered_set<const var_decl*> variables_set;
+ typedef std::unordered_set<var_decl_sptr> variables_set;
class exported_decls_builder;
@@ -230,7 +230,7 @@ public:
const std::unordered_set<function_decl*>*
lookup_functions(const char* id) const;
- const var_decl*
+ const var_decl_sptr
lookup_variable(const interned_string& id) const;
void
@@ -370,7 +370,7 @@ public:
maybe_add_fn_to_exported_fns(function_decl*);
bool
- maybe_add_var_to_exported_vars(const var_decl*);
+ maybe_add_var_to_exported_vars(const var_decl_sptr&);
}; //corpus::exported_decls_builder
/// Abstraction of a group of corpora.
@@ -145,7 +145,7 @@ protected:
add_fn_to_exported_or_undefined_decls(const function_decl* fn);
void
- add_var_to_exported_or_undefined_decls(const var_decl* var);
+ add_var_to_exported_or_undefined_decls(const var_decl_sptr& var);
virtual ir::corpus_sptr
read_corpus(status& status) = 0;
@@ -579,7 +579,7 @@ typedef unordered_map<interned_string,
hash_interned_string> istring_function_decl_ptr_map_type;
typedef unordered_map<interned_string,
- const var_decl*,
+ var_decl_sptr,
hash_interned_string> istring_var_decl_ptr_map_type;
/// This is a type that aggregates maps of all the kinds of types that
@@ -661,7 +661,7 @@ public:
if (function_decl_sptr fn = is_function_decl(result))
add_fn_to_exported_or_undefined_decls(fn.get());
else if (var_decl_sptr var = is_var_decl(result))
- add_var_to_exported_or_undefined_decls(var.get());
+ add_var_to_exported_or_undefined_decls(var);
return result;
}
@@ -1013,6 +1013,10 @@ struct var_comp
bool
operator() (const var_decl* l, const var_decl* r) const
{return operator()(*l, *r);}
+
+ bool
+ operator() (const var_decl_sptr& l, const var_decl_sptr& r) const
+ {return operator()(l.get(), r.get());}
};// end struct var_comp
/// A functor to compare instances of @ref elf_symbol base on their
@@ -1147,10 +1151,10 @@ struct corpus_diff::priv
added_function_is_suppressed(const function_decl* fn) const;
bool
- deleted_variable_is_suppressed(const var_decl* var) const;
+ deleted_variable_is_suppressed(const var_decl_sptr& var) const;
bool
- added_variable_is_suppressed(const var_decl* var) const;
+ added_variable_is_suppressed(const var_decl_sptr& var) const;
bool
added_unreachable_type_is_suppressed(const type_base *t)const ;
@@ -1434,7 +1438,7 @@ sort_string_elf_symbol_map(const string_elf_symbol_map& map,
void
sort_string_var_ptr_map(const string_var_ptr_map& map,
- vector<const var_decl*>& sorted);
+ vector<var_decl_sptr>& sorted);
void
sort_string_data_member_diff_sptr_map(const string_var_diff_sptr_map& map,
@@ -324,7 +324,7 @@ sort_string_elf_symbol_map(const string_elf_symbol_map& map,
/// @param sorted out parameter; the sorted vector of @ref var_decl.
void
sort_string_var_ptr_map(const string_var_ptr_map& map,
- vector<const var_decl*>& sorted)
+ vector<var_decl_sptr>& sorted)
{
for (string_var_ptr_map::const_iterator i = map.begin();
i != map.end();
@@ -9685,7 +9685,7 @@ corpus_diff::priv::ensure_lookup_tables_populated()
unsigned i = it->index();
ABG_ASSERT(i < first_->get_variables().size());
- const var_decl* deleted_var = first_->get_variables()[i];
+ const var_decl_sptr deleted_var = first_->get_variables()[i];
string n = deleted_var->get_id();
ABG_ASSERT(!n.empty());
ABG_ASSERT(deleted_vars_.find(n) == deleted_vars_.end());
@@ -9702,7 +9702,7 @@ corpus_diff::priv::ensure_lookup_tables_populated()
++iit)
{
unsigned i = *iit;
- const var_decl* added_var = second_->get_variables()[i];
+ const var_decl_sptr added_var = second_->get_variables()[i];
string n = added_var->get_id();
ABG_ASSERT(!n.empty());
{
@@ -9720,10 +9720,8 @@ corpus_diff::priv::ensure_lookup_tables_populated()
{
if (*j->second != *added_var)
{
- var_decl_sptr f(const_cast<var_decl*>(j->second),
- noop_deleter());
- var_decl_sptr s(const_cast<var_decl*>(added_var),
- noop_deleter());
+ var_decl_sptr f = j->second;
+ var_decl_sptr s = added_var;
changed_vars_map_[n] = compute_diff(f, s, ctxt);
}
deleted_vars_.erase(j);
@@ -10173,7 +10171,7 @@ function_is_suppressed(const function_decl* fn,
/// change reports about variable @p fn, if that variable changes in
/// the way expressed by @p k.
static bool
-variable_is_suppressed(const var_decl* var,
+variable_is_suppressed(const var_decl_sptr& var,
const suppression_sptr suppr,
variable_suppression::change_kind k,
const diff_context_sptr ctxt)
@@ -10425,7 +10423,7 @@ corpus_diff::priv::added_function_is_suppressed(const function_decl* fn) const
/// @return true iff the change reports for a give given deleted
/// variable has been deleted.
bool
-corpus_diff::priv::deleted_variable_is_suppressed(const var_decl* var) const
+corpus_diff::priv::deleted_variable_is_suppressed(const var_decl_sptr& var) const
{
if (!var)
return false;
@@ -10444,7 +10442,7 @@ corpus_diff::priv::deleted_variable_is_suppressed(const var_decl* var) const
/// @return true iff the change reports for a given deleted
/// variable has been deleted.
bool
-corpus_diff::priv::added_variable_is_suppressed(const var_decl* var) const
+corpus_diff::priv::added_variable_is_suppressed(const var_decl_sptr& var) const
{
if (!var)
return false;
@@ -55,12 +55,12 @@ typedef unordered_map<interned_string,
/// Convenience typedef for a hash map which key is a string and
/// which data is an abigail::ir::var_decl*.
-typedef unordered_map<string, var_decl*> str_var_ptr_map_type;
+typedef unordered_map<string, var_decl_sptr> str_var_ptr_map_type;
/// Convenience typedef for a hash map which key is an interned_string
/// and which data is an abigail::ir::var_decl*.
typedef unordered_map<interned_string,
- var_decl*,
+ var_decl_sptr,
hash_interned_string> istr_var_ptr_map_type;
/// The type of the private data of @ref
@@ -449,7 +449,7 @@ public:
///
/// @param id the variable to add to the map.
void
- add_var_to_map(var_decl* var)
+ add_var_to_map(const var_decl_sptr& var)
{
if (var)
{
@@ -475,13 +475,13 @@ public:
///
/// @param fn the variable to add to the set of exported variables.
void
- add_var_to_exported(const var_decl* var)
+ add_var_to_exported(const var_decl_sptr& var)
{
const interned_string& id = get_id(*var);
if (!var_id_is_in_id_var_map(id))
{
- vars_.push_back(const_cast<var_decl*>(var));
- add_var_to_map(const_cast<var_decl*>(var));
+ vars_.push_back(var);
+ add_var_to_map(var);
}
}
@@ -617,7 +617,7 @@ public:
///
/// @return true iff the variable is to be kept.
bool
- keep_wrt_id_of_vars_to_keep(const var_decl* var)
+ keep_wrt_id_of_vars_to_keep(const var_decl_sptr& var)
{
if (!var)
return false;
@@ -662,7 +662,7 @@ public:
///
/// @return true iff the variable is to be kept.
bool
- keep_wrt_regex_of_vars_to_suppress(const var_decl *var)
+ keep_wrt_regex_of_vars_to_suppress(const var_decl_sptr var)
{
if (!var)
return false;
@@ -691,7 +691,7 @@ public:
///
/// @return true iff the variable is to be kept.
bool
- keep_wrt_regex_of_vars_to_keep(const var_decl *var)
+ keep_wrt_regex_of_vars_to_keep(const var_decl_sptr& var)
{
if (!var)
return false;
@@ -743,7 +743,7 @@ struct corpus::priv
translation_units members;
string_tu_map_type path_tu_map;
vector<const function_decl*> fns;
- vector<const var_decl*> vars;
+ vector<var_decl_sptr> vars;
functions_set undefined_fns;
functions sorted_undefined_fns;
variables_set undefined_vars;
@@ -190,7 +190,7 @@ corpus::exported_decls_builder::maybe_add_fn_to_exported_fns(function_decl* fn)
/// @return true iff the variable was added to the set of exported
/// variables.
bool
-corpus::exported_decls_builder::maybe_add_var_to_exported_vars(const var_decl* var)
+corpus::exported_decls_builder::maybe_add_var_to_exported_vars(const var_decl_sptr& var)
{
if (!var->get_is_in_public_symbol_table())
return false;
@@ -308,8 +308,12 @@ struct var_comp
return first_name < second_name;
}
-};
+ bool
+ operator()(const var_decl_sptr& first,
+ const var_decl_sptr& second) const
+ {return operator()(first.get(), second.get());}
+};
/// A comparison functor to compare elf_symbols for the purpose of
/// sorting.
@@ -1411,7 +1415,7 @@ corpus::lookup_functions(const char* id) const
///
/// @return the variable with ID @p id that was found or nil if none
/// was found.
-const var_decl*
+const var_decl_sptr
corpus::lookup_variable(const interned_string& id) const
{
exported_decls_builder_sptr b = get_exported_decls_builder();
@@ -502,7 +502,7 @@ public:
add_decl_to_scope(var_declaration,
ir_translation_unit->get_global_scope());
var_declaration->set_is_in_public_symbol_table(true);
- add_var_to_exported_or_undefined_decls(var_declaration.get());
+ add_var_to_exported_or_undefined_decls(var_declaration);
}
else
{
@@ -16300,7 +16300,7 @@ build_ir_node_from_die(reader& rdr,
rdr.var_decls_to_re_add_to_tree().push_back(m);
}
ABG_ASSERT(m->get_scope());
- rdr.add_var_to_exported_or_undefined_decls(m.get());
+ rdr.add_var_to_exported_or_undefined_decls(m);
result = m;
}
}
@@ -16318,7 +16318,7 @@ build_ir_node_from_die(reader& rdr,
ABG_ASSERT(v);
ABG_ASSERT(v->get_scope());
rdr.var_decls_to_re_add_to_tree().push_back(v);
- rdr.add_var_to_exported_or_undefined_decls(v.get());
+ rdr.add_var_to_exported_or_undefined_decls(v);
}
}
break;
@@ -334,7 +334,7 @@ fe_iface::add_fn_to_exported_or_undefined_decls(const function_decl* fn)
///
/// @param var the internal representation of the ABI of a variable.
void
-fe_iface::add_var_to_exported_or_undefined_decls(const var_decl* var)
+fe_iface::add_var_to_exported_or_undefined_decls(const var_decl_sptr& var)
{
bool added = false;
if (var)
@@ -5375,7 +5375,7 @@ build_class_decl(reader& rdr,
is_static,
offset_in_bits);
if (is_static)
- rdr.add_var_to_exported_or_undefined_decls(v.get());
+ rdr.add_var_to_exported_or_undefined_decls(v);
// Now let's record the fact that the data
// member uses its type and that the class being
// built uses the data member.
@@ -6469,7 +6469,7 @@ handle_var_decl(reader& rdr,
{
decl_base_sptr decl = build_var_decl_if_not_suppressed(rdr, node,
add_to_current_scope);
- rdr.add_var_to_exported_or_undefined_decls(is_var_decl(decl).get());
+ rdr.add_var_to_exported_or_undefined_decls(is_var_decl(decl));
return decl;
}
@@ -2548,8 +2548,7 @@ write_translation_unit(write_context& ctxt,
if (const abigail::ir::corpus* abi = tu.get_corpus())
for (auto undefined_var : abi->get_sorted_undefined_variables())
{
- var_decl_sptr v(const_cast<var_decl*>(undefined_var),
- noop_deleter());
+ var_decl_sptr v = undefined_var;
if (v->get_translation_unit() != &tu || ctxt.decl_is_emitted(v))
continue;
@@ -166,11 +166,11 @@ struct fn_change
/// the differences found in the type of that variable.
struct var_change
{
- const var_decl* decl = nullptr;
+ var_decl_sptr decl = nullptr;
diff_sptr diff;
bool reverse_direction = false;
- var_change(const var_decl* var,
+ var_change(const var_decl_sptr& var,
diff_sptr difference,
bool reverse_dir)
: decl(var),
@@ -542,7 +542,7 @@ compare_expected_against_provided_variables(diff_context_sptr& ctxt,
{
interned_string var_id = expected_var->get_id();
// ... against the variables exported by the library!
- const var_decl* exported_var =
+ const var_decl_sptr exported_var =
reverse_direction
? app_corpus->lookup_variable(var_id)
: lib_corpus->lookup_variable(var_id);