@@ -71,6 +71,12 @@ void
consider_types_not_reachable_from_public_interfaces(fe_iface& ctxt,
bool flag);
+class reader;
+typedef shared_ptr<reader> reader_sptr;
+
+reader_sptr
+is_reader(fe_iface_sptr);
+
#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
vector<type_base_sptr>*
get_types_from_type_id(fe_iface&, const string&);
@@ -62,8 +62,6 @@ using std::istream;
/// strings.
typedef unordered_map<string, vector<string>> string_strings_map_type;
-class reader;
-
static bool read_is_declaration_only(xmlNodePtr, bool&);
static bool read_is_artificial(xmlNodePtr, bool&);
static bool read_tracking_non_reachable_types(xmlNodePtr, bool&);
@@ -85,8 +83,6 @@ static bool maybe_map_type_with_type_id(const type_base_sptr&,
static void maybe_set_naming_typedef(reader& rdr,
xmlNodePtr,
const decl_base_sptr &);
-class reader;
-
static int advance_cursor(reader& rdr);
static void
@@ -165,7 +161,6 @@ public:
friend unordered_map<type_or_decl_base*, vector<type_or_decl_base*>>*
get_artifact_used_by_relation_map(reader& rdr);
-private:
types_map_type 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;
@@ -1471,7 +1466,14 @@ public:
}
};// end class reader
-typedef shared_ptr<reader> reader_sptr;
+/// Convert a @ref abigail:fe_iface into an abigail::abixml::reader.
+///
+/// @param f the interface to convert.
+///
+/// @return the resulting abigail::abixml::reader.
+reader_sptr
+is_reader(fe_iface_sptr iface)
+{return dynamic_pointer_cast<reader>(iface);}
static int advance_cursor(reader&);
static bool read_translation_unit(fe_iface&, translation_unit&, xmlNodePtr);
@@ -2291,8 +2293,7 @@ add_reader_suppressions(reader& rdr,
/// @param flag if yes, then types not reachable from public interface
/// are taken into account when the abixml file is read.
void
-consider_types_not_reachable_from_public_interfaces(fe_iface& iface,
- bool flag)
+consider_types_not_reachable_from_public_interfaces(fe_iface& iface, bool flag)
{
abixml::reader& rdr = dynamic_cast<abixml::reader&>(iface);
rdr.tracking_non_reachable_types(flag);
@@ -2304,13 +2305,13 @@ consider_types_not_reachable_from_public_interfaces(fe_iface& iface,
/// This function is available only if the project has been configured
/// with --enable-show-type-use-in-abilint.
///
-/// @param rdr the abixml text reader context to use.
+/// @param rdr the abixml reader to use.
///
/// @param type_id the type-id to consider.
vector<type_base_sptr>*
get_types_from_type_id(fe_iface& iface, const string& type_id)
{
- xml_reader::reader& rdr = dynamic_cast<xml_reader::reader&>(iface);
+ reader& rdr = dynamic_cast<reader&>(iface);
auto it = rdr.m_types_map.find(type_id);
if (it == rdr.m_types_map.end())
return nullptr;
@@ -2326,7 +2327,7 @@ get_types_from_type_id(fe_iface& iface, const string& type_id)
unordered_map<type_or_decl_base*, vector<type_or_decl_base*>>*
get_artifact_used_by_relation_map(fe_iface& iface)
{
- xml_reader::reader& rdr = dynamic_cast<xml_reader::reader&>(iface);
+ reader& rdr = dynamic_cast<reader&>(iface);
return &rdr.m_artifact_used_by_map;
}
#endif
@@ -6959,7 +6960,7 @@ struct array_deleter
};//end array_deleter
-/// Create an xml_reader::reader to read a native XML ABI file.
+/// Create an abixml::reader to read a native XML ABI file.
///
/// @param path the path to the native XML file to read.
///
@@ -1026,8 +1026,7 @@ static void
set_native_xml_reader_options(abigail::fe_iface& rdr,
const options& opts)
{
- abixml::consider_types_not_reachable_from_public_interfaces(rdr,
- opts.show_all_types);
+ abixml::consider_types_not_reachable_from_public_interfaces(rdr, opts.show_all_types);
rdr.options().do_log = opts.do_log;
}
@@ -306,16 +306,16 @@ fill_artifact_use_tree(const std::unordered_map<type_or_decl_base*,
/// @param type_id the type-id of the type to construct the "use tree"
/// for.
static unique_ptr<artifact_use_relation_tree>
-build_type_use_tree(abigail::abixml::reader &ctxt,
+build_type_use_tree(abigail::fe_iface &iface,
const string& type_id)
{
unique_ptr<artifact_use_relation_tree> result;
- vector<type_base_sptr>* types = get_types_from_type_id(ctxt, type_id);
+ vector<type_base_sptr>* types = get_types_from_type_id(iface, type_id);
if (!types)
return result;
std::unordered_map<type_or_decl_base*, vector<type_or_decl_base*>>*
- artifact_use_rel = get_artifact_used_by_relation_map(ctxt);
+ artifact_use_rel = get_artifact_used_by_relation_map(iface);
if (!artifact_use_rel)
return result;
@@ -452,18 +452,17 @@ emit_artifact_use_trace(const artifact_use_relation_tree& artifact_use_tree,
/// The type to consider is designated by a type-id string that is
/// carried by the options data structure.
///
-/// @param ctxt the abixml read context to consider.
+/// @param iface the abixml reader interface to consider.
///
/// @param the type_id of the type which usage to analyse.
static bool
-show_how_type_is_used(abigail::abixml::reader &ctxt,
- const string& type_id)
+show_how_type_is_used(abigail::fe_iface &iface, const string& type_id)
{
if (type_id.empty())
return false;
unique_ptr<artifact_use_relation_tree> use_tree =
- build_type_use_tree(ctxt, type_id);
+ build_type_use_tree(iface, type_id);
if (!use_tree)
return false;
@@ -780,6 +779,7 @@ main(int argc, char* argv[])
abigail::fe_iface::status s = abigail::fe_iface::STATUS_OK;
string di_root_path;
file_type type = guess_file_type(opts.file_path);
+ abigail::fe_iface_sptr rdr;
switch (type)
{
@@ -790,9 +790,8 @@ main(int argc, char* argv[])
return 1;
case abigail::tools_utils::FILE_TYPE_NATIVE_BI:
{
- abigail::fe_iface_sptr rdr =
- abigail::abixml::create_reader(opts.file_path,
- env);
+ rdr = abigail::abixml::create_reader(opts.file_path,
+ env);
set_reader_options(*rdr, opts);
tu = abigail::abixml::read_translation_unit(*rdr);
}
@@ -803,7 +802,6 @@ main(int argc, char* argv[])
di_root_path = opts.di_root_path;
vector<string> di_roots;
di_roots.push_back(di_root_path);
- abigail::elf_based_reader_sptr rdr;
#ifdef WITH_CTF
if (opts.use_ctf)
rdr =
@@ -821,8 +819,7 @@ main(int argc, char* argv[])
break;
case abigail::tools_utils::FILE_TYPE_XML_CORPUS:
{
- abigail::fe_iface_sptr rdr =
- abigail::abixml::create_reader(opts.file_path, env);
+ rdr = abigail::abixml::create_reader(opts.file_path, env);
assert(rdr);
set_reader_options(*rdr, opts);
corp = rdr->read_corpus(s);
@@ -830,8 +827,7 @@ main(int argc, char* argv[])
}
case abigail::tools_utils::FILE_TYPE_XML_CORPUS_GROUP:
{
- abigail::fe_iface_sptr rdr =
- abigail::abixml::create_reader(opts.file_path, env);
+ rdr = abigail::abixml::create_reader(opts.file_path, env);
assert(rdr);
set_reader_options(*rdr, opts);
group = read_corpus_group_from_input(*rdr);
@@ -941,8 +937,8 @@ main(int argc, char* argv[])
if (is_ok
&& !opts.type_id_to_show.empty())
{
- ABG_ASSERT(abixml_read_ctxt);
- show_how_type_is_used(*abixml_read_ctxt, opts.type_id_to_show);
+ ABG_ASSERT(rdr);
+ show_how_type_is_used(*rdr, opts.type_id_to_show);
}
#endif
return is_ok ? 0 : 1;