struct priv;
std::unique_ptr<priv> priv_;
- corpus(ir::environment*, const string& path= "");
+ corpus(const ir::environment&, const string& path= "");
virtual ~corpus();
- const environment*
+ const environment&
get_environment() const;
- environment*
- get_environment();
-
- void
- set_environment(environment*);
-
void
add(const translation_unit_sptr);
public:
typedef vector<corpus_sptr> corpora_type;
- corpus_group(ir::environment*, const string&);
+ corpus_group(const ir::environment&, const string&);
virtual ~corpus_group();
read_context_sptr
create_read_context(const std::string& elf_path,
const vector<char**>& debug_info_root_paths,
- ir::environment *env);
+ ir::environment& env);
corpus_sptr
read_corpus(read_context *ctxt, elf_reader::status& status);
void
reset_read_context(read_context_sptr &ctxt,
const std::string& elf_path,
- const vector<char**>& debug_info_root_path,
- ir::environment* environment);
+ const vector<char**>& debug_info_root_path);
std::string
dic_type_key(ctf_dict_t *dic, ctf_id_t ctf_type);
} // end namespace ctf_reader
read_context_sptr
create_read_context(const std::string& elf_path,
const vector<char**>& debug_info_root_paths,
- ir::environment* environment,
+ ir::environment& environment,
bool read_all_types = false,
bool linux_kernel_mode = false);
reset_read_context(read_context_sptr &ctxt,
const std::string& elf_path,
const vector<char**>& debug_info_root_paths,
- ir::environment* environment,
bool read_all_types = false,
bool linux_kernel_mode = false);
corpus_sptr
read_corpus_from_elf(const std::string& elf_path,
const vector<char**>& debug_info_root_paths,
- ir::environment* environment,
+ ir::environment& environment,
bool load_all_types,
elf_reader::status&);
read_and_add_corpus_to_group_from_elf(read_context&, corpus_group&, elf_reader::status&);
bool
-lookup_symbol_from_elf(const environment* env,
+lookup_symbol_from_elf(const environment& env,
const string& elf_path,
const string& symbol_name,
bool demangle,
vector<elf_symbol_sptr>& symbols);
bool
-lookup_public_function_symbol_from_elf(const environment* env,
+lookup_public_function_symbol_from_elf(const environment& env,
const string& path,
const string& symname,
vector<elf_symbol_sptr>& func_syms);
demangle_cplus_mangled_name(const string&);
type_base_sptr
-type_or_void(const type_base_sptr, const environment*);
+type_or_void(const type_base_sptr, const environment&);
type_base_sptr
canonicalize(type_base_sptr);
};
public:
- translation_unit(const ir::environment* env,
+ translation_unit(const ir::environment& env,
const std::string& path,
char address_size = 0);
virtual ~translation_unit();
- const environment*
+ const environment&
get_environment() const;
- environment*
- get_environment();
-
- void
- set_environment(const environment*);
-
language
get_language() const;
elf_symbol();
- elf_symbol(const environment* e,
+ elf_symbol(const environment& e,
size_t i,
size_t s,
const string& n,
public:
static elf_symbol_sptr
- create();
-
- static elf_symbol_sptr
- create(const environment* e,
- size_t i,
- size_t s,
- const string& n,
- type t,
- binding b,
- bool d,
- bool c,
- const version& ve,
- visibility vi,
- bool is_in_ksymtab = false,
+ create(const environment& e,
+ size_t i,
+ size_t s,
+ const string& n,
+ type t,
+ binding b,
+ bool d,
+ bool c,
+ const version& ve,
+ visibility vi,
+ bool is_in_ksymtab = false,
const abg_compat::optional<uint32_t>& crc = {},
const abg_compat::optional<std::string>& ns = {},
- bool is_suppressed = false);
+ bool is_suppressed = false);
- const environment*
+ const environment&
get_environment() const;
- void
- set_environment(const environment*) const;
-
size_t
get_index() const;
mutable std::unique_ptr<priv> priv_;
type_or_decl_base();
+ type_or_decl_base(const type_or_decl_base&);
protected:
void hashing_started(bool) const;
+ type_or_decl_base&
+ operator=(const type_or_decl_base&);
+
public:
- type_or_decl_base(const environment*,
+ type_or_decl_base(const environment&,
enum type_or_decl_kind k = ABSTRACT_TYPE_OR_DECL);
- type_or_decl_base(const type_or_decl_base&);
-
virtual ~type_or_decl_base();
bool
void
set_is_artificial(bool);
- const environment*
+ const environment&
get_environment() const;
- environment*
- get_environment();
-
- void
- set_environment(const environment*);
-
void
set_artificial_location(const location &);
translation_unit*
get_translation_unit();
- type_or_decl_base&
- operator=(const type_or_decl_base&);
-
virtual bool
traverse(ir_node_visitor&);
bool
operator!=(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&);
-void
-set_environment_for_artifact(type_or_decl_base* artifact,
- const environment* env);
-
-void
-set_environment_for_artifact(type_or_decl_base_sptr artifact,
- const environment* env);
-
/// The base type of all declarations.
class decl_base : public virtual type_or_decl_base
{
void
set_context_rel(context_rel *c);
+ decl_base(const decl_base&);
public:
- decl_base(const environment* e,
+ decl_base(const environment& e,
const string& name,
const location& locus,
const string& mangled_name = "",
visibility vis = VISIBILITY_DEFAULT);
- decl_base(const environment* e,
+ decl_base(const environment& e,
const interned_string& name,
const location& locus,
const interned_string& mangled_name = interned_string(),
visibility vis = VISIBILITY_DEFAULT);
- decl_base(const environment*, const location&);
-
- decl_base(const decl_base&);
+ decl_base(const environment&, const location&);
virtual bool
operator==(const decl_base&) const;
public:
struct hash;
- scope_decl(const environment* env,
+ scope_decl(const environment& env,
const string& name, const location& locus,
visibility vis = VISIBILITY_DEFAULT);
- scope_decl(const environment* env, location& l);
+ scope_decl(const environment& env, location& l);
virtual size_t
get_hash() const;
/// runtime type of the type pointed to.
struct shared_ptr_hash;
- type_base(const environment* e, size_t s, size_t a);
+ type_base(const environment& e, size_t s, size_t a);
friend type_base_sptr canonicalize(type_base_sptr);
/// Facility to hash instance of type_decl
struct hash;
- type_decl(const environment* env,
+ type_decl(const environment& env,
const string& name,
size_t size_in_bits,
size_t alignment_in_bits,
/// Hasher for instances of scope_type_decl
struct hash;
- scope_type_decl(const environment* env, const string& name,
+ scope_type_decl(const environment& env, const string& name,
size_t size_in_bits, size_t alignment_in_bits,
const location& locus, visibility vis = VISIBILITY_DEFAULT);
{
public:
- namespace_decl(const environment* env, const string& name,
+ namespace_decl(const environment& env, const string& name,
const location& locus, visibility vis = VISIBILITY_DEFAULT);
virtual string
qualified_type_def(type_base_sptr type, CV quals, const location& locus);
- qualified_type_def(environment* env, CV quals, const location& locus);
+ qualified_type_def(const environment& env, CV quals, const location& locus);
virtual size_t
get_size_in_bits() const;
pointer_type_def(const type_base_sptr& pointed_to_type, size_t size_in_bits,
size_t alignment_in_bits, const location& locus);
- pointer_type_def(environment* env, size_t size_in_bits,
+ pointer_type_def(const environment& env, size_t size_in_bits,
size_t alignment_in_bits, const location& locus);
-
void
set_pointed_to_type(const type_base_sptr&);
bool lvalue, size_t size_in_bits,
size_t alignment_in_bits, const location& locus);
- reference_type_def(const environment* env, bool lvalue, size_t size_in_bits,
+ reference_type_def(const environment& env, bool lvalue, size_t size_in_bits,
size_t alignment_in_bits, const location& locus);
void
/// Hasher for an instance of array::subrange
struct hash;
- subrange_type(const environment* env,
+ subrange_type(const environment& env,
const string& name,
bound_value lower_bound,
bound_value upper_bound,
const location& loc,
translation_unit::language l = translation_unit::LANG_C11);
- subrange_type(const environment* env,
+ subrange_type(const environment& env,
const string& name,
bound_value lower_bound,
bound_value upper_bound,
const location& loc,
translation_unit::language l = translation_unit::LANG_C11);
- subrange_type(const environment* env,
+ subrange_type(const environment& env,
const string& name,
bound_value upper_bound,
const location& loc,
const std::vector<subrange_sptr>& subs,
const location& locus);
- array_type_def(environment* env,
+ array_type_def(const environment& env,
const std::vector<subrange_sptr>& subs,
const location& locus);
~enumerator();
- enumerator(const environment* env, const string& name, int64_t value);
+ enumerator(const string& name, int64_t value);
enumerator(const enumerator&);
bool
operator!=(const enumerator& other) const;
- const environment*
- get_environment() const;
-
- const interned_string&
+ const string&
get_name() const;
- const interned_string&
+ const string&
get_qualified_name(bool internal = false) const;
void
visibility vis = VISIBILITY_DEFAULT);
typedef_decl(const string& name,
- environment* env,
+ const environment& env,
const location& locus,
const string& mangled_name = "",
visibility vis = VISIBILITY_DEFAULT);
size_t size_in_bits,
size_t alignment_in_bits);
- function_type(const environment* env,
+ function_type(const environment& env,
size_t size_in_bits,
size_t alignment_in_bits);
size_t size_in_bits,
size_t alignment_in_bits);
- method_type(const environment* env,
+ method_type(const environment& env,
size_t size_in_bits,
size_t alignment_in_bits);
/// Hasher.
struct hash;
- template_decl(const environment* env,
+ template_decl(const environment& env,
const string& name,
const location& locus,
visibility vis = VISIBILITY_DEFAULT);
struct hash;
struct shared_ptr_hash;
- function_tdecl(const environment* env,
+ function_tdecl(const environment& env,
const location& locus,
visibility vis = VISIBILITY_DEFAULT,
binding bind = BINDING_NONE);
struct hash;
struct shared_ptr_hash;
- class_tdecl(const environment* env, const location& locus,
+ class_tdecl(const environment& env, const location& locus,
visibility vis = VISIBILITY_DEFAULT);
class_tdecl(class_decl_sptr pattern,
typedef unordered_map<string, method_decl_sptr> string_mem_fn_sptr_map_type;
/// @}
- class_or_union(const environment* env, const string& name,
+ class_or_union(const environment& env, const string& name,
size_t size_in_bits, size_t align_in_bits,
const location& locus, visibility vis,
member_types& mbrs, data_members& data_mbrs,
member_functions& member_fns);
- class_or_union(const environment* env, const string& name,
+ class_or_union(const environment& env, const string& name,
size_t size_in_bits, size_t align_in_bits,
const location& locus, visibility vis);
- class_or_union(const environment* env, const string& name,
+ class_or_union(const environment& env, const string& name,
bool is_declaration_only = true);
virtual void
public:
- class_decl(const environment* env, const string& name,
+ class_decl(const environment& env, const string& name,
size_t size_in_bits, size_t align_in_bits,
bool is_struct, const location& locus,
visibility vis, base_specs& bases,
member_types& mbrs, data_members& data_mbrs,
member_functions& member_fns);
- class_decl(const environment* env, const string& name,
+ class_decl(const environment& env, const string& name,
size_t size_in_bits, size_t align_in_bits,
bool is_struct, const location& locus,
visibility vis, base_specs& bases,
member_types& mbrs, data_members& data_mbrs,
member_functions& member_fns, bool is_anonymous);
- class_decl(const environment* env, const string& name,
+ class_decl(const environment& env, const string& name,
size_t size_in_bits, size_t align_in_bits,
bool is_struct, const location& locus, visibility vis);
- class_decl(const environment* env, const string& name,
+ class_decl(const environment& env, const string& name,
size_t size_in_bits, size_t align_in_bits,
bool is_struct, const location& locus,
visibility vis, bool is_anonymous);
- class_decl(const environment* env, const string& name, bool is_struct,
+ class_decl(const environment& env, const string& name, bool is_struct,
bool is_declaration_only = true);
virtual string
public:
- union_decl(const environment* env, const string& name,
+ union_decl(const environment& env, const string& name,
size_t size_in_bits, const location& locus,
visibility vis, member_types& mbrs,
data_members& data_mbrs, member_functions& member_fns);
- union_decl(const environment* env, const string& name,
+ union_decl(const environment& env, const string& name,
size_t size_in_bits, const location& locus,
visibility vis, member_types& mbrs,
data_members& data_mbrs, member_functions& member_fns,
bool is_anonymous);
- union_decl(const environment* env, const string& name,
+ union_decl(const environment& env, const string& name,
size_t size_in_bits, const location& locus,
visibility vis);
- union_decl(const environment* env, const string& name,
+ union_decl(const environment& env, const string& name,
size_t size_in_bits, const location& locus,
visibility vis, bool is_anonymous);
- union_decl(const environment* env, const string& name,
+ union_decl(const environment& env, const string& name,
bool is_declaration_only = true);
virtual string
translation_unit_sptr
read_translation_unit_from_file(const std::string& file_path,
- environment* env);
+ environment& env);
translation_unit_sptr
read_translation_unit_from_buffer(const std::string& file_path,
- environment* env);
+ environment& env);
translation_unit_sptr
read_translation_unit_from_istream(std::istream* in,
- environment* env);
+ environment& env);
translation_unit_sptr
read_translation_unit(read_context&);
typedef shared_ptr<read_context> read_context_sptr;
read_context_sptr
-create_native_xml_read_context(const string& path, environment *env);
+create_native_xml_read_context(const string& path, environment& env);
read_context_sptr
-create_native_xml_read_context(std::istream* in, environment* env);
-
+create_native_xml_read_context(std::istream* in, environment& env);
const string&
read_context_get_path(const read_context&);
corpus_sptr
read_corpus_from_native_xml(std::istream* in,
- environment* env);
+ environment& env);
corpus_sptr
read_corpus_from_native_xml_file(const string& path,
- environment* env);
+ environment& env);
corpus_sptr
read_corpus_from_input(read_context& ctxt);
corpus_group_sptr
read_corpus_group_from_native_xml(std::istream* in,
- environment* env);
+ environment& env);
corpus_group_sptr
read_corpus_group_from_native_xml_file(const string& path,
- environment* env);
+ environment& env);
void
add_read_context_suppressions(read_context& ctxt,
vector<string>& kabi_wl_paths,
suppr::suppressions_type& supprs,
bool verbose,
- environment_sptr& env,
+ environment& env,
corpus::origin origin = corpus::DWARF_ORIGIN);
}// end namespace tools_utils
typedef shared_ptr<write_context> write_context_sptr;
write_context_sptr
-create_write_context(const environment *env,
+create_write_context(const environment& env,
ostream& output_stream);
void
if (!first || !second)
return diff_sptr();
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
diff_sptr d;
if (is_type(first) && is_type(second))
d = compute_diff_for_types(first, second, ctxt);
decl_base_sptr f = get_type_declaration(first),
s = get_type_declaration(second);
- if (first && second)
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
diff_sptr d = compute_diff_for_types(f,s, ctxt);
ABG_ASSERT(d);
return d;
const var_decl_sptr second,
diff_context_sptr ctxt)
{
- if (first && second)
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
var_diff_sptr d(new var_diff(first, second, diff_sptr(), ctxt));
ctxt->initialize_canonical_diff(d);
pointer_type_def_sptr second,
diff_context_sptr ctxt)
{
- if (first && second)
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
diff_sptr d = compute_diff_for_types(first->get_pointed_to_type(),
second->get_pointed_to_type(),
ctxt);
array_type_def_sptr second,
diff_context_sptr ctxt)
{
- if (first && second)
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
diff_sptr d = compute_diff_for_types(first->get_element_type(),
second->get_element_type(),
ctxt);
reference_type_def_sptr second,
diff_context_sptr ctxt)
{
- if (first && second)
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
diff_sptr d = compute_diff_for_types(first->get_pointed_to_type(),
second->get_pointed_to_type(),
ctxt);
const qualified_type_def_sptr second,
diff_context_sptr ctxt)
{
- if (first && second)
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
diff_sptr d = compute_diff_for_types(first->get_underlying_type(),
second->get_underlying_type(),
ctxt);
const enum_type_decl_sptr second,
diff_context_sptr ctxt)
{
- if (first && second)
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
diff_sptr ud = compute_diff_for_types(first->get_underlying_type(),
second->get_underlying_type(),
ctxt);
const class_decl_sptr second,
diff_context_sptr ctxt)
{
- if (first && second)
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
class_decl_sptr f = is_class_type(look_through_decl_only_class(first)),
s = is_class_type(look_through_decl_only_class(second));
const class_decl::base_spec_sptr second,
diff_context_sptr ctxt)
{
- if (first && second)
- {
- ABG_ASSERT(first->get_environment() == second->get_environment());
- ABG_ASSERT(first->get_base_class()->get_environment()
- == second->get_base_class()->get_environment());
- ABG_ASSERT(first->get_environment()
- == first->get_base_class()->get_environment());
- }
-
class_diff_sptr cl = compute_diff(first->get_base_class(),
second->get_base_class(),
ctxt);
const union_decl_sptr second,
diff_context_sptr ctxt)
{
- if (first && second)
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
union_diff_sptr changes(new union_diff(first, second, ctxt));
ctxt->initialize_canonical_diff(changes);
{
ABG_ASSERT(d->first_scope() == first && d->second_scope() == second);
- if (first && second)
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
compute_diff(first->get_member_decls().begin(),
first->get_member_decls().end(),
second->get_member_decls().begin(),
const scope_decl_sptr second_scope,
diff_context_sptr ctxt)
{
- if (first_scope && second_scope)
- ABG_ASSERT(first_scope->get_environment()
- == second_scope->get_environment());
-
scope_diff_sptr d(new scope_diff(first_scope, second_scope, ctxt));
d = compute_diff(first_scope, second_scope, d, ctxt);
ctxt->initialize_canonical_diff(d);
if (!first || !second)
return fn_parm_diff_sptr();
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
fn_parm_diff_sptr result(new fn_parm_diff(first, second, ctxt));
ctxt->initialize_canonical_diff(result);
return function_type_diff_sptr();
}
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
function_type_diff_sptr result(new function_type_diff(first, second, ctxt));
diff_utils::compute_diff(first->get_first_parm(),
return function_decl_diff_sptr();
}
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
function_type_diff_sptr type_diff = compute_diff(first->get_type(),
second->get_type(),
ctxt);
const type_decl_sptr second,
diff_context_sptr ctxt)
{
- if (first && second)
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
type_decl_diff_sptr result(new type_decl_diff(first, second, ctxt));
// We don't need to actually compute a diff here as a type_decl
const typedef_decl_sptr second,
diff_context_sptr ctxt)
{
- if (first && second)
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
diff_sptr d = compute_diff_for_types(first->get_underlying_type(),
second->get_underlying_type(),
ctxt);
{
ABG_ASSERT(first && second);
- ABG_ASSERT(first->get_environment() == second->get_environment());
-
if (!ctxt)
ctxt.reset(new diff_context);
ABG_ASSERT(f && s);
- // We can only compare two corpora that were built out of the same
- // environment.
- ABG_ASSERT(f->get_environment() == s->get_environment());
-
if (!ctxt)
ctxt.reset(new diff_context);
return false;
type_base_sptr t = is_type(d->first_subject());
- if (t && t->get_environment()->is_variadic_parameter_type(t))
+ if (t && t->get_environment().is_variadic_parameter_type(t))
return true;
t = is_type(d->second_subject());
- if (t && t->get_environment()->is_variadic_parameter_type(t))
+ if (t && t->get_environment().is_variadic_parameter_type(t))
return true;
return false;
mutable unordered_map<string, type_base_sptr> canonical_types_;
string format_major_version_number_;
string format_minor_version_number_;
- environment* env;
+ const environment& env;
corpus_group* group;
corpus::exported_decls_builder_sptr exported_decls_builder;
corpus::origin origin_;
mutable abg_compat::optional<elf_symbols> unrefed_fun_symbols;
public:
- priv(const string & p,
- environment* e)
+ priv(const string & p,
+ const environment& e)
: env(e),
group(),
origin_(ARTIFICIAL_ORIGIN),
/// @param env the environment of the corpus.
///
/// @param path the path to the file containing the ABI corpus.
-corpus::corpus(ir::environment* env, const string& path)
+corpus::corpus(const ir::environment& env, const string& path)
{
priv_.reset(new priv(path, env));
init_format_version();
/// Getter of the enviroment of the corpus.
///
/// @return the environment of this corpus.
-const environment*
+const environment&
corpus::get_environment() const
{return priv_->env;}
-/// Getter of the enviroment of the corpus.
-///
-/// @return the environment of this corpus.
-environment*
-corpus::get_environment()
-{return priv_->env;}
-
-/// Setter of the environment of this corpus.
-///
-/// @param e the new environment.
-void
-corpus::set_environment(environment* e)
-{
- priv_->env = e;
- init_format_version();
-}
-
/// Add a translation unit to the current ABI Corpus. Next time
/// corpus::save is called, all the translation unit that got added to
/// the corpus are going to be serialized on disk in the file
void
corpus::add(const translation_unit_sptr tu)
{
- if (!tu->get_environment())
- tu->set_environment(get_environment());
-
- ABG_ASSERT(tu->get_environment() == get_environment());
-
ABG_ASSERT(priv_->members.insert(tu).second);
if (!tu->get_absolute_path().empty())
corpus::record_type_as_reachable_from_public_interfaces(const type_base& t)
{
string repr = get_pretty_representation(&t, /*internal=*/true);
- interned_string s = t.get_environment()->intern(repr);
+ interned_string s = t.get_environment().intern(repr);
priv_->get_public_types_pretty_representations()->insert(s);
}
corpus::type_is_reachable_from_public_interfaces(const type_base& t) const
{
string repr = get_pretty_representation(&t, /*internal=*/true);
- interned_string s = t.get_environment()->intern(repr);
+ interned_string s = t.get_environment().intern(repr);
return (priv_->get_public_types_pretty_representations()->find(s)
!= priv_->get_public_types_pretty_representations()->end());
void
corpus::init_format_version()
{
- if (priv_->env)
- {
- set_format_major_version_number
- (priv_->env->get_config().get_format_major_version_number());
- set_format_minor_version_number
- (priv_->env->get_config().get_format_minor_version_number());
- }
+ set_format_major_version_number
+ (priv_->env.get_config().get_format_major_version_number());
+ set_format_minor_version_number
+ (priv_->env.get_config().get_format_minor_version_number());
}
/// Getter for the origin of the corpus.
}
}; // end corpus_group::priv
-/// Default constructor of the @ref corpus_group type.
-corpus_group::corpus_group(environment* env, const string& path = "")
+/// Constructor of the @ref corpus_group type.
+///
+/// @param env the environment of the @ref corpus_group.
+///
+/// @param path the path to the file represented by the corpus group.
+corpus_group::corpus_group(const environment& env, const string& path = "")
: corpus(env, path), priv_(new priv)
{}
if (!corp)
return;
- // Ensure the new environment patches the current one.
- if (const environment* cur_env = get_environment())
- {
- if (environment* corp_env = corp->get_environment())
- ABG_ASSERT(cur_env == corp_env);
- }
- else
- set_environment(corp->get_environment());
-
// Ensure the new architecture name matches the current one.
string cur_arch = get_architecture_name(),
corp_arch = corp->get_architecture_name();
string filename;
/// The IR environment.
- ir::environment *ir_env;
+ ir::environment& ir_env;
/// The CTF archive read from FILENAME. If an archive couldn't
/// be read from the file then this is NULL.
/// created within the same environment.
read_context(const string& elf_path,
const vector<char**>& debug_info_root_paths,
- ir::environment *env) :
- ctfa(NULL)
+ ir::environment& env) :
+ ir_env(env), ctfa(nullptr)
{
- initialize(elf_path, debug_info_root_paths, env);
+ initialize(elf_path, debug_info_root_paths);
}
/// Initializer of read_context.
/// the environment.
void
initialize(const string& elf_path,
- const vector<char**>& debug_info_root_paths,
- ir::environment *env)
+ const vector<char**>& debug_info_root_paths)
{
types_map.clear();
filename = elf_path;
- ir_env = env;
elf_handler = NULL;
elf_handler_dbg = NULL;
elf_fd = -1;
&& type_encoding.cte_format == CTF_INT_SIGNED)
{
/* This is the `void' type. */
- type_base_sptr void_type = ctxt->ir_env->get_void_type();
+ type_base_sptr void_type = ctxt->ir_env.get_void_type();
decl_base_sptr type_declaration = get_type_declaration(void_type);
result = is_type_decl(type_declaration);
canonicalize(result);
translation_unit_sptr tunit)
{
- ir::environment* env = ctxt.ir_env;
- ABG_ASSERT(env);
- type_base_sptr t = env->get_variadic_parameter_type();
+ ir::environment& env = ctxt.ir_env;
+ type_base_sptr t = env.get_variadic_parameter_type();
decl_base_sptr type_declaration = get_type_declaration(t);
if (!has_scope(type_declaration))
add_decl_to_scope(type_declaration, tunit->get_global_scope());
int evalue;
while ((ename = ctf_enum_next(ctf_dictionary, ctf_type, &enum_next, &evalue)))
- enms.push_back(enum_type_decl::enumerator(ctxt->ir_env, ename, evalue));
+ enms.push_back(enum_type_decl::enumerator(ename, evalue));
if (ctf_errno(ctf_dictionary) != ECTF_NEXT_END)
{
fprintf(stderr, "ERROR from ctf_enum_next\n");
read_context_sptr
create_read_context(const std::string& elf_path,
const vector<char**>& debug_info_root_paths,
- ir::environment *env)
+ ir::environment& env)
{
read_context_sptr result(new read_context(elf_path,
debug_info_root_paths,
ctxt->ctfa = ctf_arc_bufopen(&ctxt->ctf_sect, &ctxt->symtab_sect,
&ctxt->strtab_sect, &errp);
- ctxt->ir_env->canonicalization_is_done(false);
+ ctxt->ir_env.canonicalization_is_done(false);
if (ctxt->ctfa == NULL)
status |= elf_reader::STATUS_DEBUG_INFO_NOT_FOUND;
else
ctxt->cur_corpus_->sort_variables();
}
- ctxt->ir_env->canonicalization_is_done(true);
+ ctxt->ir_env.canonicalization_is_done(true);
/* Cleanup and return. */
close_elf_handler(ctxt);
void
reset_read_context(read_context_sptr &ctxt,
const std::string& elf_path,
- const vector<char**>& debug_info_root_path,
- ir::environment* environment)
+ const vector<char**>& debug_info_root_path)
{
if (ctxt)
- ctxt->initialize(elf_path, debug_info_root_path, environment);
+ ctxt->initialize(elf_path, debug_info_root_path);
}
/// Returns a key to be use in types_map dict conformed by
/// @param syms_found a vector of symbols found with the name @p
/// sym_name. table.
static bool
-lookup_symbol_from_sysv_hash_tab(const environment* env,
+lookup_symbol_from_sysv_hash_tab(const environment& env,
Elf* elf_handle,
const string& sym_name,
size_t ht_index,
///
/// @return true if a symbol was actually found.
static bool
-lookup_symbol_from_gnu_hash_tab(const environment* env,
+lookup_symbol_from_gnu_hash_tab(const environment& env,
Elf* elf_handle,
const string& sym_name,
size_t ht_index,
/// @return true iff the function found the symbol from the elf hash
/// table.
static bool
-lookup_symbol_from_elf_hash_tab(const environment* env,
+lookup_symbol_from_elf_hash_tab(const environment& env,
Elf* elf_handle,
hash_table_kind ht_kind,
size_t ht_index,
///
/// @return true iff the symbol was found.
static bool
-lookup_symbol_from_symtab(const environment* env,
+lookup_symbol_from_symtab(const environment& env,
Elf* elf_handle,
const string& sym_name,
size_t sym_tab_index,
///
/// @return true iff a symbol with the name @p symbol_name was found.
static bool
-lookup_symbol_from_elf(const environment* env,
+lookup_symbol_from_elf(const environment& env,
Elf* elf_handle,
const string& symbol_name,
bool demangle,
///
/// @return true iff the symbol was found.
static bool
-lookup_public_function_symbol_from_elf(const environment* env,
+lookup_public_function_symbol_from_elf(environment& env,
Elf* elf_handle,
const string& symbol_name,
vector<elf_symbol_sptr>& func_syms)
public:
struct options_type
{
- environment* env;
+ environment& env;
bool load_in_linux_kernel_mode;
bool load_all_types;
bool show_stats;
bool do_log;
- options_type()
- : env(),
+ options_type(environment& e)
+ : env(e),
load_in_linux_kernel_mode(),
load_all_types(),
show_stats(),
/// exported or not.
read_context(const string& elf_path,
const vector<char**>& debug_info_root_paths,
- ir::environment* environment,
+ ir::environment& environment,
bool load_all_types,
bool linux_kernel_mode)
+ : options_(environment)
{
- initialize(elf_path, debug_info_root_paths, environment,
+ initialize(elf_path, debug_info_root_paths,
load_all_types, linux_kernel_mode);
}
void
initialize(const string& elf_path,
const vector<char**>& debug_info_root_paths,
- ir::environment* environment,
bool load_all_types,
bool linux_kernel_mode)
{
memset(&offline_callbacks_, 0, sizeof(offline_callbacks_));
create_default_dwfl(debug_info_root_paths);
- options_.env = environment;
options_.load_in_linux_kernel_mode = linux_kernel_mode;
options_.load_all_types = load_all_types;
drop_undefined_syms_ = false;
/// Getter for the current environment.
///
/// @return the current environment.
- const ir::environment*
- env() const
+ environment&
+ env()
{return options_.env;}
/// Getter for the current environment.
///
/// @return the current environment.
- ir::environment*
- env()
- {return options_.env;}
-
- /// Setter for the current environment.
- ///
- /// @param env the new current environment.
- void
- env(ir::environment* env)
- {options_.env = env;}
+ const environment&
+ env() const
+ {return const_cast<read_context*>(this)->env();}
/// Getter for the flag that tells us if we are dropping functions
/// and variables that have undefined symbols.
{
read_context& ctxt = *const_cast<read_context*>(this);
string qualified_name = die_qualified_name(ctxt, die, where_offset);
- interned_string istr = env()->intern(qualified_name);
+ interned_string istr = env().intern(qualified_name);
map[die_offset] = istr;
return istr;
}
// The name of the translation unit die is "".
if (die == cur_tu_die())
- return env()->intern("");
+ return env().intern("");
die_istring_map_type& map =
die_qualified_name_maps_.get_container(*const_cast<read_context*>(this),
qualified_name =
die_qualified_type_name(ctxt, die, where_offset);
- interned_string istr = env()->intern(qualified_name);
+ interned_string istr = env().intern(qualified_name);
map[die_offset] = istr;
return istr;
}
read_context& ctxt = *const_cast<read_context*>(this);
string pretty_representation =
die_pretty_print_type(ctxt, die, where_offset);
- interned_string istr = env()->intern(pretty_representation);
+ interned_string istr = env().intern(pretty_representation);
map[die_offset] = istr;
return istr;
}
read_context& ctxt = *const_cast<read_context*>(this);
string pretty_representation =
die_pretty_print(ctxt, die, where_offset);
- interned_string istr = env()->intern(pretty_representation);
+ interned_string istr = env().intern(pretty_representation);
map[die_offset] = istr;
return istr;
}
if (!l || !r)
return !!l == !!r;
- const environment* e = l->get_environment();
- ABG_ASSERT(!e->canonicalization_is_done());
+ const environment& e = l->get_environment();
+ ABG_ASSERT(!e.canonicalization_is_done());
- e->priv_->allow_type_comparison_results_caching(true);
- bool s0 = e->decl_only_class_equals_definition();
- e->decl_only_class_equals_definition(true);
+ e.priv_->allow_type_comparison_results_caching(true);
+ bool s0 = e.decl_only_class_equals_definition();
+ e.decl_only_class_equals_definition(true);
bool equal = l == r;
- e->decl_only_class_equals_definition(s0);
- e->priv_->clear_type_comparison_results_cache();
- e->priv_->allow_type_comparison_results_caching(false);
+ e.decl_only_class_equals_definition(s0);
+ e.priv_->clear_type_comparison_results_cache();
+ e.priv_->allow_type_comparison_results_caching(false);
return equal;
}
do
// Analyze all the DIEs we encounter unless we are asked to only
// analyze exported interfaces and the types reachables from them.
- if (!ctxt.env()->analyze_exported_interfaces_only()
+ if (!ctxt.env().analyze_exported_interfaces_only()
|| ctxt.is_decl_die_with_exported_symbol(&child))
build_ir_node_from_die(ctxt, &child,
die_is_public_decl(&child),
die_loc_and_name(ctxt, &child, l, n, m);
uint64_t val = 0;
die_unsigned_constant_attribute(&child, DW_AT_const_value, val);
- enms.push_back(enum_type_decl::enumerator(ctxt.env(), n, val));
+ enms.push_back(enum_type_decl::enumerator(n, val));
}
while (dwarf_siblingof(&child, &child) == 0);
}
{
// This is a variadic function parameter.
bool is_artificial = die_is_artificial(&child);
- ir::environment* env = ctxt.env();
- ABG_ASSERT(env);
+
type_base_sptr parm_type =
is_type(build_ir_node_for_variadic_parameter_type(ctxt));
function_decl::parameter_sptr p
if (!die_die_attribute(die, DW_AT_type, underlying_type_die))
// A typedef DIE with no underlying type means a typedef to
// void type.
- utype = ctxt.env()->get_void_type();
+ utype = ctxt.env().get_void_type();
if (!utype)
utype =
///
/// @return the newly created symbol.
elf_symbol_sptr
-create_default_fn_sym(const string& sym_name, const environment *env)
+create_default_fn_sym(const string& sym_name, const environment& env)
{
elf_symbol::version ver;
elf_symbol_sptr result =
ctxt.current_corpus()->set_origin(origin);
if (origin & corpus::LINUX_KERNEL_BINARY_ORIGIN
- && !ctxt.env()->user_set_analyze_exported_interfaces_only())
+ && !ctxt.env().user_set_analyze_exported_interfaces_only())
// So we are looking at the Linux Kernel and the user has not set
// any particular option regarding the amount of types to analyse.
// In that case, we need to only analyze types that are reachable
// from exported interfaces otherwise we get such a massive amount
// of type DIEs to look at that things are just too slow down the
// road.
- ctxt.env()->analyze_exported_interfaces_only(true);
+ ctxt.env().analyze_exported_interfaces_only(true);
ctxt.current_corpus()->set_soname(ctxt.dt_soname());
ctxt.current_corpus()->set_needed(ctxt.dt_needed());
(ctxt.current_corpus()->get_exported_decls_builder().get());
#ifdef WITH_DEBUG_SELF_COMPARISON
- if (ctxt.env()->self_comparison_debug_is_on())
- ctxt.env()->set_self_comparison_debug_input(ctxt.current_corpus());
+ if (ctxt.env().self_comparison_debug_is_on())
+ ctxt.env().set_self_comparison_debug_input(ctxt.current_corpus());
#endif
// Walk all the DIEs of the debug info to build a DIE -> parent map
}
}
- ctxt.env()->canonicalization_is_done(false);
+ ctxt.env().canonicalization_is_done(false);
{
tools_utils::timer t;
}
}
- ctxt.env()->canonicalization_is_done(true);
+ ctxt.env().canonicalization_is_done(true);
{
tools_utils::timer t;
static decl_base_sptr
build_ir_node_for_void_type(read_context& ctxt)
{
- ir::environment* env = ctxt.env();
- ABG_ASSERT(env);
- type_base_sptr t = env->get_void_type();
+ ir::environment& env = ctxt.env();
+ type_base_sptr t = env.get_void_type();
decl_base_sptr type_declaration = get_type_declaration(t);
if (!has_scope(type_declaration))
add_decl_to_scope(type_declaration,
build_ir_node_for_variadic_parameter_type(read_context &ctxt)
{
- ir::environment* env = ctxt.env();
- ABG_ASSERT(env);
- type_base_sptr t = env->get_variadic_parameter_type();
+ ir::environment& env = ctxt.env();
+ type_base_sptr t = env.get_variadic_parameter_type();
decl_base_sptr type_declaration = get_type_declaration(t);
if (!has_scope(type_declaration))
add_decl_to_scope(type_declaration,
read_context_sptr
create_read_context(const std::string& elf_path,
const vector<char**>& debug_info_root_paths,
- ir::environment* environment,
+ ir::environment& environment,
bool load_all_types,
bool linux_kernel_mode)
{
reset_read_context(read_context_sptr &ctxt,
const std::string& elf_path,
const vector<char**>& debug_info_root_path,
- ir::environment* environment,
bool read_all_types,
bool linux_kernel_mode)
{
if (ctxt)
- ctxt->initialize(elf_path, debug_info_root_path, environment,
+ ctxt->initialize(elf_path, debug_info_root_path,
read_all_types, linux_kernel_mode);
}
corpus_sptr
read_corpus_from_elf(const std::string& elf_path,
const vector<char**>& debug_info_root_paths,
- ir::environment* environment,
+ environment& environment,
bool load_all_types,
status& status)
{
/// @return true iff the symbol was found among the publicly exported
/// symbols of the ELF file.
bool
-lookup_symbol_from_elf(const environment* env,
+lookup_symbol_from_elf(const environment& env,
const string& elf_path,
const string& symbol_name,
bool demangle,
/// @return true iff a function with symbol name @p symbol_name is
/// found.
bool
-lookup_public_function_symbol_from_elf(const environment* env,
+lookup_public_function_symbol_from_elf(environment& env,
const string& path,
const string& symname,
vector<elf_symbol_sptr>& syms)
{
vector<char**> di_roots;
di_roots.push_back(debug_info_root_path);
- read_context_sptr c = create_read_context(elf_path, di_roots, 0);
+ environment env;
+ read_context_sptr c = create_read_context(elf_path, di_roots, env);
read_context& ctxt = *c;
// Load debug info from the elf path.
/// Private type to hold private members of @ref translation_unit
struct translation_unit::priv
{
- const environment* env_;
+ const environment& env_;
corpus* corp;
bool is_constructed_;
char address_size_;
type_maps types_;
- priv(const environment* env)
+ priv(const environment& env)
: env_(env),
corp(),
is_constructed_(),
for (auto i : types_with_non_confirmed_propagated_ct_)
{
type_base *t = reinterpret_cast<type_base*>(i);
- ABG_ASSERT(t->get_environment()->priv_->is_recursive_type(t)
+ ABG_ASSERT(t->get_environment().priv_->is_recursive_type(t)
|| t->priv_->depends_on_recursive_type());
t->priv_->set_does_not_depend_on_recursive_type(dependant_type);
if (!t->priv_->depends_on_recursive_type())
if (!t || t->priv_->propagated_canonical_type_confirmed())
return;
- const environment* env = t->get_environment();
- ABG_ASSERT(env);
+ const environment& env = t->get_environment();
- env->priv_->confirm_ct_propagation_for_types_dependant_on(t);
+ env.priv_->confirm_ct_propagation_for_types_dependant_on(t);
t->priv_->set_does_not_depend_on_recursive_type();
- env->priv_->remove_from_types_with_non_confirmed_propagated_ct(t);
- env->priv_->set_is_not_recursive(t);
+ env.priv_->remove_from_types_with_non_confirmed_propagated_ct(t);
+ env.priv_->set_is_not_recursive(t);
t->priv_->set_propagated_canonical_type_confirmed(true);
}
for (auto i : types_with_non_confirmed_propagated_ct_)
{
type_base *t = reinterpret_cast<type_base*>(i);
- ABG_ASSERT(t->get_environment()->priv_->is_recursive_type(t)
+ ABG_ASSERT(t->get_environment().priv_->is_recursive_type(t)
|| t->priv_->depends_on_recursive_type());
t->priv_->set_does_not_depend_on_recursive_type();
t->priv_->set_propagated_canonical_type_confirmed(true);
for (auto i : to_remove)
{
type_base *t = reinterpret_cast<type_base*>(i);
- ABG_ASSERT(t->get_environment()->priv_->is_recursive_type(t)
+ ABG_ASSERT(t->get_environment().priv_->is_recursive_type(t)
|| t->priv_->depends_on_recursive_type());
type_base_sptr canonical = t->priv_->canonical_type.lock();
if (canonical)
if (!t)
return;
- const environment *env = t->get_environment();
- env->priv_->cancel_ct_propagation_for_types_dependant_on(t);
+ const environment& env = t->get_environment();
+ env.priv_->cancel_ct_propagation_for_types_dependant_on(t);
if (t->priv_->depends_on_recursive_type()
- || env->priv_->is_recursive_type(t))
+ || env.priv_->is_recursive_type(t))
{
// This cannot carry any tentative canonical type at this
// point.
// Reset the marking of the type as it no longer carries a
// tentative canonical type that might be later cancelled.
t->priv_->set_does_not_depend_on_recursive_type();
- env->priv_->remove_from_types_with_non_confirmed_propagated_ct(t);
+ env.priv_->remove_from_types_with_non_confirmed_propagated_ct(t);
}
}
mark_as_being_compared(const class_or_union& first,
const class_or_union& second) const
{
- const environment* env = first.get_environment();
- ABG_ASSERT(env);
- env->priv_->classes_being_compared_.insert
+ const environment& env = first.get_environment();
+ env.priv_->classes_being_compared_.insert
(std::make_pair(reinterpret_cast<uint64_t>(&first),
reinterpret_cast<uint64_t>(&second)));
}
unmark_as_being_compared(const class_or_union& first,
const class_or_union& second) const
{
- const environment* env = first.get_environment();
- ABG_ASSERT(env);
- env->priv_->classes_being_compared_.erase
+ const environment& env = first.get_environment();
+ env.priv_->classes_being_compared_.erase
(std::make_pair(reinterpret_cast<uint64_t>(&first),
reinterpret_cast<uint64_t>(&second)));
}
comparison_started(const class_or_union& first,
const class_or_union& second) const
{
- const environment* env = first.get_environment();
- ABG_ASSERT(env);
- return env->priv_->
+ const environment& env = first.get_environment();
+ return env.priv_->
classes_being_compared_.count
(std::make_pair(reinterpret_cast<uint64_t>(&first),
reinterpret_cast<uint64_t>((&second))));
mark_as_being_compared(const function_type& first,
const function_type& second) const
{
- const environment* env = first.get_environment();
- ABG_ASSERT(env);
- env->priv_->fn_types_being_compared_.insert
+ const environment& env = first.get_environment();
+ env.priv_->fn_types_being_compared_.insert
(std::make_pair(reinterpret_cast<uint64_t>(&first),
reinterpret_cast<uint64_t>(&second)));
}
unmark_as_being_compared(const function_type& first,
const function_type& second) const
{
- const environment* env = first.get_environment();
- ABG_ASSERT(env);
- env->priv_->fn_types_being_compared_.erase
+ const environment& env = first.get_environment();
+ env.priv_->fn_types_being_compared_.erase
(std::make_pair(reinterpret_cast<uint64_t>(&first),
reinterpret_cast<uint64_t>(&second)));
}
comparison_started(const function_type& first,
const function_type& second) const
{
- const environment* env = first.get_environment();
- ABG_ASSERT(env);
- return env->priv_->fn_types_being_compared_.count
+ const environment& env = first.get_environment();
+ return env.priv_->fn_types_being_compared_.count
(std::make_pair(reinterpret_cast<uint64_t>(&first),
reinterpret_cast<uint64_t>(&second)));
}
namespace
{
-/// This internal type is a tree walker that walks the sub-tree of a
-/// type and sets the environment of the type (including its sub-type)
-/// to a new environment.
-class environment_setter : public abigail::ir::ir_node_visitor
-{
- const abigail::ir::environment* env_;
-
-public:
- environment_setter(const abigail::ir::environment* env)
- : env_(env)
- {}
-
- /// This function is called on each sub-tree node that is a
- /// declaration. Note that it's also called on some types because
- /// most types that have a declarations also inherit the type @ref
- /// decl_base.
- ///
- /// @param d the declaration being visited.
- bool
- visit_begin(abigail::ir::decl_base* d)
- {
- if (const abigail::ir::environment* env = d->get_environment())
- {
- ABG_ASSERT(env == env_);
- return false;
- }
- else
- d->set_environment(env_);
-
- return true;
-
- }
-
- /// This function is called on each sub-tree node that is a type.
- ///
- /// @param t the type being visited.
- bool
- visit_begin(abigail::ir::type_base* t)
- {
- if (abigail::ir::environment* env = t->get_environment())
- {
- ABG_ASSERT(env == env_);
- return false;
- }
- else
- {
- ABG_ASSERT(!t->get_environment());
- t->set_environment(env_);
- }
- return true;
- }
-};
-
/// This internal type is a tree walking that is used to set the
/// qualified name of a tree of decls and types. It used by the
/// function update_qualified_name().
push_composite_type_comparison_operands(const type_base& left,
const type_base& right)
{
- const environment * env = left.get_environment();
- env->priv_->push_composite_type_comparison_operands(&left, &right);
+ const environment& env = left.get_environment();
+ env.priv_->push_composite_type_comparison_operands(&left, &right);
}
/// Pop a pair of operands from the stack of operands to the current
pop_composite_type_comparison_operands(const type_base& left,
const type_base& right)
{
- const environment * env = left.get_environment();
- env->priv_->pop_composite_type_comparison_operands(&left, &right);
+ const environment& env = left.get_environment();
+ env.priv_->pop_composite_type_comparison_operands(&left, &right);
}
/// In the stack of the current types being compared (as part of type
bool
mark_dependant_types_compared_until(const type_base &r)
{
- const environment * env = r.get_environment();
- if (env->do_on_the_fly_canonicalization())
- return env->priv_->mark_dependant_types_compared_until(&r);
+ const environment& env = r.get_environment();
+ if (env.do_on_the_fly_canonicalization())
+ return env.priv_->mark_dependant_types_compared_until(&r);
return false;
}
// instructing us to compare them canonically, and the second time
// with that boolean set to false, instructing us to compare them
// structurally.
- const environment *env = l->get_environment();
- if (env->priv_->use_canonical_type_comparison_)
+ const environment&env = l->get_environment();
+ if (env.priv_->use_canonical_type_comparison_)
{
if (const type_base *lc = l->get_naked_canonical_type())
if (const type_base *rc = r->get_naked_canonical_type())
unmark_types_as_being_compared(l, r);
- const environment* env = l.get_environment();
- if (env->do_on_the_fly_canonicalization())
+ const environment& env = l.get_environment();
+ if (env.do_on_the_fly_canonicalization())
// We are instructed to perform the "canonical type propagation"
// optimization, making 'r' to possibly get the canonical type of
// 'l' if it has one. This mostly means that we are currently
{
if (value == true
&& (is_type(&r)->priv_->depends_on_recursive_type()
- || env->priv_->is_recursive_type(&r))
+ || env.priv_->is_recursive_type(&r))
&& is_type(&r)->priv_->canonical_type_propagated()
&& !is_type(&r)->priv_->propagated_canonical_type_confirmed()
- && !env->priv_->right_type_comp_operands_.empty())
+ && !env.priv_->right_type_comp_operands_.empty())
{
// Track the object 'r' for which the propagated canonical
// type might be re-initialized if the current comparison
// eventually fails.
- env->priv_->add_to_types_with_non_confirmed_propagated_ct(is_type(&r));
+ env.priv_->add_to_types_with_non_confirmed_propagated_ct(is_type(&r));
}
- else if (value == true && env->priv_->right_type_comp_operands_.empty())
+ else if (value == true && env.priv_->right_type_comp_operands_.empty())
{
// The type provided in the 'r' argument is the type that is
// being canonicalized; 'r' is not a mere subtype being
// confirm the "canonical type propagation" of all the
// sub-types that were compared during the comparison of
// 'r'.
- env->priv_->confirm_ct_propagation(&r);
+ env.priv_->confirm_ct_propagation(&r);
}
else if (value == false)
{
// The comparison of the current sub-type failed. So all
// the types in
- // env->prix_->types_with_non_confirmed_propagated_ct_
+ // env.prix_->types_with_non_confirmed_propagated_ct_
// should see their tentatively propagated canonical type
// cancelled.
- env->priv_->cancel_ct_propagation(&r);
+ env.priv_->cancel_ct_propagation(&r);
}
}
// propagation can now see their tentative canonical type be
// confirmed for real.
if (value == true
- && env->priv_->right_type_comp_operands_.empty()
- && !env->priv_->types_with_non_confirmed_propagated_ct_.empty())
+ && env.priv_->right_type_comp_operands_.empty()
+ && !env.priv_->types_with_non_confirmed_propagated_ct_.empty())
// So the comparison is completely done and there are some
// types for which their propagated canonical type is sitll
// considered not confirmed. As the comparison did yield true, we
// shall now confirm the propagation for all those types.
- env->priv_->confirm_ct_propagation();
+ env.priv_->confirm_ct_propagation();
ABG_RETURN(value);
}
///
/// @param address_size the size of addresses in the translation unit,
/// in bits.
-translation_unit::translation_unit(const environment* env,
+translation_unit::translation_unit(const environment& env,
const std::string& path,
char address_size)
: priv_(new priv(env))
{
priv_->global_scope_.reset
(new global_scope(const_cast<translation_unit*>(this)));
- // The global scope must be out of the same environment as its
- // translation unit.
- priv_->global_scope_->
- set_environment(const_cast<environment*>(get_environment()));
priv_->global_scope_->set_translation_unit
(const_cast<translation_unit*>(this));
}
/// Getter of the environment of the current @ref translation_unit.
///
/// @return the translation unit of the current translation unit.
-const environment*
+const environment&
translation_unit::get_environment() const
{return priv_->env_;}
-/// Getter of the environment of the current @ref translation_unit.
-///
-/// @return the translation unit of the current translation unit.
-environment*
-translation_unit::get_environment()
-{return const_cast<environment*>(priv_->env_);}
-
-/// Setter of the environment of the current @ref translation_unit.
-///
-/// @param env the environment.
-void
-translation_unit::set_environment(const environment* env)
-{priv_->env_ = env;}
-
/// Getter of the language of the source code of the translation unit.
///
/// @return the language of the source code.
void
translation_unit::bind_function_type_life_time(function_type_sptr ftype) const
{
- const environment* env = get_environment();
- ABG_ASSERT(env);
+ const environment& env = get_environment();
const_cast<translation_unit*>(this)->priv_->live_fn_types_.push_back(ftype);
// The function type must be out of the same environment as its
// translation unit.
- if (const environment* e = ftype->get_environment())
- ABG_ASSERT(env == e);
- else
- ftype->set_environment(const_cast<environment*>(env));
+ {
+ const environment& e = ftype->get_environment();
+ ABG_ASSERT(&env == &e);
+ }
if (const translation_unit* existing_tu = ftype->get_translation_unit())
ABG_ASSERT(existing_tu == this);
// <elf_symbol stuff>
struct elf_symbol::priv
{
- const environment* env_;
+ const environment& env_;
size_t index_;
size_t size_;
string name_;
elf_symbol_wptr next_common_instance_;
string id_string_;
- priv()
- : env_(),
+ priv(const environment& e)
+ : env_(e),
index_(),
size_(),
type_(elf_symbol::NOTYPE_TYPE),
is_suppressed_(false)
{}
- priv(const environment* e,
+ priv(const environment& e,
size_t i,
size_t s,
const string& n,
}
}; // end struct elf_symbol::priv
-/// Default constructor of the @ref elf_symbol type.
-///
-/// Note that this constructor is private, so client code cannot use
-/// it to create instances of @ref elf_symbol. Rather, client code
-/// should use the @ref elf_symbol::create() function to create
-/// instances of @ref elf_symbol instead.
-elf_symbol::elf_symbol()
- : priv_(new priv)
-{}
-
/// Constructor of the @ref elf_symbol type.
///
/// Note that this constructor is private, so client code cannot use
/// @param crc the CRC (modversions) value of Linux Kernel symbols
///
/// @param ns the namespace of Linux Kernel symbols, if any
-elf_symbol::elf_symbol(const environment* e,
+elf_symbol::elf_symbol(const environment& e,
size_t i,
size_t s,
const string& n,
is_suppressed))
{}
-/// Factory of instances of @ref elf_symbol.
-///
-/// This is the function to use to create instances of @ref elf_symbol.
-///
-/// @return a (smart) pointer to a newly created instance of @ref
-/// elf_symbol.
-elf_symbol_sptr
-elf_symbol::create()
-{
- elf_symbol_sptr e(new elf_symbol());
- e->priv_->main_symbol_ = e;
- return e;
-}
-
/// Factory of instances of @ref elf_symbol.
///
/// This is the function to use to create instances of @ref elf_symbol.
/// @return a (smart) pointer to a newly created instance of @ref
/// elf_symbol.
elf_symbol_sptr
-elf_symbol::create(const environment* e,
+elf_symbol::create(const environment& e,
size_t i,
size_t s,
const string& n,
/// elf_symbol.
///
/// @return the enviroment used by the current instance of @ref elf_symbol.
-const environment*
+const environment&
elf_symbol::get_environment() const
{return priv_->env_;}
-/// Setter of the environment used by the current instance of @ref
-/// elf_symbol.
-///
-/// @param The new enviroment used by the current instance of @ref
-/// elf_symbol.
-void
-elf_symbol::set_environment(const environment* e) const
-{priv_->env_ = e;}
-
/// Getter for the index
///
/// @return the index of the symbol.
environment::get_void_type() const
{
if (!priv_->void_type_)
- priv_->void_type_.reset(new type_decl(const_cast<environment*>(this),
+ priv_->void_type_.reset(new type_decl(*this,
intern("void"),
0, 0, location()));
return priv_->void_type_;
{
if (!priv_->variadic_marker_type_)
priv_->variadic_marker_type_.
- reset(new type_decl(const_cast<environment*>(this),
+ reset(new type_decl(*this,
intern("variadic parameter type"),
0, 0, location()));
return priv_->variadic_marker_type_;
// hotspots, due to their use of dynamic_cast.
void* type_or_decl_ptr_;
bool hashing_started_;
- const environment* env_;
+ const environment& env_;
translation_unit* translation_unit_;
// The location of an artifact as seen from its input by the
// artifact reader. This might be different from the source
///
/// @param k the identifier of the runtime type of the current
/// instance of ABI artifact.
- priv(const environment* e = 0,
+ priv(const environment& e,
enum type_or_decl_kind k = ABSTRACT_TYPE_OR_DECL)
: kind_(k),
rtti_(),
return l;
}
-/// Default constructor of @ref type_or_decl_base.
-type_or_decl_base::type_or_decl_base()
- :priv_(new priv)
-{}
-
/// Constructor of @ref type_or_decl_base.
///
/// @param the environment the current ABI artifact is constructed
/// from.
///
/// @param k the runtime identifier bitmap of the type being built.
-type_or_decl_base::type_or_decl_base(const environment* e,
+type_or_decl_base::type_or_decl_base(const environment& e,
enum type_or_decl_kind k)
:priv_(new priv(e, k))
{}
-/// Copy constructor of @ref type_or_decl_base.
-type_or_decl_base::type_or_decl_base(const type_or_decl_base& o)
-{*priv_ = *o.priv_;}
-
/// The destructor of the @ref type_or_decl_base type.
type_or_decl_base::~type_or_decl_base()
{}
type_or_decl_base::hashing_started(bool b) const
{priv_->hashing_started_ = b;}
-/// Setter of the environment of the current ABI artifact.
-///
-/// This just sets the environment artifact of the current ABI
-/// artifact, not on its sub-trees. If you want to set the
-/// environment of an ABI artifact including its sub-tree, use the
-/// abigail::ir::set_environment_for_artifact() function.
-///
-/// @param env the new environment.
-void
-type_or_decl_base::set_environment(const environment* env)
-{priv_->env_ = env;}
-
/// Getter of the environment of the current ABI artifact.
///
/// @return the environment of the artifact.
-const environment*
+const environment&
type_or_decl_base::get_environment() const
{return priv_->env_;}
&& priv_->artificial_location_.get_is_artificial());
}
-/// Getter of the environment of the current ABI artifact.
-///
-/// @return the environment of the artifact.
-environment*
-type_or_decl_base::get_environment()
-{return const_cast<environment*>(priv_->env_);}
-
/// Get the @ref corpus this ABI artifact belongs to.
///
/// @return the corpus this ABI artifact belongs to, or nil if it
type_or_decl_base::get_translation_unit() const
{return const_cast<type_or_decl_base*>(this)->get_translation_unit();}
-/// Assignment operator for @ref type_or_decl_base.
-///
-/// @param o the other instance to assign the current instance to.
-///
-/// return a reference to the assigned instance of @ref
-/// type_or_decl_base.
-type_or_decl_base&
-type_or_decl_base::operator=(const type_or_decl_base& o)
-{
- *priv_ = *o.priv_;
- return *this;
-}
-
/// Traverse the the ABI artifact.
///
/// @param v the visitor used to traverse the sub-tree nodes of the
type_or_decl_base::traverse(ir_node_visitor&)
{return true;}
-/// Set the environment of a given ABI artifact, including recursively
-/// setting the environment on the sub-trees of the artifact.
-///
-/// @param artifact the artifact to set the environment for.
-///
-/// @param env the new environment.
-void
-set_environment_for_artifact(type_or_decl_base* artifact,
- const environment* env)
-{
- ABG_ASSERT(artifact && env);
-
- ::environment_setter s(env);
- artifact->traverse(s);
-}
-
-/// Set the environment of a given ABI artifact, including recursively
-/// setting the environment on the sub-trees of the artifact.
-///
-/// @param artifact the artifact to set the environment for.
-///
-/// @param env the new environment.
-void
-set_environment_for_artifact(type_or_decl_base_sptr artifact,
- const environment* env)
-{set_environment_for_artifact(artifact.get(), env);}
-
/// Non-member equality operator for the @type_or_decl_base type.
///
/// @param lr the left-hand operand of the equality.
/// @param linkage_name the linkage name of the declaration.
///
/// @param vis the visibility of the declaration.
-decl_base::decl_base(const environment* e,
+decl_base::decl_base(const environment& e,
const string& name,
const location& locus,
const string& linkage_name,
visibility vis)
: type_or_decl_base(e, ABSTRACT_DECL_BASE),
- priv_(new priv(e->intern(name), e->intern(linkage_name), vis))
+ priv_(new priv(e.intern(name), e.intern(linkage_name), vis))
{
set_location(locus);
}
/// constructed.
///
/// @param vis the visibility of the declaration being constructed.
-decl_base::decl_base(const environment* e,
+decl_base::decl_base(const environment& e,
const interned_string& name,
const location& locus,
const interned_string& linkage_name,
///
/// @param l the location where to find the declaration in the source
/// code.
-decl_base::decl_base(const environment* e, const location& l)
+decl_base::decl_base(const environment& e, const location& l)
: type_or_decl_base(e, ABSTRACT_DECL_BASE),
priv_(new priv())
{
set_location(l);
}
-decl_base::decl_base(const decl_base& d)
- : type_or_decl_base(d)
-{
- priv_->in_pub_sym_tab_ = d.priv_->in_pub_sym_tab_;
- priv_->location_ = d.priv_->location_;
- priv_->name_ = d.priv_->name_;
- priv_->qualified_parent_name_ = d.priv_->qualified_parent_name_;
- priv_->qualified_name_ = d.priv_->qualified_name_;
- priv_->linkage_name_ = d.priv_->linkage_name_;
- priv_->context_ = d.priv_->context_;
- priv_->visibility_ = d.priv_->visibility_;
-}
-
/// Getter for the qualified name.
///
/// Unlike decl_base::get_qualified_name() this doesn't try to update
void
decl_base::set_name(const string& n)
{
- priv_->name_ = get_environment()->intern(n);
+ priv_->name_ = get_environment().intern(n);
priv_->is_anonymous_ = n.empty();
}
priv_->naming_typedef_ = t;
set_name(t->get_name());
string qualified_name = build_qualified_name(get_scope(), t->get_name());
- set_qualified_name(get_environment()->intern(qualified_name));
+ set_qualified_name(get_environment().intern(qualified_name));
set_is_anonymous(false);
// Now that the qualified type of the decl has changed, let's update
// the qualified names of the member types of this decls.
void
decl_base::set_linkage_name(const string& m)
{
- const environment* env = get_environment();
- ABG_ASSERT(env);
- priv_->linkage_name_ = env->intern(m);
+ const environment& env = get_environment();
+ priv_->linkage_name_ = env.intern(m);
}
/// Getter for the visibility of the decl.
// other anymous types of the same kind.
string r;
r += get_generic_anonymous_internal_type_name(&d);
- return d.get_environment()->intern(r);
+ return d.get_environment().intern(r);
}
interned_string n = (is_anonymous_or_typedef_named(d)
return type;
}
- environment* env = type->get_environment();
- ABG_ASSERT(env);
+ const environment& env = type->get_environment();
type_base_sptr t = type;
if (const typedef_decl_sptr ty = is_typedef(t))
ty->get_alignment_in_bits()));
}
- if (!t->get_environment())
- set_environment_for_artifact(t, env);
-
if (!t->get_translation_unit())
t->set_translation_unit(type->get_translation_unit());
decl_base_sptr result = t;
type_base_sptr u = t->get_underlying_type();
- environment* env = t->get_environment();
+ const environment& env = t->get_environment();
if ((t->get_cv_quals() & qualified_type_def::CV_CONST
&& (is_reference_type(u)))
|| (t->get_cv_quals() & qualified_type_def::CV_CONST
- && env->is_void_type(u))
+ && env.is_void_type(u))
|| t->get_cv_quals() == qualified_type_def::CV_NONE)
// Let's strip the const qualifier because a reference is always
// 'const' and a const void doesn't make sense. They will just
/// @param locus the source location where the scope_decl is defined.
///
/// @param vis the visibility of the declaration.
-scope_decl::scope_decl(const environment* env,
+scope_decl::scope_decl(const environment& env,
const string& name,
const location& locus,
visibility vis)
/// @param l the source location where the scope_decl is defined.
///
/// @param vis the visibility of the declaration.
-scope_decl::scope_decl(const environment* env, location& l)
+scope_decl::scope_decl(const environment& env, location& l)
: type_or_decl_base(env, ABSTRACT_SCOPE_DECL|ABSTRACT_DECL_BASE),
decl_base(env, "", l),
priv_(new priv)
update_qualified_name(member);
- if (const environment* env = get_environment())
- set_environment_for_artifact(member, env);
-
if (translation_unit* tu = get_translation_unit())
{
if (translation_unit* existing_tu = member->get_translation_unit())
update_qualified_name(member);
- if (const environment* env = get_environment())
- set_environment_for_artifact(member, env);
-
if (translation_unit* tu = get_translation_unit())
{
if (translation_unit* existing_tu = member->get_translation_unit())
{
ABG_ASSERT(has_generic_anonymous_internal_type_name(d));
- const environment *env = d->get_environment();
+ const environment&env = d->get_environment();
interned_string result;
if (is_class_type(d))
result =
- env->intern(tools_utils::get_anonymous_struct_internal_name_prefix());
+ env.intern(tools_utils::get_anonymous_struct_internal_name_prefix());
else if (is_union_type(d))
result =
- env->intern(tools_utils::get_anonymous_union_internal_name_prefix());
+ env.intern(tools_utils::get_anonymous_union_internal_name_prefix());
else if (is_enum_type(d))
result =
- env->intern(tools_utils::get_anonymous_enum_internal_name_prefix());
+ env.intern(tools_utils::get_anonymous_enum_internal_name_prefix());
else
ABG_ASSERT_NOT_REACHED;
{
string r;
r += get_generic_anonymous_internal_type_name(d);
- return t->get_environment()->intern(r);
+ return t->get_environment().intern(r);
}
if (qualified)
return d->get_qualified_name(internal);
- const environment *env = d->get_environment();
- ABG_ASSERT(env);
- return env->intern(get_internal_integral_type_name(t));
+ const environment&env = d->get_environment();
+ return env.intern(get_internal_integral_type_name(t));
}
if (qualified)
get_name_of_pointer_to_type(const type_base& pointed_to_type,
bool qualified, bool internal)
{
- const environment* env = pointed_to_type.get_environment();
- ABG_ASSERT(env);
-
+ const environment& env = pointed_to_type.get_environment();
string tn = get_type_name(pointed_to_type, qualified, internal);
tn = tn + "*";
- return env->intern(tn);
+ return env.intern(tn);
}
/// Get the name of the reference to a given type.
bool lvalue_reference,
bool qualified, bool internal)
{
- const environment* env = pointed_to_type.get_environment();
- ABG_ASSERT(env);
+ const environment& env = pointed_to_type.get_environment();
string name = get_type_name(pointed_to_type, qualified, internal);
if (lvalue_reference)
else
name = name + "&&";
- return env->intern(name);
+ return env.intern(name);
}
/// Get the name of a qualified type, given the underlying type and
qualified_type_def::CV quals,
bool qualified, bool internal)
{
- const environment* env = underlying_type->get_environment();
- ABG_ASSERT(env);
+ const environment& env = underlying_type->get_environment();
string quals_repr = get_string_representation_of_cv_quals(quals);
string name = get_type_name(underlying_type, qualified, internal);
name = quals_repr + " " + name;
}
- return env->intern(name);
+ return env.intern(name);
}
/// Get the name of a given function type and return a copy of it.
internal
? peel_typedef_type(fn_type.get_return_type())
: fn_type.get_return_type();
- const environment* env = fn_type.get_environment();
- ABG_ASSERT(env);
+ const environment& env = fn_type.get_environment();
o << get_pretty_representation(return_type, internal);
}
o <<")";
- return env->intern(o.str());
+ return env.intern(o.str());
}
/// Get the name of a given method type and return a copy of it.
internal
? peel_typedef_type(fn_type.get_return_type())
: fn_type.get_return_type();
- const environment* env = fn_type.get_environment();
- ABG_ASSERT(env);
+ const environment& env = fn_type.get_environment();
if (return_type)
o << return_type->get_cached_pretty_representation(internal);
}
o <<")";
- return env->intern(o.str());
+ return env.intern(o.str());
}
/// Build and return a copy of the pretty representation of an ABI
// Look through typedefs in the pointed-to type as well.
type_base * ty = t->get_pointed_to_type().get();
ty = peel_qualified_or_typedef_type(ty);
- if (ty->get_environment()->is_void_type(ty))
+ if (ty->get_environment().is_void_type(ty))
return ty;
return 0;
type_decl_sptr
lookup_basic_type(const string& type_name, const translation_unit& tu)
{
- const environment* env = tu.get_environment();
- ABG_ASSERT(env);
+ const environment& env = tu.get_environment();
- interned_string s = env->intern(type_name);
+ interned_string s = env.intern(type_name);
return lookup_basic_type(s, tu);
}
class_decl_sptr
lookup_class_type(const string& fqn, const translation_unit& tu)
{
- const environment* env = tu.get_environment();
- ABG_ASSERT(env);
-
- interned_string s = env->intern(fqn);
+ const environment& env = tu.get_environment();
+ interned_string s = env.intern(fqn);
return lookup_class_type(s, tu);
}
union_decl_sptr
lookup_union_type(const string& fqn, const translation_unit& tu)
{
- const environment* env = tu.get_environment();
- ABG_ASSERT(env);
-
- interned_string s = env->intern(fqn);
+ const environment& env = tu.get_environment();
+ interned_string s = env.intern(fqn);
return lookup_union_type(s, tu);
}
union_decl_sptr
lookup_union_type_per_location(const string& loc, const corpus& corp)
{
- const environment* env = corp.get_environment();
- ABG_ASSERT(env);
-
- return lookup_union_type_per_location(env->intern(loc), corp);
+ const environment& env = corp.get_environment();
+ return lookup_union_type_per_location(env.intern(loc), corp);
}
/// Lookup an enum type from a translation unit.
enum_type_decl_sptr
lookup_enum_type(const string& type_name, const translation_unit& tu)
{
- const environment* env = tu.get_environment();
- ABG_ASSERT(env);
-
- interned_string s = env->intern(type_name);
+ const environment& env = tu.get_environment();
+ interned_string s = env.intern(type_name);
return lookup_enum_type(s, tu);
}
typedef_decl_sptr
lookup_typedef_type(const string& type_name, const translation_unit& tu)
{
- const environment* env = tu.get_environment();
- ABG_ASSERT(env);
-
- interned_string s = env->intern(type_name);
+ const environment& env = tu.get_environment();
+ interned_string s = env.intern(type_name);
return lookup_typedef_type(s, tu);
}
pointer_type_def_sptr
lookup_pointer_type(const string& type_name, const translation_unit& tu)
{
- const environment* env = tu.get_environment();
- ABG_ASSERT(env);
-
- interned_string s = env->intern(type_name);
+ const environment& env = tu.get_environment();
+ interned_string s = env.intern(type_name);
return lookup_pointer_type(s, tu);
}
type_base_sptr
lookup_type(const string& fqn, const translation_unit& tu)
{
- const environment *env = tu.get_environment();
- ABG_ASSERT(env);
- interned_string ifqn = env->intern(fqn);
+ const environment&env = tu.get_environment();
+ interned_string ifqn = env.intern(fqn);
return lookup_type(ifqn, tu);
}
type_decl_sptr
lookup_basic_type_per_location(const string &loc, const corpus &corp)
{
- const environment* env = corp.get_environment();
- ABG_ASSERT(env);
-
- return lookup_basic_type_per_location(env->intern(loc), corp);
+ const environment& env = corp.get_environment();
+ return lookup_basic_type_per_location(env.intern(loc), corp);
}
/// Look into a given corpus to find a basic type which has a given
type_decl_sptr
lookup_basic_type(const string& qualified_name, const corpus& corp)
{
- return lookup_basic_type(corp.get_environment()->intern(qualified_name),
+ return lookup_basic_type(corp.get_environment().intern(qualified_name),
corp);
}
class_decl_sptr
lookup_class_type(const string& qualified_name, const corpus& corp)
{
- interned_string s = corp.get_environment()->intern(qualified_name);
+ interned_string s = corp.get_environment().intern(qualified_name);
return lookup_class_type(s, corp);
}
const type_base_wptrs_type*
lookup_class_types(const string& qualified_name, const corpus& corp)
{
- interned_string s = corp.get_environment()->intern(qualified_name);
+ interned_string s = corp.get_environment().intern(qualified_name);
return lookup_class_types(s, corp);
}
class_decl_sptr
lookup_class_type_per_location(const string &loc, const corpus &corp)
{
- const environment* env = corp.get_environment();
- ABG_ASSERT(env);
-
- return lookup_class_type_per_location(env->intern(loc), corp);
+ const environment& env = corp.get_environment();
+ return lookup_class_type_per_location(env.intern(loc), corp);
}
/// Look into a given corpus to find a union type which has a given
union_decl_sptr
lookup_union_type(const string& type_name, const corpus& corp)
{
- interned_string s = corp.get_environment()->intern(type_name);
+ interned_string s = corp.get_environment().intern(type_name);
return lookup_union_type(s, corp);
}
enum_type_decl_sptr
lookup_enum_type(const string& qualified_name, const corpus& corp)
{
- interned_string s = corp.get_environment()->intern(qualified_name);
+ interned_string s = corp.get_environment().intern(qualified_name);
return lookup_enum_type(s, corp);
}
const type_base_wptrs_type*
lookup_enum_types(const string& qualified_name, const corpus& corp)
{
- interned_string s = corp.get_environment()->intern(qualified_name);
+ interned_string s = corp.get_environment().intern(qualified_name);
return lookup_enum_types(s, corp);
}
enum_type_decl_sptr
lookup_enum_type_per_location(const string &loc, const corpus &corp)
{
- const environment* env = corp.get_environment();
- ABG_ASSERT(env);
-
- return lookup_enum_type_per_location(env->intern(loc), corp);
+ const environment& env = corp.get_environment();
+ return lookup_enum_type_per_location(env.intern(loc), corp);
}
/// Look into a given corpus to find a typedef type which has the
typedef_decl_sptr
lookup_typedef_type(const string& qualified_name, const corpus& corp)
{
- interned_string s = corp.get_environment()->intern(qualified_name);
+ interned_string s = corp.get_environment().intern(qualified_name);
return lookup_typedef_type(s, corp);
}
typedef_decl_sptr
lookup_typedef_type_per_location(const string &loc, const corpus &corp)
{
- const environment* env = corp.get_environment();
- ABG_ASSERT(env);
-
- return lookup_typedef_type_per_location(env->intern(loc), corp);
+ const environment& env = corp.get_environment();
+ return lookup_typedef_type_per_location(env.intern(loc), corp);
}
/// Look into a corpus to find a class, union or typedef type which
else if (location l = type->get_location())
{
string str = l.expand();
- s = type->get_environment()->intern(str);
+ s = type->get_environment().intern(str);
}
istring_type_base_wptrs_map_type::iterator i = types_map.find(s);
if (use_type_name_as_key)
{
string qname = type->get_qualified_name();
- s = type->get_environment()->intern(qname);
+ s = type->get_environment().intern(qname);
}
else if (location l = type->get_location())
{
string str = l.expand();
- s = type->get_environment()->intern(str);
+ s = type->get_environment().intern(str);
}
bool result = false;
p->get_size_in_bits(),
p->get_alignment_in_bits(),
p->get_location()));
- result->set_environment(pointed_to_type->get_environment());
}
}
else if (reference_type_def_sptr r = is_reference_type(type))
r->get_size_in_bits(),
r->get_alignment_in_bits(),
r->get_location()));
- result->set_environment(pointed_to_type->get_environment());
}
}
else if (function_type_sptr f = is_function_type(type))
{
function_type_sptr nil = function_type_sptr();
- environment* env = tu.get_environment();
- ABG_ASSERT(env);
+ const environment& env = tu.get_environment();
type_base_sptr return_type = fn_type.get_return_type();
type_base_sptr result_return_type;
- if (!return_type || env->is_void_type(return_type))
- result_return_type = env->get_void_type();
+ if (!return_type || env.is_void_type(return_type))
+ result_return_type = env.get_void_type();
else
result_return_type = synthesize_type_from_translation_unit(return_type, tu);
if (!result_return_type)
fn_type.get_alignment_in_bits()));
tu.priv_->synthesized_types_.push_back(result_fn_type);
- // The new synthesized type must be in the same environment as its
- // translation unit.
- result_fn_type->set_environment(tu.get_environment());
tu.bind_function_type_life_time(result_fn_type);
canonicalize(result_fn_type);
///
/// @return either @p t if it is non-null, or the void type.
type_base_sptr
-type_or_void(const type_base_sptr t, const environment* env)
+type_or_void(const type_base_sptr t, const environment& env)
{
type_base_sptr r;
if (t)
r = t;
else
- {
- ABG_ASSERT(env);
- r = type_base_sptr(env->get_void_type());
- }
+ r = type_base_sptr(env.get_void_type());
return r;
}
{
if (c1->get_is_declaration_only() != c2->get_is_declaration_only())
{
- if (c1->get_environment()->decl_only_class_equals_definition())
+ if (c1->get_environment().decl_only_class_equals_definition())
// At least one of classes/union is declaration-only.
// Because we are in a context in which a declaration-only
// class/union is equal to all definitions of that
const type_base_sptr& candidate_type)
{
#ifdef WITH_DEBUG_TYPE_CANONICALIZATION
- environment *env = canonical_type->get_environment();
- if (env->debug_type_canonicalization_is_on())
+ const environment&env = canonical_type->get_environment();
+ if (env.debug_type_canonicalization_is_on())
{
bool canonical_equality = false, structural_equality = false;
- env->priv_->use_canonical_type_comparison_ = false;
+ env.priv_->use_canonical_type_comparison_ = false;
structural_equality = canonical_type == candidate_type;
- env->priv_->use_canonical_type_comparison_ = true;
+ env.priv_->use_canonical_type_comparison_ = true;
canonical_equality = canonical_type == candidate_type;
if (canonical_equality != structural_equality)
{
if (!t)
return t;
- environment* env = t->get_environment();
- ABG_ASSERT(env);
+ environment& env = const_cast<environment&>(t->get_environment());
if (is_non_canonicalized_type(t))
// This type should not be canonicalized!
// Look through decl-only types (classes, unions and enums)
bool decl_only_class_equals_definition =
- (odr_is_relevant(*t) || env->decl_only_class_equals_definition());
+ (odr_is_relevant(*t) || env.decl_only_class_equals_definition());
class_or_union_sptr class_or_union = is_class_or_union_type(t);
// type.
type_base_sptr canonical_type_present_in_corpus;
environment::canonical_types_map_type& types =
- env->get_canonical_types_map();
+ env.get_canonical_types_map();
type_base_sptr result;
environment::canonical_types_map_type::iterator i = types.find(repr);
// declaration-only struct S should be left alone and not
// resolved to any of the two definitions of struct S.
bool saved_decl_only_class_equals_definition =
- env->decl_only_class_equals_definition();
- env->do_on_the_fly_canonicalization(true);
+ env.decl_only_class_equals_definition();
+ env.do_on_the_fly_canonicalization(true);
// Compare types by considering that decl-only classes don't
// equal their definition.
- env->decl_only_class_equals_definition(false);
- env->priv_->allow_type_comparison_results_caching(true);
+ env.decl_only_class_equals_definition(false);
+ env.priv_->allow_type_comparison_results_caching(true);
bool equal = (types_defined_same_linux_kernel_corpus_public(**it, *t)
|| compare_types_during_canonicalization(*it, t));
// Restore the state of the on-the-fly-canonicalization and
// the decl-only-class-being-equal-to-a-matching-definition
// flags.
- env->priv_->allow_type_comparison_results_caching(false);
- env->do_on_the_fly_canonicalization(false);
- env->decl_only_class_equals_definition
+ env.priv_->allow_type_comparison_results_caching(false);
+ env.do_on_the_fly_canonicalization(false);
+ env.decl_only_class_equals_definition
(saved_decl_only_class_equals_definition);
if (equal)
{
}
}
#ifdef WITH_DEBUG_SELF_COMPARISON
- if (env->self_comparison_debug_is_on())
+ if (env.self_comparison_debug_is_on())
{
// So we are debugging the canonicalization process,
// possibly via the use of 'abidw --debug-abidiff <binary>'.
corpus_sptr corp1, corp2;
- env->get_self_comparison_debug_inputs(corp1, corp2);
+ env.get_self_comparison_debug_inputs(corp1, corp2);
if (corp1 && corp2 && t->get_corpus() == corp2.get())
{
// If 't' comes from the second corpus, then it *must*
// have canonical types coming from the first corpus.
if (result)
{
- if (!env->priv_->
+ if (!env.priv_->
check_canonical_type_from_abixml_during_self_comp(t,
result))
// The canonical type of the type re-read from abixml
else //!result
{
uintptr_t ptr_val = reinterpret_cast<uintptr_t>(t.get());
- string type_id = env->get_type_id_from_pointer(ptr_val);
+ string type_id = env.get_type_id_from_pointer(ptr_val);
if (type_id.empty())
type_id = "type-id-<not-found>";
// We are in the case where 't' is different from all
/// @param s the size of the type, in bits.
///
/// @param a the alignment of the type, in bits.
-type_base::type_base(const environment* e, size_t s, size_t a)
+type_base::type_base(const environment& e, size_t s, size_t a)
: type_or_decl_base(e, ABSTRACT_TYPE_BASE|ABSTRACT_TYPE_BASE),
priv_(new priv(s, a))
{}
if (!get_naked_canonical_type() || priv_->internal_cached_repr_.empty())
{
string r = ir::get_pretty_representation(this, internal);
- priv_->internal_cached_repr_ = get_environment()->intern(r);
+ priv_->internal_cached_repr_ = get_environment().intern(r);
}
return priv_->internal_cached_repr_;
}
if (!get_naked_canonical_type() || priv_->cached_repr_.empty())
{
string r = ir::get_pretty_representation(this, internal);
- priv_->cached_repr_ = get_environment()->intern(r);
+ priv_->cached_repr_ = get_environment().intern(r);
}
return priv_->cached_repr_;
/// @param linkage_name the linkage_name of the current type declaration.
///
/// @param vis the visibility of the type declaration.
-type_decl::type_decl(const environment* env,
+type_decl::type_decl(const environment& env,
const string& name,
size_t size_in_bits,
size_t alignment_in_bits,
const interned_string&
type_decl::get_qualified_name(bool internal) const
{
- const environment* env = get_environment();
- ABG_ASSERT(env);
+ const environment& env = get_environment();
+
if (internal)
if (is_integral_type(this))
{
if (decl_base::priv_->internal_qualified_name_.empty())
decl_base::priv_->internal_qualified_name_ =
- env->intern(get_internal_integral_type_name(this));
+ env.intern(get_internal_integral_type_name(this));
return decl_base::priv_->internal_qualified_name_;
}
else
{
decl_base::priv_->temporary_internal_qualified_name_ =
- env->intern(get_internal_integral_type_name(this));
+ env.intern(get_internal_integral_type_name(this));
return decl_base::priv_->temporary_internal_qualified_name_;
}
}
/// @param locus the source location where the type is defined.
///
/// @param vis the visibility of the type.
-scope_type_decl::scope_type_decl(const environment* env,
+scope_type_decl::scope_type_decl(const environment& env,
const string& name,
size_t size_in_bits,
size_t alignment_in_bits,
/// @param locus the source location where the namespace is defined.
///
/// @param vis the visibility of the namespace.
-namespace_decl::namespace_decl(const environment* env,
+namespace_decl::namespace_decl(const environment& env,
const string& name,
const location& locus,
visibility vis)
// especially during the construction of the type, while the
// underlying type is not yet constructed. In that case, let's do
// like if the underlying type is the 'void' type.
- t = get_environment()->get_void_type();
+ t = get_environment().get_void_type();
return get_name_of_qualified_type(t, get_cv_quals(),
fully_qualified,
priv_(new priv(quals, type))
{
runtime_type_instance(this);
- interned_string name = type->get_environment()->intern(build_name(false));
+ interned_string name = type->get_environment().intern(build_name(false));
set_name(name);
}
/// @param quals a bitfield representing the const/volatile qualifiers
///
/// @param locus the location of the qualified type definition
-qualified_type_def::qualified_type_def(environment* env,
+qualified_type_def::qualified_type_def(const environment& env,
CV quals,
const location& locus)
: type_or_decl_base(env,
runtime_type_instance(this);
// We don't yet have an underlying type. So for naming purpose,
// let's temporarily pretend the underlying type is 'void'.
- interned_string name = env->intern("void");
+ interned_string name = env.intern("void");
set_name(name);
}
const interned_string&
qualified_type_def::get_qualified_name(bool internal) const
{
- const environment* env = get_environment();
- ABG_ASSERT(env);
+ const environment& env = get_environment();
+
if (!get_canonical_type())
{
// Lets compute it and return a reference to where it's
// stored.
priv_->temporary_internal_name_ =
- env->intern(build_name(true, /*internal=*/true));
+ env.intern(build_name(true, /*internal=*/true));
return priv_->temporary_internal_name_;
}
else
{
// We are asked to return a temporary non-internal name.
set_temporary_qualified_name
- (env->intern(build_name(true, /*internal=*/false)));
+ (env.intern(build_name(true, /*internal=*/false)));
return peek_temporary_qualified_name();
}
}
{
if (priv_->internal_name_.empty())
priv_->internal_name_ =
- env->intern(build_name(/*qualified=*/true,
+ env.intern(build_name(/*qualified=*/true,
/*internal=*/true));
return priv_->internal_name_;
}
{
if (peek_qualified_name().empty())
set_qualified_name
- (env->intern(build_name(/*qualified=*/true,
+ (env.intern(build_name(/*qualified=*/true,
/*internal=*/false)));
return peek_qualified_name();
}
// Now we need to update other properties that depend on the new underlying type.
set_size_in_bits(t->get_size_in_bits());
set_alignment_in_bits(t->get_alignment_in_bits());
- interned_string name = get_environment()->intern(build_name(false));
+ interned_string name = get_environment().intern(build_name(false));
set_name(name);
if (scope_decl* s = get_scope())
{
interned_string temp_internal_qualified_name_;
priv(const type_base_sptr& t)
- : pointed_to_type_(type_or_void(t, 0)),
+ : pointed_to_type_(type_or_void(t, t->get_environment())),
naked_pointed_to_type_(t.get())
{}
try
{
ABG_ASSERT(pointed_to);
- const environment* env = pointed_to->get_environment();
+ const environment& env = pointed_to->get_environment();
decl_base_sptr pto = dynamic_pointer_cast<decl_base>(pointed_to);
string name = (pto ? pto->get_name() : string("void")) + "*";
- set_name(env->intern(name));
+ set_name(env.intern(name));
if (pto)
set_visibility(pto->get_visibility());
}
/// @param align_in_bits the alignment of the type, in bits.
///
/// @param locus the source location where the type was defined.
-pointer_type_def::pointer_type_def(environment* env, size_t size_in_bits,
+pointer_type_def::pointer_type_def(const environment& env, size_t size_in_bits,
size_t alignment_in_bits,
const location& locus)
: type_or_decl_base(env,
{
runtime_type_instance(this);
string name = string("void") + "*";
- set_name(env->intern(name));
+ set_name(env.intern(name));
}
/// Set the pointed-to type of the pointer.
try
{
- const environment* env = t->get_environment();
- ABG_ASSERT(get_environment() == env);
+ const environment& env = t->get_environment();
decl_base_sptr pto = dynamic_pointer_cast<decl_base>(t);
string name = (pto ? pto->get_name() : string("void")) + "*";
- set_name(env->intern(name));
+ set_name(env.intern(name));
if (pto)
set_visibility(pto->get_visibility());
}
if (!is_lvalue())
name += "&";
- environment* env = pointed_to->get_environment();
- ABG_ASSERT(env);
- set_name(env->intern(name));
+ const environment& env = pointed_to->get_environment();
+ set_name(env.intern(name));
- pointed_to_type_ = type_base_wptr(type_or_void(pointed_to, 0));
+ pointed_to_type_ =
+ type_base_wptr(type_or_void(pointed_to,
+ pointed_to->get_environment()));
}
catch (...)
{}
/// @param align_in_bits the alignment of the type, in bits.
///
/// @param locus the source location of the type.
-reference_type_def::reference_type_def(const environment* env, bool lvalue,
+reference_type_def::reference_type_def(const environment& env, bool lvalue,
size_t size_in_bits,
size_t alignment_in_bits,
const location& locus)
string name = "void&";
if (!is_lvalue())
name += "&";
- ABG_ASSERT(env);
- set_name(env->intern(name));
- pointed_to_type_ = type_base_wptr(env->get_void_type());
+
+ set_name(env.intern(name));
+ pointed_to_type_ = type_base_wptr(env.get_void_type());
}
/// Setter of the pointed_to type of the current reference type.
string name = string(pto->get_name()) + "&";
if (!is_lvalue())
name += "&";
- environment* env = pto->get_environment();
- ABG_ASSERT(env && env == get_environment());
- set_name(env->intern(name));
+ const environment& env = pto->get_environment();
+ set_name(env.intern(name));
}
}
/// @param underlying_type the underlying type of the subrange type.
///
/// @param loc the source location where the type is defined.
-array_type_def::subrange_type::subrange_type(const environment* env,
+array_type_def::subrange_type::subrange_type(const environment& env,
const string& name,
bound_value lower_bound,
bound_value upper_bound,
/// @param loc the source location where the type is defined.
///
/// @param l the language that generated this subrange.
-array_type_def::subrange_type::subrange_type(const environment* env,
+array_type_def::subrange_type::subrange_type(const environment& env,
const string& name,
bound_value lower_bound,
bound_value upper_bound,
/// @param loc the source location of the type.
///
/// @param the language that generated this type.
-array_type_def::subrange_type::subrange_type(const environment* env,
+array_type_def::subrange_type::subrange_type(const environment& env,
const string& name,
bound_value upper_bound,
const location& loc,
/// @param subs a vector of the array's subranges(dimensions)
///
/// @param locus the source location of the array type definition.
-array_type_def::array_type_def(environment* env,
+array_type_def::array_type_def(const environment& env,
const std::vector<subrange_sptr>& subs,
const location& locus)
: type_or_decl_base(env,
{
for (const auto &sub : get_subranges())
s *= sub->get_length();
-
- const environment* env = e->get_environment();
- ABG_ASSERT(env);
set_size_in_bits(s);
}
set_alignment_in_bits(e->get_alignment_in_bits());
{
priv_->element_type_ = element_type;
update_size();
- set_name(get_environment()->intern(get_pretty_representation()));
+ set_name(get_environment().intern(get_pretty_representation()));
}
/// Append subranges from the vector @param subs to the current
priv_->subranges_.push_back(sub);
update_size();
- set_name(get_environment()->intern(get_pretty_representation()));
+ set_name(get_environment().intern(get_pretty_representation()));
}
/// @return true if one of the sub-ranges of the array is infinite, or
const interned_string&
array_type_def::get_qualified_name(bool internal) const
{
- const environment* env = get_environment();
- ABG_ASSERT(env);
+ const environment& env = get_environment();
+
if (internal)
{
{
if (priv_->internal_qualified_name_.empty())
priv_->internal_qualified_name_ =
- env->intern(get_type_representation(*this, /*internal=*/true));
+ env.intern(get_type_representation(*this, /*internal=*/true));
return priv_->internal_qualified_name_;
}
else
{
priv_->temp_internal_qualified_name_ =
- env->intern(get_type_representation(*this, /*internal=*/true));
+ env.intern(get_type_representation(*this, /*internal=*/true));
return priv_->temp_internal_qualified_name_;
}
}
if (get_canonical_type())
{
if (decl_base::peek_qualified_name().empty())
- set_qualified_name(env->intern(get_type_representation
+ set_qualified_name(env.intern(get_type_representation
(*this, /*internal=*/false)));
return decl_base::peek_qualified_name();
}
else
{
- set_temporary_qualified_name(env->intern(get_type_representation
+ set_temporary_qualified_name(env.intern(get_type_representation
(*this,
/*internal=*/false)));
return decl_base::peek_temporary_qualified_name();
}
enum_type_decl &local_r = const_cast<enum_type_decl&>(r);
- interned_string qn_r = l.get_environment()->intern(r.get_qualified_name());
- interned_string qn_l = l.get_environment()->intern(l.get_qualified_name());
+ interned_string qn_r = l.get_environment().intern(r.get_qualified_name());
+ interned_string qn_l = l.get_environment().intern(l.get_qualified_name());
string n_l = l.get_name();
string n_r = r.get_name();
local_r.set_qualified_name(qn_l);
/// enum_type_decl::enumerator.
class enum_type_decl::enumerator::priv
{
- const environment* env_;
- interned_string name_;
+ string name_;
int64_t value_;
- interned_string qualified_name_;
+ string qualified_name_;
enum_type_decl* enum_type_;
friend class enum_type_decl::enumerator;
public:
priv()
- : env_(),
- enum_type_()
+ : enum_type_()
{}
- priv(const environment* env,
- const string& name,
+ priv(const string& name,
int64_t value,
enum_type_decl* e = 0)
- : env_(env),
- name_(env ? env->intern(name) : interned_string()),
+ : name_(name),
value_(value),
enum_type_(e)
{}
enum_type_decl::enumerator::~enumerator() = default;
-
/// Constructor of the @ref enum_type_decl::enumerator type.
///
/// @param env the environment we are operating from.
/// @param name the name of the enumerator.
///
/// @param value the value of the enumerator.
-enum_type_decl::enumerator::enumerator(const environment* env,
- const string& name,
+enum_type_decl::enumerator::enumerator(const string& name,
int64_t value)
- : priv_(new priv(env, name, value))
+ : priv_(new priv(name, value))
{}
/// Copy constructor of the @ref enum_type_decl::enumerator type.
///
/// @param other enumerator to copy.
enum_type_decl::enumerator::enumerator(const enumerator& other)
- : priv_(new priv(other.get_environment(),
- other.get_name(),
+ : priv_(new priv(other.get_name(),
other.get_value(),
other.get_enum_type()))
{}
enum_type_decl::enumerator&
enum_type_decl::enumerator::operator=(const enumerator& o)
{
- priv_->env_ = o.get_environment();
priv_->name_ = o.get_name();
priv_->value_ = o.get_value();
priv_->enum_type_ = o.get_enum_type();
return *this;
}
+
/// Equality operator
///
/// @param other the enumerator to compare to the current
enum_type_decl::enumerator::operator!=(const enumerator& other) const
{return !operator==(other);}
-/// Getter of the environment of this enumerator.
-///
-/// @return the environment of this enumerator.
-const environment*
-enum_type_decl::enumerator::get_environment() const
-{return priv_->env_;}
-
/// Getter for the name of the current instance of
/// enum_type_decl::enumerator.
///
/// @return a reference to the name of the current instance of
/// enum_type_decl::enumerator.
-const interned_string&
+const string&
enum_type_decl::enumerator::get_name() const
{return priv_->name_;}
///
/// @return the qualified name of the current instance of
/// enum_type_decl::enumerator.
-const interned_string&
+const string&
enum_type_decl::enumerator::get_qualified_name(bool internal) const
{
if (priv_->qualified_name_.empty())
{
- const environment* env = priv_->enum_type_->get_environment();
- ABG_ASSERT(env);
priv_->qualified_name_ =
- env->intern(get_enum_type()->get_qualified_name(internal)
- + "::"
- + get_name());
+ get_enum_type()->get_qualified_name(internal)
+ + "::"
+ + get_name();
}
return priv_->qualified_name_;
}
/// @param n the new name.
void
enum_type_decl::enumerator::set_name(const string& n)
-{
- const environment* env = get_environment();
- ABG_ASSERT(env);
- priv_->name_ = env->intern(n);
-}
+{priv_->name_ = n;}
/// Getter for the value of @ref enum_type_decl::enumerator.
///
///
/// @param vis the visibility of the typedef type.
typedef_decl::typedef_decl(const string& name,
- environment* env,
+ const environment& env,
const location& locus,
const string& mangled_name,
visibility vis)
priv_->symbol_ = sym;
// The variable id cache that depends on the symbol must be
// invalidated because the symbol changed.
- priv_->id_ = get_environment()->intern("");
+ priv_->id_ = get_environment().intern("");
}
/// Gets the the underlying ELF symbol for the current variable,
// The variables have underlying elf symbols that are equal, so
// now, let's compare the decl_base part of the variables w/o
// considering their decl names.
- const environment* env = l.get_environment();
+ const environment& env = l.get_environment();
const interned_string n1 = l.get_qualified_name(), n2 = r.get_qualified_name();
- const_cast<var_decl&>(l).set_qualified_name(env->intern(""));
- const_cast<var_decl&>(r).set_qualified_name(env->intern(""));
+ const_cast<var_decl&>(l).set_qualified_name(env.intern(""));
+ const_cast<var_decl&>(r).set_qualified_name(env.intern(""));
bool decl_bases_different = !l.decl_base::operator==(r);
const_cast<var_decl&>(l).set_qualified_name(n1);
const_cast<var_decl&>(r).set_qualified_name(n2);
sym_str = s->get_id_string();
else if (!get_linkage_name().empty())
sym_str = get_linkage_name();
- const environment* env = get_type()->get_environment();
- ABG_ASSERT(env);
- priv_->id_ = env->intern(repr);
+
+ const environment& env = get_type()->get_environment();
+ priv_->id_ = env.intern(repr);
if (!sym_str.empty())
- priv_->id_ = env->intern(priv_->id_ + "{" + sym_str + "}");
+ priv_->id_ = env.intern(priv_->id_ + "{" + sym_str + "}");
}
return priv_->id_;
}
{
// Display the anonymous data member in a way that makes sense.
string r = get_pretty_representation(internal);
- set_qualified_name(get_environment()->intern(r));
+ set_qualified_name(get_environment().intern(r));
}
return decl_base::get_qualified_name(internal);
/// @param size_in_bits the size of this type, in bits.
///
/// @param alignment_in_bits the alignment of this type, in bits.
-function_type::function_type(const environment* env,
+function_type::function_type(const environment& env,
size_t size_in_bits,
size_t alignment_in_bits)
: type_or_decl_base(env, FUNCTION_TYPE | ABSTRACT_TYPE_BASE),
// comparison has been cached, let's just re-use it, rather than
// comparing them all over again.
bool cached_result = false;
- if (l.get_environment()->priv_->is_type_comparison_cached(l, r,
+ if (l.get_environment().priv_->is_type_comparison_cached(l, r,
cached_result))
return cached_result;
}
// perform this caching also on the earlier return points of this
// function. That would basically mean to redefine the RETURN macro
// to make it perform this caching for us.
- l.get_environment()->priv_->cache_type_comparison_result(l, r, result);
+ l.get_environment().priv_->cache_type_comparison_result(l, r, result);
RETURN(result);
#undef RETURN
/// @param size_in_bits the size of the type, expressed in bits.
///
/// @param alignment_in_bits the alignment of the type, expressed in bits
-method_type::method_type(const environment* env,
+method_type::method_type(const environment& env,
size_t size_in_bits,
size_t alignment_in_bits)
: type_or_decl_base(env, METHOD_TYPE | ABSTRACT_TYPE_BASE | FUNCTION_TYPE),
if (parm.get() != first_parm.get())
result += ", ";
if (parm->get_variadic_marker()
- || get_environment()->is_variadic_parameter_type(parm->get_type()))
+ || get_environment().is_variadic_parameter_type(parm->get_type()))
result += "...";
else
{
priv_->symbol_ = sym;
// The function id cache that depends on the symbol must be
// invalidated because the symbol changed.
- priv_->id_ = get_environment()->intern("");
+ priv_->id_ = get_environment().intern("");
}
/// Gets the the underlying ELF symbol for the current variable,
{
if (priv_->id_.empty())
{
- const environment* env = get_type()->get_environment();
+ const environment& env = get_type()->get_environment();
if (elf_symbol_sptr s = get_symbol())
{
if (s->has_aliases())
// The symbol has several aliases, so let's use a scheme
// that allows all aliased functions to have different
// IDs.
- priv_->id_ = env->intern(get_name() + "/" + s->get_id_string());
+ priv_->id_ = env.intern(get_name() + "/" + s->get_id_string());
else
// Let's use the full symbol name with its version as ID.
- priv_->id_ = env->intern(s->get_id_string());
+ priv_->id_ = env.intern(s->get_id_string());
}
else if (!get_linkage_name().empty())
- priv_->id_= env->intern(get_linkage_name());
+ priv_->id_= env.intern(get_linkage_name());
else
- priv_->id_ = env->intern(get_pretty_representation());
+ priv_->id_ = env.intern(get_pretty_representation());
}
return priv_->id_;
}
interned_string
function_decl::parameter::get_type_name() const
{
- const environment* env = get_environment();
- ABG_ASSERT(env);
+ const environment& env = get_environment();
type_base_sptr t = get_type();
string str;
- if (get_variadic_marker() || env->is_variadic_parameter_type(t))
+ if (get_variadic_marker() || env.is_variadic_parameter_type(t))
str = "...";
else
{
ABG_ASSERT(t);
str = abigail::ir::get_type_name(t);
}
- return env->intern(str);
+ return env.intern(str);
}
/// @return a copy of the pretty representation of the type of the
type_base_sptr t = get_type();
string str;
if (get_variadic_marker()
- || get_environment()->is_variadic_parameter_type(t))
+ || get_environment().is_variadic_parameter_type(t))
str = "...";
else
{
interned_string
function_decl::parameter::get_name_id() const
{
- const environment* env = get_environment();
- ABG_ASSERT(env);
+ const environment& env = get_environment();
+
std::ostringstream o;
o << "parameter-" << get_index();
- return env->intern(o.str());
+ return env.intern(o.str());
}
unsigned
function_decl::parameter::get_pretty_representation(bool internal,
bool /*qualified_name*/) const
{
- const environment* env = get_environment();
- ABG_ASSERT(env);
+ const environment& env = get_environment();
string type_repr;
type_base_sptr t = get_type();
if (!t)
type_repr = "void";
- else if (env->is_variadic_parameter_type(t))
+ else if (env.is_variadic_parameter_type(t))
type_repr = "...";
else
type_repr = ir::get_pretty_representation(t, internal);
///
/// @param member_fns the vector of member functions of this instance
/// of @ref class_or_union.
-class_or_union::class_or_union(const environment* env, const string& name,
+class_or_union::class_or_union(const environment& env, const string& name,
size_t size_in_bits, size_t align_in_bits,
const location& locus, visibility vis,
member_types& mem_types,
/// @param locus the source location of declaration point this class.
///
/// @param vis the visibility of instances of @ref class_or_union.
-class_or_union::class_or_union(const environment* env, const string& name,
+class_or_union::class_or_union(const environment& env, const string& name,
size_t size_in_bits, size_t align_in_bits,
const location& locus, visibility vis)
: type_or_decl_base(env,
///
/// @param is_declaration_only a boolean saying whether the instance
/// represents a declaration only, or not.
-class_or_union::class_or_union(const environment* env, const string& name,
+class_or_union::class_or_union(const environment& env, const string& name,
bool is_declaration_only)
: type_or_decl_base(env,
ABSTRACT_TYPE_BASE
/// classes of interest are being compared.
void
dump_classes_being_compared(const type_or_decl_base& c)
-{c.get_environment()->priv_->dump_classes_being_compared();}
+{c.get_environment().priv_->dump_classes_being_compared();}
/// Dumps a textual representation (to the standard error output) of
/// the content of the set of function types being currently compared
/// function types of interest are being compared.
void
dump_fn_types_being_compared(const type_or_decl_base& t)
-{t.get_environment()->priv_->dump_fn_types_being_compared();}
+{t.get_environment().priv_->dump_fn_types_being_compared();}
/// Compares two instances of @ref class_or_union.
///
// change.
return true;
- if ((l.get_environment()->decl_only_class_equals_definition()
+ if ((l.get_environment().decl_only_class_equals_definition()
|| ((odr_is_relevant(l) && !def1)
|| (odr_is_relevant(r) && !def2)))
&& !is_anonymous_or_typedef_named(l)
old_type->get_is_const(),
old_type->get_size_in_bits(),
old_type->get_alignment_in_bits()));
- new_type->set_environment(t->get_environment());
keep_type_alive(new_type);
method_decl_sptr
maybe_propagate_canonical_type(const type_base& lhs_type,
const type_base& rhs_type)
{
+ const environment& env = lhs_type.get_environment();
#if WITH_DEBUG_TYPE_CANONICALIZATION
- if (const environment *env = lhs_type.get_environment())
- if (!env->priv_->use_canonical_type_comparison_)
- return false;
+ if (!env.priv_->use_canonical_type_comparison_)
+ return false;
#endif
- if (const environment *env = lhs_type.get_environment())
- if (env->do_on_the_fly_canonicalization())
- if (type_base_sptr canonical_type = lhs_type.get_canonical_type())
- if (!rhs_type.get_canonical_type())
- if (env->priv_->propagate_ct(lhs_type, rhs_type))
- return true;
+ if (env.do_on_the_fly_canonicalization())
+ if (type_base_sptr canonical_type = lhs_type.get_canonical_type())
+ if (!rhs_type.get_canonical_type())
+ if (env.priv_->propagate_ct(lhs_type, rhs_type))
+ return true;
return false;
}
///
/// @param mbr_fns the vector of member functions of this instance of
/// class_decl.
-class_decl::class_decl(const environment* env, const string& name,
+class_decl::class_decl(const environment& env, const string& name,
size_t size_in_bits, size_t align_in_bits,
bool is_struct, const location& locus,
visibility vis, base_specs& bases,
///
/// @param is_anonymous whether the newly created instance is
/// anonymous.
-class_decl::class_decl(const environment* env, const string& name,
+class_decl::class_decl(const environment& env, const string& name,
size_t size_in_bits, size_t align_in_bits,
bool is_struct, const location& locus,
visibility vis, base_specs& bases,
/// @param locus the source location of declaration point this class.
///
/// @param vis the visibility of instances of class_decl.
-class_decl::class_decl(const environment* env, const string& name,
+class_decl::class_decl(const environment& env, const string& name,
size_t size_in_bits, size_t align_in_bits,
bool is_struct, const location& locus,
visibility vis)
///
/// @param is_anonymous whether the newly created instance is
/// anonymous.
-class_decl:: class_decl(const environment* env, const string& name,
+class_decl:: class_decl(const environment& env, const string& name,
size_t size_in_bits, size_t align_in_bits,
bool is_struct, const location& locus,
visibility vis, bool is_anonymous)
///
/// @param is_declaration_only a boolean saying whether the instance
/// represents a declaration only, or not.
-class_decl::class_decl(const environment* env, const string& name,
+class_decl::class_decl(const environment& env, const string& name,
bool is_struct, bool is_declaration_only)
: type_or_decl_base(env,
CLASS_TYPE
void
class_decl::add_base_specifier(base_spec_sptr b)
{
- ABG_ASSERT(get_environment());
- ABG_ASSERT(b->get_environment() == get_environment());
priv_->bases_.push_back(b);
priv_->bases_map_[b->get_base_class()->get_qualified_name()] = b;
- if (const environment* env = get_environment())
- b->set_environment(env);
}
/// Get the base specifiers for this class.
static bool
maybe_cancel_propagated_canonical_type(const class_or_union& t)
{
- const environment* env = t.get_environment();
- if (env && env->do_on_the_fly_canonicalization())
+ const environment& env = t.get_environment();
+ if (env.do_on_the_fly_canonicalization())
if (is_type(&t)->priv_->canonical_type_propagated())
{
is_type(&t)->priv_->clear_propagated_canonical_type();
- env->priv_->remove_from_types_with_non_confirmed_propagated_ct(&t);
+ env.priv_->remove_from_types_with_non_confirmed_propagated_ct(&t);
return true;
}
return false;
// cached, let's just re-use it, rather than comparing them all
// over again.
bool result = false;
- if (l.get_environment()->priv_->is_type_comparison_cached(l, r, result))
+ if (l.get_environment().priv_->is_type_comparison_cached(l, r, result))
return result;
}
// perform this caching also on the earlier return points of this
// function. That would basically mean to redefine the RETURN macro
// to make it perform this caching for us.
- l.get_environment()->priv_->cache_type_comparison_result(l, r, result);
+ l.get_environment().priv_->cache_type_comparison_result(l, r, result);
RETURN(result);
#undef RETURN
/// @param data_mbrs the data members of the union.
///
/// @param member_fns the member functions of the union.
-union_decl::union_decl(const environment* env, const string& name,
+union_decl::union_decl(const environment& env, const string& name,
size_t size_in_bits, const location& locus,
visibility vis, member_types& mbr_types,
data_members& data_mbrs, member_functions& member_fns)
///
/// @param is_anonymous whether the newly created instance is
/// anonymous.
-union_decl::union_decl(const environment* env, const string& name,
+union_decl::union_decl(const environment& env, const string& name,
size_t size_in_bits, const location& locus,
visibility vis, member_types& mbr_types,
data_members& data_mbrs, member_functions& member_fns,
/// @param locus the location of the type.
///
/// @param vis the visibility of instances of @ref union_decl.
-union_decl::union_decl(const environment* env, const string& name,
+union_decl::union_decl(const environment& env, const string& name,
size_t size_in_bits, const location& locus,
visibility vis)
: type_or_decl_base(env,
///
/// @param is_anonymous whether the newly created instance is
/// anonymous.
-union_decl::union_decl(const environment* env, const string& name,
+union_decl::union_decl(const environment& env, const string& name,
size_t size_in_bits, const location& locus,
visibility vis, bool is_anonymous)
: type_or_decl_base(env,
///
/// @param is_declaration_only a boolean saying whether the instance
/// represents a declaration only, or not.
-union_decl::union_decl(const environment* env,
+union_decl::union_decl(const environment& env,
const string& name,
bool is_declaration_only)
: type_or_decl_base(env,
// cached, let's just re-use it, rather than comparing them all
// over again.
bool result = false;
- if (l.get_environment()->priv_->is_type_comparison_cached(l, r, result))
+ if (l.get_environment().priv_->is_type_comparison_cached(l, r, result))
return result;
}
// perform this caching also on the earlier return points of this
// function. That would basically mean to redefine the RETURN macro
// to make it perform this caching for us.
- l.get_environment()->priv_->cache_type_comparison_result(l, r, result);
+ l.get_environment().priv_->cache_type_comparison_result(l, r, result);
RETURN(result);
}
/// defined.
///
/// @param vis the visibility of the template declaration.
-template_decl::template_decl(const environment* env,
+template_decl::template_decl(const environment& env,
const string& name,
const location& locus,
visibility vis)
///
/// @param bind the binding of the declaration. This is the binding
/// the functions instantiated from this template are going to have.
-function_tdecl::function_tdecl(const environment* env,
+function_tdecl::function_tdecl(const environment& env,
const location& locus,
visibility vis,
binding bind)
///
/// @param vis the visibility of the instance of class instantiated
/// from this template.
-class_tdecl::class_tdecl(const environment* env,
+class_tdecl::class_tdecl(const environment& env,
const location& locus,
visibility vis)
: type_or_decl_base(env,
void
keep_type_alive(type_base_sptr t)
{
- environment* env = t->get_environment();
- ABG_ASSERT(env);
- env->priv_->extra_live_types_.push_back(t);
+ const environment& env = t->get_environment();
+ env.priv_->extra_live_types_.push_back(t);
}
/// Hash an ABI artifact that is either a type or a decl.
if (!t)
return true;
- const environment* env = t->get_environment();
+ const environment& env = t->get_environment();
return (is_declaration_only_class_or_union_type(t)
- || env->is_void_type(t)
- || env->is_variadic_parameter_type(t));
+ || env.is_void_type(t)
+ || env.is_variadic_parameter_type(t));
}
/// For a given type, return its exemplar type.
else
d->priv_->qualified_parent_name_ = abigail::interned_string();
- abigail::environment* env = d->get_environment();
- ABG_ASSERT(env);
+ const abigail::ir::environment& env = d->get_environment();
+
if (!d->priv_->qualified_parent_name_.empty())
{
if (d->get_name().empty())
d->priv_->qualified_name_ = abigail::interned_string();
else
d->priv_->qualified_name_ =
- env->intern(d->priv_->qualified_parent_name_ + "::" + d->get_name());
+ env.intern(d->priv_->qualified_parent_name_ + "::" + d->get_name());
}
if (d->priv_->scoped_name_.empty())
&& !parent->get_is_anonymous()
&& !parent->get_name().empty())
d->priv_->scoped_name_ =
- env->intern(parent->get_name() + "::" + d->get_name());
+ env.intern(parent->get_name() + "::" + d->get_name());
else
d->priv_->scoped_name_ =
- env->intern(d->get_name());
+ env.intern(d->get_name());
}
if (!is_scope_decl(d))
private:
string m_path;
- environment* m_env;
+ environment& m_env;
unordered_map<string, vector<type_base_sptr> > m_types_map;
unordered_map<string, shared_ptr<function_tdecl> > m_fn_tmpl_map;
unordered_map<string, shared_ptr<class_tdecl> > m_class_tmpl_map;
public:
read_context(xml::reader_sptr reader,
- environment* env)
+ environment& env)
: m_env(env),
m_reader(reader),
m_corp_node(),
/// Getter for the environment of this reader.
///
/// @return the environment of this reader.
- const environment*
- get_environment() const
+ environment&
+ get_environment()
{return m_env;}
/// Getter for the environment of this reader.
///
/// @return the environment of this reader.
- environment*
- get_environment()
- {return m_env;}
-
- /// Setter for the environment of this reader.
- ///
- /// @param env the environment of this reader.
- void
- set_environment(environment* env)
- {m_env = env;}
+ const environment&
+ get_environment() const
+ {return const_cast<read_context*>(this)->get_environment();}
xml::reader_sptr
get_reader() const
void
maybe_check_abixml_canonical_type_stability(type_base_sptr& t)
{
- if (!m_env->self_comparison_debug_is_on()
- || m_env->get_type_id_canonical_type_map().empty())
+ if (!get_environment().self_comparison_debug_is_on()
+ || get_environment().get_type_id_canonical_type_map().empty())
return ;
if (class_decl_sptr c = is_class_type(t))
// Let's get the type-id of this type as recorded in the
// originating abixml file.
string type_id =
- m_env->get_type_id_from_pointer(reinterpret_cast<uintptr_t>(t.get()));
+ get_environment().get_type_id_from_pointer(reinterpret_cast<uintptr_t>(t.get()));
if (!type_id.empty())
{
// Now let's get the canonical type that initially led to the
// serialization of a type with this type-id, when the abixml
// was being serialized.
- auto j = m_env->get_type_id_canonical_type_map().find(type_id);
- if (j == m_env->get_type_id_canonical_type_map().end())
+ auto j = get_environment().get_type_id_canonical_type_map().find(type_id);
+ if (j == get_environment().get_type_id_canonical_type_map().end())
{
if (t->get_naked_canonical_type())
std::cerr << "error: no type with type-id: '"
{
ctxt.set_corpus(std::make_shared<corpus>(ctxt.get_environment(), ""));
#ifdef WITH_DEBUG_SELF_COMPARISON
- if (ctxt.get_environment()->self_comparison_debug_is_on())
- ctxt.get_environment()->
+ if (ctxt.get_environment().self_comparison_debug_is_on())
+ ctxt.get_environment().
set_self_comparison_debug_input(ctxt.get_corpus());
#endif
// due to potential suppression specifications. That's fine.
corp.set_symtab(symtab_reader::symtab::load(fn_sym_db, var_sym_db));
- ctxt.get_environment()->canonicalization_is_done(false);
+ ctxt.get_environment().canonicalization_is_done(false);
// Read the translation units.
while (read_translation_unit_from_input(ctxt))
ctxt.perform_late_type_canonicalizing();
- ctxt.get_environment()->canonicalization_is_done(true);
+ ctxt.get_environment().canonicalization_is_done(true);
if (call_reader_next)
{
/// This is non-null iff the parsing resulted in a valid corpus group.
corpus_group_sptr
read_corpus_group_from_native_xml(std::istream* in,
- environment* env)
+ environment& env)
{
read_context_sptr read_ctxt = create_native_xml_read_context(in, env);
return read_corpus_group_from_input(*read_ctxt);
/// group.
corpus_group_sptr
read_corpus_group_from_native_xml_file(const string& path,
- environment* env)
+ environment& env)
{
read_context_sptr read_ctxt = create_native_xml_read_context(path, env);
corpus_group_sptr group = read_corpus_group_from_input(*read_ctxt);
/// successful completion, or nil.
translation_unit_sptr
read_translation_unit_from_file(const string& input_file,
- environment* env)
+ environment& env)
{
read_context ctxt(xml::new_reader_from_file(input_file), env);
translation_unit_sptr tu = read_translation_unit_from_input(ctxt);
- ctxt.get_environment()->canonicalization_is_done(false);
+ env.canonicalization_is_done(false);
ctxt.perform_late_type_canonicalizing();
- ctxt.get_environment()->canonicalization_is_done(true);
+ env.canonicalization_is_done(true);
return tu;
}
/// successful completion, or nil.
translation_unit_sptr
read_translation_unit_from_buffer(const string& buffer,
- environment* env)
+ environment& env)
{
read_context ctxt(xml::new_reader_from_buffer(buffer), env);
translation_unit_sptr tu = read_translation_unit_from_input(ctxt);
- ctxt.get_environment()->canonicalization_is_done(false);
+ env.canonicalization_is_done(false);
ctxt.perform_late_type_canonicalizing();
- ctxt.get_environment()->canonicalization_is_done(true);
+ env.canonicalization_is_done(true);
return tu;
}
read_translation_unit(read_context& ctxt)
{
translation_unit_sptr tu = read_translation_unit_from_input(ctxt);
- ctxt.get_environment()->canonicalization_is_done(false);
+ ctxt.get_environment().canonicalization_is_done(false);
ctxt.perform_late_type_canonicalizing();
- ctxt.get_environment()->canonicalization_is_done(true);
+ ctxt.get_environment().canonicalization_is_done(true);
return tu;
}
if (!t)
return false;
- environment *env = t->get_environment();
- if (!env->self_comparison_debug_is_on()
+ const environment& env = t->get_environment();
+ if (!env.self_comparison_debug_is_on()
|| is_non_canonicalized_type(t.get()))
return false;
- env->get_pointer_type_id_map()[reinterpret_cast<uintptr_t>(t.get())] =
+ env.get_pointer_type_id_map()[reinterpret_cast<uintptr_t>(t.get())] =
type_id;
return true;
if (!t)
return false;
- environment *env = t->get_environment();
- if (!env->self_comparison_debug_is_on()
+ const environment& env = t->get_environment();
+ if (!env.self_comparison_debug_is_on()
|| is_non_canonicalized_type(t.get()))
return false;
location loc;
read_location(ctxt, node, loc);
- const environment* env = ctxt.get_environment();
+ const environment& env = ctxt.get_environment();
namespace_decl_sptr decl(new namespace_decl(env, name, loc));
maybe_set_artificial_location(ctxt, node, decl);
ctxt.push_decl_to_current_scope(decl, add_to_current_scope);
if (drop_if_suppressed && is_suppressed)
return elf_symbol_sptr();
- const environment* env = ctxt.get_environment();
+ const environment& env = ctxt.get_environment();
elf_symbol_sptr e = elf_symbol::create(env, /*index=*/0,
size, name, type, binding,
is_defined, is_common,
/// Build a function parameter from a 'parameter' xml element node.
///
-/// @param ctxt the contexte of the xml parsing.
+/// @param rdr the contexte of the xml parsing.
///
/// @param node the xml 'parameter' element node to de-serialize from.
static shared_ptr<function_decl::parameter>
if (!node || !xmlStrEqual(node->name, BAD_CAST("parameter")))
return nil;
- ABG_ASSERT(ctxt.get_environment());
-
bool is_variadic = false;
string is_variadic_str;
if (xml_char_sptr s =
type_base_sptr type;
if (is_variadic)
- type = ctxt.get_environment()->get_variadic_parameter_type();
+ type = ctxt.get_environment().get_variadic_parameter_type();
else
{
ABG_ASSERT(!type_id.empty());
type = ctxt.build_or_get_type_decl(type_id, true);
}
ABG_ASSERT(type);
- ABG_ASSERT(type->get_environment() == ctxt.get_environment());
string name;
if (xml_char_sptr a = xml::build_sptr(xmlGetProp(node, BAD_CAST("name"))))
location loc;
read_location(ctxt, node, loc);
- environment* env = ctxt.get_environment();
- ABG_ASSERT(env);
+ environment& env = ctxt.get_environment();
std::vector<function_decl::parameter_sptr> parms;
- type_base_sptr return_type = env->get_void_type();
+ type_base_sptr return_type = env.get_void_type();
for (xmlNodePtr n = xmlFirstElementChild(node);
n ;
return ty;
}
- const environment* env = ctxt.get_environment();
+ const environment& env = ctxt.get_environment();
type_decl_sptr decl(new type_decl(env, name, size_in_bits,
alignment_in_bits, loc));
maybe_set_artificial_location(ctxt, node, decl);
size_t size = ctxt.get_translation_unit()->get_address_size(), align = 0;
read_size_and_alignment(node, size, align);
- environment* env = ctxt.get_environment();
- ABG_ASSERT(env);
+ const environment& env = ctxt.get_environment();
std::vector<shared_ptr<function_decl::parameter> > parms;
- type_base_sptr return_type = env->get_void_type();
+ type_base_sptr return_type = env.get_void_type();
class_or_union_sptr method_class_type;
if (is_method_t)
function_type_sptr fn_type(is_method_t
? new method_type(method_class_type,
- ctxt.get_environment(),
+ /*is_const=*/false,
size, align)
: new function_type(return_type,
parms, size, align));
ABG_ASSERT(!id.empty());
- const environment* env = ctxt.get_environment();
- ABG_ASSERT(env);
-
string base_type_id;
enum_type_decl::enumerators enums;
for (xmlNodePtr n = xmlFirstElementChild(node);
return nil;
}
- enums.push_back(enum_type_decl::enumerator(env, name, value));
+ enums.push_back(enum_type_decl::enumerator(name, value));
}
}
return previous_declaration;
}
- const environment* env = ctxt.get_environment();
- ABG_ASSERT(env);
+ const environment& env = ctxt.get_environment();
if (!is_decl_only && previous_definition)
// We are in the case where we've read this class definition
return previous_declaration;
}
- const environment* env = ctxt.get_environment();
- ABG_ASSERT(env);
+ const environment& env = ctxt.get_environment();
if (!is_decl_only && previous_definition)
// We are in the case where we've read this class definition
decl_base::binding bind = decl_base::BINDING_NONE;
read_binding(node, bind);
- const environment* env = ctxt.get_environment();
- ABG_ASSERT(env);
+ const environment& env = ctxt.get_environment();
function_tdecl_sptr fn_tmpl_decl(new function_tdecl(env, loc, vis, bind));
maybe_set_artificial_location(ctxt, node, fn_tmpl_decl);
decl_base::visibility vis = decl_base::VISIBILITY_NONE;
read_visibility(node, vis);
- const environment* env = ctxt.get_environment();
- ABG_ASSERT(env);
+ const environment& env = ctxt.get_environment();
class_tdecl_sptr class_tmpl (new class_tdecl(env, loc, vis));
maybe_set_artificial_location(ctxt, node, class_tmpl);
else
ctxt.push_and_key_type_decl(result, id, /*add_to_current_scope=*/true);
- ABG_ASSERT(result->get_environment());
ctxt.maybe_canonicalize_type(result, /*force_delay=*/false);
/// @return the translation unit resulting from the parsing upon
/// successful completion, or nil.
translation_unit_sptr
-read_translation_unit_from_istream(istream* in, environment* env)
+read_translation_unit_from_istream(istream* in, environment& env)
{
read_context read_ctxt(xml::new_reader_from_istream(in), env);
return read_translation_unit_from_input(read_ctxt);
///
/// @return the created context.
read_context_sptr
-create_native_xml_read_context(const string& path, environment *env)
+create_native_xml_read_context(const string& path, environment& env)
{
read_context_sptr result(new read_context(xml::new_reader_from_file(path),
env));
corp->set_origin(corpus::NATIVE_XML_ORIGIN);
result->set_corpus(corp);
#ifdef WITH_DEBUG_SELF_COMPARISON
- if (env->self_comparison_debug_is_on())
- env->set_self_comparison_debug_input(result->get_corpus());
+ if (env.self_comparison_debug_is_on())
+ env.set_self_comparison_debug_input(result->corpus());
#endif
result->set_path(path);
return result;
///
/// @return the created context.
read_context_sptr
-create_native_xml_read_context(std::istream* in, environment* env)
+create_native_xml_read_context(std::istream* in, environment& env)
{
read_context_sptr result(new read_context(xml::new_reader_from_istream(in),
env));
corp->set_origin(corpus::NATIVE_XML_ORIGIN);
result->set_corpus(corp);
#ifdef WITH_DEBUG_SELF_COMPARISON
- if (env->self_comparison_debug_is_on())
- env->set_self_comparison_debug_input(result->get_corpus());
+ if (env.self_comparison_debug_is_on())
+ env.set_self_comparison_debug_input(result->corpus());
#endif
return result;
}
/// is non-null iff the parsing resulted in a valid corpus.
corpus_sptr
read_corpus_from_native_xml(std::istream* in,
- environment* env)
+ environment& env)
{
read_context_sptr read_ctxt = create_native_xml_read_context(in, env);
return read_corpus_from_input(*read_ctxt);
/// is non-null if the parsing successfully resulted in a corpus.
corpus_sptr
read_corpus_from_native_xml_file(const string& path,
- environment* env)
+ environment& env)
{
read_context_sptr read_ctxt = create_native_xml_read_context(path, env);
corpus_sptr corp = read_corpus_from_input(*read_ctxt);
// that are not canonicalized. Look into function
// hash_as_canonical_type_or_constant for the details.
&& v != 0xdeadbabe)
- ctxt.get_environment()->get_type_id_canonical_type_map()[id] = v;
+ ctxt.get_environment().get_type_id_canonical_type_map()[id] = v;
}
}
return true;
/// not completed
symtab_ptr
symtab::load(Elf* elf_handle,
- ir::environment* env,
+ const ir::environment& env,
symbol_predicate is_suppressed)
{
ABG_ASSERT(elf_handle);
- ABG_ASSERT(env);
symtab_ptr result(new symtab);
if (!result->load_(elf_handle, env, is_suppressed))
/// @return true if the load succeeded
bool
symtab::load_(Elf* elf_handle,
- ir::environment* env,
+ const ir::environment& env,
symbol_predicate is_suppressed)
{
GElf_Ehdr ehdr_mem;
static symtab_ptr
load(Elf* elf_handle,
- ir::environment* env,
+ const ir::environment& env,
symbol_predicate is_suppressed = NULL);
static symtab_ptr
addr_symbol_map_type entry_addr_symbol_map_;
bool
- load_(Elf* elf_handle, ir::environment* env, symbol_predicate is_suppressed);
+ load_(Elf* elf_handle,
+ const ir::environment& env,
+ symbol_predicate is_suppressed);
bool
load_(string_elf_symbols_map_sptr function_symbol_map,
suppressions_type& supprs,
bool verbose,
timer& t,
- environment_sptr& env)
+ environment& env)
{
if (!(origin & corpus::DWARF_ORIGIN))
return;
- abigail::elf_reader::status status = abigail::elf_reader::STATUS_OK;
+ abigail::elf_reader::status status = abigail::elf_reader::STATUS_OK;
dwarf_reader::read_context_sptr ctxt;
ctxt =
- dwarf_reader::create_read_context(vmlinux, di_roots, env.get(),
- /*read_all_types=*/false,
- /*linux_kernel_mode=*/true);
- dwarf_reader::set_do_log(*ctxt, verbose);
-
+ dwarf_reader::create_read_context(vmlinux, di_roots, env,
+ /*read_all_types=*/false,
+ /*linux_kernel_mode=*/true);
+ dwarf_reader::set_do_log(*ctxt, verbose);
t.start();
load_generate_apply_suppressions(*ctxt, suppr_paths,
kabi_wl_paths, supprs);
<< t
<< "\n";
- group.reset(new corpus_group(env.get(), root));
+ group.reset(new corpus_group(env, root));
set_read_context_corpus_group(*ctxt, group);
<< "/" << total_nb_modules
<< ") ... " << std::flush;
- reset_read_context(ctxt, *m, di_roots, env.get(),
+ reset_read_context(ctxt, *m, di_roots,
/*read_all_types=*/false,
/*linux_kernel_mode=*/true);
vector<char**>& di_roots,
bool verbose,
timer& t,
- environment_sptr& env)
+ environment& env)
{
if (!(origin & corpus::CTF_ORIGIN))
return;
abigail::elf_reader::status status = abigail::elf_reader::STATUS_OK;
ctf_reader::read_context_sptr ctxt;
- ctxt = ctf_reader::create_read_context(vmlinux, di_roots, env.get());
- group.reset(new corpus_group(env.get(), root));
+ ctxt = ctf_reader::create_read_context(vmlinux, di_roots, env);
+ group.reset(new corpus_group(env, root));
set_read_context_corpus_group(*ctxt, group);
if (verbose)
<< "/" << total_nb_modules
<< ") ... " << std::flush;
- reset_read_context(ctxt, *m, di_roots, env.get());
+ reset_read_context(ctxt, *m, di_roots);
set_read_context_corpus_group(*ctxt, group);
t.start();
vector<string>& kabi_wl_paths,
suppressions_type& supprs,
bool verbose,
- environment_sptr& env,
+ environment& env,
corpus::origin origin)
{
string vmlinux = vmlinux_path;
class id_manager
{
- const environment* m_env;
+ const environment& m_env;
mutable unsigned long long m_cur_id;
unsigned long long
{ return ++m_cur_id; }
public:
- id_manager(const environment* env)
+ id_manager(const environment& env)
: m_env(env),
m_cur_id(0) {}
- const environment*
+ const environment&
get_environment() const
{return m_env;}
{
ostringstream o;
o << get_new_id();
- const environment* env = get_environment();
- ABG_ASSERT(env);
- return env->intern(o.str());
+ const environment& env = get_environment();
+ return env.intern(o.str());
}
/// Return a unique string representing a numerical ID, prefixed by
{
ostringstream o;
o << prefix << get_new_id();
- const environment* env = get_environment();
- ABG_ASSERT(env);
- return env->intern(o.str());
+ const environment& env = get_environment();
+ return env.intern(o.str());
}
};
class write_context
{
- const environment* m_env;
+ const environment& m_env;
id_manager m_id_manager;
ostream* m_ostream;
bool m_annotate;
/// @param env the enviroment we are operating from.
///
/// @param os the output stream to write to.
- write_context(const environment* env, ostream& os)
+ write_context(const environment& env, ostream& os)
: m_env(env),
m_id_manager(env),
m_ostream(&os),
/// Getter of the environment we are operating from.
///
/// @return the environment we are operating from.
- const environment*
+ const environment&
get_environment() const
{return m_env;}
const config&
get_config() const
- {
- ABG_ASSERT(get_environment());
- return get_environment()->get_config();
- }
+ {return get_environment().get_config();}
/// Getter for the current ostream
///
++hash;
std::ostringstream os;
os << std::hex << std::setfill('0') << std::setw(8) << hash;
- return m_type_id_map[c] = c->get_environment()->intern(os.str());
+ return m_type_id_map[c] = c->get_environment().intern(os.str());
}
}
ABG_ASSERT_NOT_REACHED;
{
ABG_ASSERT(!is_type(decl));
string repr = get_pretty_representation(decl, true);
- interned_string irepr = decl->get_environment()->intern(repr);
+ interned_string irepr = decl->get_environment().intern(repr);
return m_emitted_decls_set.find(irepr) != m_emitted_decls_set.end();
}
record_decl_as_emitted(const decl_base_sptr& decl)
{
string repr = get_pretty_representation(decl, true);
- interned_string irepr = decl->get_environment()->intern(repr);
+ interned_string irepr = decl->get_environment().intern(repr);
m_emitted_decls_set.insert(irepr);
}
///
/// @return the new @ref write_context object.
write_context_sptr
-create_write_context(const environment *env,
+create_write_context(const environment& env,
ostream& default_output_stream)
{
write_context_sptr ctxt(new write_context(env, default_output_stream));
{
type_base_wptrs_type result;
canonical_type_sptr_set_type member_types;
- const environment* env = ctxt.get_environment();
+ const environment& env = ctxt.get_environment();
// We are looking at a decl-only class. All decl-only classes
// of a given name are equal. But then the problem is that a
//
// So let's gather all the member-types of all the decl-only
// classes of the fully-qualified name and emit them here.
- if (lookup_decl_only_class_types(env->intern(decl->get_qualified_name()),
+ if (lookup_decl_only_class_types(env.intern(decl->get_qualified_name()),
*decl->get_corpus(),
result))
{
elf_reader::status c1_status, c2_status;
corpus_sptr c1, c2;
- environment_sptr env(new environment);
+ environment env;
vector<char**> di_roots;
- c1 = dwarf_reader::read_corpus_from_elf(opts.elf1, di_roots, env.get(),
+ c1 = dwarf_reader::read_corpus_from_elf(opts.elf1, di_roots, env,
/*load_all_types=*/false,
c1_status);
if (c1_status != elf_reader::STATUS_OK)
return 1;
}
- c2 = dwarf_reader::read_corpus_from_elf(opts.elf2, di_roots, env.get(),
+ c2 = dwarf_reader::read_corpus_from_elf(opts.elf2, di_roots, env,
/*load_all_types=*/false,
c2_status);
if (c2_status != elf_reader::STATUS_OK)
continue;
}
- environment_sptr env(new environment);
+ environment env;
translation_unit_sptr tu1, tu2;
corpus_sptr corpus1, corpus2;
corpus_group_sptr corpus_group1, corpus_group2;
file_type t = guess_file_type(first_in_path);
if (t == abigail::tools_utils::FILE_TYPE_NATIVE_BI)
- tu1 = read_translation_unit_from_file(first_in_path, env.get());
+ tu1 = read_translation_unit_from_file(first_in_path, env);
else if (t == abigail::tools_utils::FILE_TYPE_XML_CORPUS)
- corpus1 = read_corpus_from_native_xml_file(first_in_path, env.get());
+ corpus1 = read_corpus_from_native_xml_file(first_in_path, env);
else if (t == abigail::tools_utils::FILE_TYPE_XML_CORPUS_GROUP)
corpus_group1 = read_corpus_group_from_native_xml_file(first_in_path,
- env.get());
+ env);
else
abort();
if (!tu1 && !corpus1 && !corpus_group1)
t = guess_file_type(second_in_path);
if (t == abigail::tools_utils::FILE_TYPE_NATIVE_BI)
- tu2 = read_translation_unit_from_file(second_in_path, env.get());
+ tu2 = read_translation_unit_from_file(second_in_path, env);
else if (t == abigail::tools_utils::FILE_TYPE_XML_CORPUS)
- corpus2 = read_corpus_from_native_xml_file(second_in_path, env.get());
+ corpus2 = read_corpus_from_native_xml_file(second_in_path, env);
else if (t == abigail::tools_utils::FILE_TYPE_XML_CORPUS_GROUP)
corpus_group2 = read_corpus_group_from_native_xml_file(first_in_path,
- env.get());
+ env);
else
abort();
if (!tu2 && !corpus2 && !corpus_group2)
abigail::elf_reader::status status =
abigail::elf_reader::STATUS_UNKNOWN;
- environment_sptr env(new environment);
+ environment env;
std::vector<char**> di_roots;
abigail::corpus_sptr corp0 =
read_corpus_from_elf(in_elfv0_path,
/*debug_info_root_path=*/di_roots,
- env.get(),
+ env,
/*load_all_types=*/false,
status);
abigail::corpus_sptr corp1 =
read_corpus_from_elf(in_elfv1_path,
/*debug_info_root_path=*/di_roots,
- env.get(),
+ env,
/*load_all_types=*/false,
status);
string file_name = argv[1];
- abigail::ir::environment_sptr env(new abigail::ir::environment);
+ abigail::ir::environment env;
abigail::corpus_sptr c;
abigail::elf_reader::status status = abigail::elf_reader::STATUS_OK;
std::vector<char**> di_roots;
if (!(c = abigail::dwarf_reader::read_corpus_from_elf(file_name, di_roots,
- env.get(),
+ env,
/*load_all_type=*/false,
status)))
{
void
test_task_ctf::perform()
{
- abigail::ir::environment_sptr env;
+ abigail::ir::environment env;
set_in_elf_path();
set_in_suppr_spec_path();
- env.reset(new abigail::ir::environment);
abigail::elf_reader::status status =
abigail::elf_reader::STATUS_UNKNOWN;
vector<char**> di_roots;
read_context_sptr ctxt = create_read_context(in_elf_path,
di_roots,
- env.get());
+ env);
ABG_ASSERT(ctxt);
corpus_sptr corp = read_corpus(ctxt.get(), status);
{
const std::string& absolute_path = test_data_dir + path;
- environment_sptr env(new environment);
+ environment env;
const std::vector<char**> debug_info_root_paths;
read_context_sptr ctxt =
- create_read_context(absolute_path, debug_info_root_paths, env.get(),
+ create_read_context(absolute_path, debug_info_root_paths, env,
/* load_all_type = */ true,
/* linux_kernel_mode = */ true);
static corpus_sptr
read_corpus(options opts, status &status,
const vector<char**> di_roots,
- const environment_sptr &env,
+ environment& env,
const string &path)
{
corpus_sptr retval = NULL;
{
abigail::ctf_reader::read_context_sptr r_ctxt
= abigail::ctf_reader::create_read_context(path,
- env.get());
+ env);
ABG_ASSERT(r_ctxt);
retval = abigail::ctf_reader::read_corpus(r_ctxt.get(), status);
}
else
#endif
- retval = read_corpus_from_elf(path, di_roots, env.get(),
+ retval = read_corpus_from_elf(path, di_roots, env,
/*load_all_types=*/opts.weak_mode,
status);
}
case abigail::tools_utils::FILE_TYPE_XML_CORPUS:
{
abigail::xml_reader::read_context_sptr r_ctxt =
- abigail::xml_reader::create_native_xml_read_context(path, env.get());
+ abigail::xml_reader::create_native_xml_read_context(path, env);
assert(r_ctxt);
retval = abigail::xml_reader::read_corpus_from_input(*r_ctxt);
}
vector<char**> app_di_roots;
app_di_roots.push_back(&app_di_root);
status status = abigail::elf_reader::STATUS_UNKNOWN;
- environment_sptr env(new environment);
+ environment env;
corpus_sptr app_corpus = read_corpus(opts, status,
app_di_roots, env,
t1_type = guess_file_type(opts.file1);
t2_type = guess_file_type(opts.file2);
- environment_sptr env(new environment);
+ environment env;
if (opts.exported_interfaces_only.has_value())
- env->analyze_exported_interfaces_only(*opts.exported_interfaces_only);
+ env.analyze_exported_interfaces_only(*opts.exported_interfaces_only);
#ifdef WITH_DEBUG_SELF_COMPARISON
if (opts.do_debug_self_comparison)
- env->self_comparison_debug_is_on(true);
+ env.self_comparison_debug_is_on(true);
#endif
#ifdef WITH_DEBUG_TYPE_CANONICALIZATION
if (opts.do_debug_type_canonicalization)
- env->debug_type_canonicalization_is_on(true);
+ env.debug_type_canonicalization_is_on(true);
#endif
translation_unit_sptr t1, t2;
abigail::elf_reader::status c1_status =
break;
case abigail::tools_utils::FILE_TYPE_NATIVE_BI:
t1 = abigail::xml_reader::read_translation_unit_from_file(opts.file1,
- env.get());
+ env);
break;
case abigail::tools_utils::FILE_TYPE_ELF: // fall through
case abigail::tools_utils::FILE_TYPE_AR:
abigail::ctf_reader::read_context_sptr ctxt
= abigail::ctf_reader::create_read_context(opts.file1,
opts.prepared_di_root_paths1,
- env.get());
+ env);
ABG_ASSERT(ctxt);
c1 = abigail::ctf_reader::read_corpus(ctxt.get(),
c1_status);
abigail::dwarf_reader::read_context_sptr ctxt =
abigail::dwarf_reader::create_read_context
(opts.file1, opts.prepared_di_root_paths1,
- env.get(), /*read_all_types=*/opts.show_all_types,
+ env, /*read_all_types=*/opts.show_all_types,
opts.linux_kernel_mode);
assert(ctxt);
{
abigail::xml_reader::read_context_sptr ctxt =
abigail::xml_reader::create_native_xml_read_context(opts.file1,
- env.get());
+ env);
assert(ctxt);
set_suppressions(*ctxt, opts);
set_native_xml_reader_options(*ctxt, opts);
{
abigail::xml_reader::read_context_sptr ctxt =
abigail::xml_reader::create_native_xml_read_context(opts.file1,
- env.get());
+ env);
assert(ctxt);
set_suppressions(*ctxt, opts);
set_native_xml_reader_options(*ctxt, opts);
break;
case abigail::tools_utils::FILE_TYPE_NATIVE_BI:
t2 = abigail::xml_reader::read_translation_unit_from_file(opts.file2,
- env.get());
+ env);
break;
case abigail::tools_utils::FILE_TYPE_ELF: // Fall through
case abigail::tools_utils::FILE_TYPE_AR:
abigail::ctf_reader::read_context_sptr ctxt
= abigail::ctf_reader::create_read_context(opts.file2,
opts.prepared_di_root_paths2,
- env.get());
+ env);
ABG_ASSERT(ctxt);
c2 = abigail::ctf_reader::read_corpus(ctxt.get(),
c2_status);
abigail::dwarf_reader::read_context_sptr ctxt =
abigail::dwarf_reader::create_read_context
(opts.file2, opts.prepared_di_root_paths2,
- env.get(), /*read_all_types=*/opts.show_all_types,
+ env, /*read_all_types=*/opts.show_all_types,
opts.linux_kernel_mode);
assert(ctxt);
abigail::dwarf_reader::set_show_stats(*ctxt, opts.show_stats);
{
abigail::xml_reader::read_context_sptr ctxt =
abigail::xml_reader::create_native_xml_read_context(opts.file2,
- env.get());
+ env);
assert(ctxt);
set_suppressions(*ctxt, opts);
set_native_xml_reader_options(*ctxt, opts);
{
abigail::xml_reader::read_context_sptr ctxt =
abigail::xml_reader::create_native_xml_read_context(opts.file2,
- env.get());
+ env);
assert(ctxt);
set_suppressions(*ctxt, opts);
set_native_xml_reader_options(*ctxt, opts);
/// otherwise.
static int
load_corpus_and_write_abixml(char* argv[],
- environment_sptr& env,
+ environment& env,
options& opts)
{
int exit_code = 0;
#ifdef WITH_DEBUG_SELF_COMPARISON
if (opts.debug_abidiff)
- env->self_comparison_debug_is_on(true);
+ env.self_comparison_debug_is_on(true);
#endif
#ifdef WITH_DEBUG_TYPE_CANONICALIZATION
if (opts.debug_type_canonicalization)
- env->debug_type_canonicalization_is_on(true);
+ env.debug_type_canonicalization_is_on(true);
if (opts.debug_die_canonicalization)
- env->debug_die_canonicalization_is_on(true);
+ env.debug_die_canonicalization_is_on(true);
#endif
// First of all, read a libabigail IR corpus from the file specified
abigail::ctf_reader::read_context_sptr ctxt
= abigail::ctf_reader::create_read_context(opts.in_file_path,
opts.prepared_di_root_paths,
- env.get());
+ env);
assert (ctxt);
t.start();
corp = abigail::ctf_reader::read_corpus (ctxt, s);
dwarf_reader::read_context_sptr c
= abigail::dwarf_reader::create_read_context(opts.in_file_path,
opts.prepared_di_root_paths,
- env.get(),
+ env,
opts.load_all_types,
opts.linux_kernel_mode);
dwarf_reader::read_context& ctxt = *c;
}
}
- if (opts.exported_interfaces_only.has_value())
- env->analyze_exported_interfaces_only(*opts.exported_interfaces_only);
+ // ... if we are asked to only analyze exported interfaces (to stay
+ // concise), then take that into account ...
+ if (opts.exported_interfaces_only.has_value())
+ env.analyze_exported_interfaces_only(*opts.exported_interfaces_only);
t.start();
corp = dwarf_reader::read_corpus_from_elf(ctxt, s);
}
#endif
xml_reader::read_context_sptr read_ctxt =
- create_native_xml_read_context(tmp_file->get_path(), env.get());
+ create_native_xml_read_context(tmp_file->get_path(), env);
#ifdef WITH_DEBUG_SELF_COMPARISON
if (opts.debug_abidiff
/// otherwise.
static int
load_kernel_corpus_group_and_write_abixml(char* argv[],
- environment_sptr& env,
+ environment& env,
options& opts)
{
if (!(tools_utils::is_dir(opts.in_file_path) && opts.corpus_group_for_linux))
suppressions_type supprs;
if (opts.exported_interfaces_only.has_value())
- env->analyze_exported_interfaces_only(*opts.exported_interfaces_only);
+ env.analyze_exported_interfaces_only(*opts.exported_interfaces_only);
if (opts.do_log)
emit_prefix(argv[0], cerr)
if (!opts.noout)
{
const xml_writer::write_context_sptr& ctxt
- = xml_writer::create_write_context(group->get_environment(), cout);
+ = xml_writer::create_write_context(env, cout);
set_common_options(*ctxt, opts);
if (!opts.out_file_path.empty())
return 1;
}
- environment_sptr env(new environment);
+ environment env;
int exit_code = 0;
if (tools_utils::is_regular_file(opts.in_file_path))
if (!maybe_check_suppression_files(opts))
return 1;
- abigail::ir::environment_sptr env(new abigail::ir::environment);
+ abigail::ir::environment env;
if (opts.read_from_stdin)
{
if (!cin.good())
if (opts.read_tu)
{
abigail::translation_unit_sptr tu =
- read_translation_unit_from_istream(&cin, env.get());
+ read_translation_unit_from_istream(&cin, env);
if (!tu)
{
if (!opts.noout)
{
const write_context_sptr& ctxt
- = create_write_context(tu->get_environment(), cout);
+ = create_write_context(env, cout);
write_translation_unit(*ctxt, *tu, 0);
}
return 0;
{
abigail::xml_reader::read_context_sptr ctxt =
abigail::xml_reader::create_native_xml_read_context(&cin,
- env.get());
+ env);
assert(ctxt);
set_suppressions(*ctxt, opts);
corpus_sptr corp = abigail::xml_reader::read_corpus_from_input(*ctxt);
if (!opts.noout)
{
const write_context_sptr& ctxt
- = create_write_context(corp->get_environment(), cout);
+ = create_write_context(env, cout);
write_corpus(*ctxt, corp, /*indent=*/0);
}
return 0;
{
abixml_read_ctxt =
abigail::xml_reader::create_native_xml_read_context(opts.file_path,
- env.get());
+ env);
tu = read_translation_unit(*abixml_read_ctxt);
}
break;
abigail::ctf_reader::read_context_sptr ctxt =
abigail::ctf_reader::create_read_context(opts.file_path,
di_roots,
- env.get());
+ env);
ABG_ASSERT(ctxt);
corp = abigail::ctf_reader::read_corpus(ctxt.get(), s);
}
{
abigail::dwarf_reader::read_context_sptr ctxt =
abigail::dwarf_reader::create_read_context(opts.file_path,
- di_roots, env.get(),
+ di_roots, env,
/*load_all_types=*/false);
assert(ctxt);
set_suppressions(*ctxt, opts);
{
abixml_read_ctxt =
abigail::xml_reader::create_native_xml_read_context(opts.file_path,
- env.get());
+ env);
assert(abixml_read_ctxt);
set_suppressions(*abixml_read_ctxt, opts);
corp = read_corpus_from_input(*abixml_read_ctxt);
{
abixml_read_ctxt =
abigail::xml_reader::create_native_xml_read_context(opts.file_path,
- env.get());
+ env);
assert(abixml_read_ctxt);
set_suppressions(*abixml_read_ctxt, opts);
group = read_corpus_group_from_input(*abixml_read_ctxt);
}
std::ostream& of = opts.diff ? tmp_file->get_stream() : cout;
- const abigail::ir::environment* env = 0;
- if (tu)
- env = tu->get_environment();
- else if (corp)
- env = corp->get_environment();
- else if (group)
- env = group->get_environment();
-
- ABG_ASSERT(env);
const write_context_sptr ctxt = create_write_context(env, of);
bool is_ok = true;
const string& debug_dir2,
const suppressions_type& priv_types_supprs2,
const options& opts,
- abigail::ir::environment_sptr &env,
+ abigail::ir::environment& env,
corpus_diff_sptr &diff,
diff_context_sptr &ctxt,
abigail::elf_reader::status *detailed_error_status = 0)
{
ctxt_ctf = abigail::ctf_reader::create_read_context(elf1.path,
di_dirs1,
- env.get());
+ env);
ABG_ASSERT(ctxt_ctf);
corpus1 = abigail::ctf_reader::read_corpus(ctxt_ctf.get(),
c1_status);
else
#endif
{
- ctxt_dwarf = create_read_context(elf1.path, di_dirs1, env.get(),
+ ctxt_dwarf = create_read_context(elf1.path, di_dirs1, env,
/*load_all_types=*/opts.show_all_types);
add_read_context_suppressions(*ctxt_dwarf, priv_types_supprs1);
if (!opts.kabi_suppressions.empty())
{
ctxt_ctf = abigail::ctf_reader::create_read_context(elf2.path,
di_dirs2,
- env.get());
+ env);
corpus2 = abigail::ctf_reader::read_corpus(ctxt_ctf.get(),
c2_status);
}
else
#endif
{
- ctxt_dwarf = create_read_context(elf2.path, di_dirs2, env.get(),
+ ctxt_dwarf = create_read_context(elf2.path, di_dirs2, env,
/*load_all_types=*/opts.show_all_types);
add_read_context_suppressions(*ctxt_dwarf, priv_types_supprs2);
compare_to_self(const elf_file& elf,
const string& debug_dir,
const options& opts,
- abigail::ir::environment_sptr &env,
+ abigail::ir::environment& env,
corpus_diff_sptr &diff,
diff_context_sptr &ctxt,
abigail::elf_reader::status *detailed_error_status = 0)
{
ctxt_ctf = abigail::ctf_reader::create_read_context(elf.path,
di_dirs,
- env.get());
+ env);
ABG_ASSERT(ctxt_ctf);
corp = abigail::ctf_reader::read_corpus(ctxt_ctf.get(),
c_status);
#endif
{
ctxt_dwarf =
- create_read_context(elf.path, di_dirs, env.get(),
+ create_read_context(elf.path, di_dirs, env,
/*read_all_types=*/opts.show_all_types);
corp = read_corpus_from_elf(*ctxt_dwarf, c_status);
{
const abigail::xml_writer::write_context_sptr c =
- abigail::xml_writer::create_write_context(env.get(), of);
+ abigail::xml_writer::create_write_context(env, of);
if (opts.verbose)
emit_prefix("abipkgdiff", cerr)
{
abigail::xml_reader::read_context_sptr c =
abigail::xml_reader::create_native_xml_read_context(abi_file_path,
- env.get());
+ env);
if (!c)
{
if (opts.verbose)
virtual void
perform()
{
- abigail::ir::environment_sptr env(new abigail::ir::environment);
+ abigail::ir::environment env;
diff_context_sptr ctxt;
corpus_diff_sptr diff;
abigail::elf_reader::STATUS_UNKNOWN;
if (args->opts.exported_interfaces_only.has_value())
- env->analyze_exported_interfaces_only
+ env.analyze_exported_interfaces_only
(*args->opts.exported_interfaces_only);
status |= compare(args->elf1, args->debug_dir1, args->private_types_suppr1,
virtual void
perform()
{
- abigail::ir::environment_sptr env(new abigail::ir::environment);
+ abigail::ir::environment env;
diff_context_sptr ctxt;
corpus_diff_sptr diff;
if (args->opts.exported_interfaces_only.has_value())
- env->analyze_exported_interfaces_only
+ env.analyze_exported_interfaces_only
(*args->opts.exported_interfaces_only);
abigail::elf_reader::status detailed_status =
string dist_root1 = first_package.extracted_dir_path();
string dist_root2 = second_package.extracted_dir_path();
- abigail::ir::environment_sptr env(new abigail::ir::environment);
+ abigail::ir::environment env;
if (opts.exported_interfaces_only.has_value())
- env->analyze_exported_interfaces_only
+ env.analyze_exported_interfaces_only
(*opts.exported_interfaces_only);
suppressions_type supprs;
&& opts.symbol_name != 0);
string p = opts.elf_path, n = opts.symbol_name;
- environment_sptr env(new environment);
+ environment env;
vector<elf_symbol_sptr> syms;
- if (!lookup_symbol_from_elf(env.get(), p, n, opts.demangle, syms))
+ if (!lookup_symbol_from_elf(env, p, n, opts.demangle, syms))
{
cout << "could not find symbol '"
<< opts.symbol_name
return 0;
}
- environment_sptr env(new environment);
+ environment env;
if (opts.exported_interfaces_only.has_value())
- env->analyze_exported_interfaces_only(*opts.exported_interfaces_only);
+ env.analyze_exported_interfaces_only(*opts.exported_interfaces_only);
corpus_group_sptr group1, group2;
string debug_info_root_dir;
else if (ftype == FILE_TYPE_XML_CORPUS_GROUP)
group1 =
read_corpus_group_from_native_xml_file(opts.kernel_dist_root1,
- env.get());
+ env);
}
else if (ftype == FILE_TYPE_XML_CORPUS_GROUP)
group2 =
read_corpus_group_from_native_xml_file(opts.kernel_dist_root2,
- env.get());
+ env);
}
abidiff_status status = abigail::tools_utils::ABIDIFF_OK;