15#include <libxml/xmlreader.h>
16#include <libxml/xmlstring.h>
23#include <unordered_map>
27#include "abg-internal.h"
31ABG_BEGIN_EXPORT_DECLARATIONS
39ABG_END_EXPORT_DECLARATIONS
53using std::unordered_map;
54using std::dynamic_pointer_cast;
60static bool read_is_declaration_only(xmlNodePtr,
bool&);
61static bool read_is_artificial(xmlNodePtr,
bool&);
62static bool read_tracking_non_reachable_types(xmlNodePtr,
bool&);
63static bool read_is_non_reachable_type(xmlNodePtr,
bool&);
64static bool read_naming_typedef_id_string(xmlNodePtr,
string&);
65static bool read_type_id_string(xmlNodePtr,
string&);
66#ifdef WITH_DEBUG_SELF_COMPARISON
67static bool maybe_map_type_with_type_id(
const type_base_sptr&,
69static bool maybe_map_type_with_type_id(
const type_base_sptr&,
72#define MAYBE_MAP_TYPE_WITH_TYPE_ID(type, xml_node) \
73 maybe_map_type_with_type_id(type, xml_node)
75#define MAYBE_MAP_TYPE_WITH_TYPE_ID(type, xml_node)
77static void maybe_set_naming_typedef(reader& rdr,
79 const decl_base_sptr &);
82static int advance_cursor(reader& rdr);
88walk_xml_node_to_map_type_ids(reader& rdr, xmlNodePtr node);
91read_elf_needed_from_input(reader& rdr, vector<string>& needed);
94read_symbol_db_from_input(reader& rdr,
99read_translation_unit_from_input(
fe_iface& rdr);
102build_ir_node_for_void_type(reader& rdr);
105build_ir_node_for_void_pointer_type(reader& rdr);
118 typedef unordered_map<string, vector<type_base_sptr> >
121 typedef unordered_map<string,
122 vector<type_base_sptr> >::const_iterator
125 typedef unordered_map<string,
126 vector<type_base_sptr> >::iterator
129 typedef unordered_map<string,
130 shared_ptr<function_tdecl> >::const_iterator
131 const_fn_tmpl_map_it;
133 typedef unordered_map<string,
134 shared_ptr<class_tdecl> >::const_iterator
135 const_class_tmpl_map_it;
137 typedef unordered_map<string, xmlNodePtr> string_xml_node_map;
139 typedef unordered_map<xmlNodePtr, decl_base_sptr> xml_node_decl_base_sptr_map;
141 friend vector<type_base_sptr>* get_types_from_type_id(reader&,
144 friend unordered_map<type_or_decl_base*, vector<type_or_decl_base*>>*
145 get_artifact_used_by_relation_map(reader& rdr);
148 types_map_type m_types_map;
149 unordered_map<string, shared_ptr<function_tdecl> > m_fn_tmpl_map;
150 unordered_map<string, shared_ptr<class_tdecl> > m_class_tmpl_map;
151 vector<type_base_sptr> m_types_to_canonicalize;
152 string_xml_node_map m_id_xml_node_map;
153 xml_node_decl_base_sptr_map m_xml_node_decl_map;
155 xmlNodePtr m_corp_node;
156 deque<shared_ptr<decl_base> > m_decls_stack;
157 bool m_tracking_non_reachable_types;
158 bool m_drop_undefined_syms;
159#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
161 vector<type_or_decl_base*>> m_artifact_used_by_map;
172 m_tracking_non_reachable_types(),
173 m_drop_undefined_syms()
182 {
return options().do_log;}
190 tracking_non_reachable_types()
const
191 {
return m_tracking_non_reachable_types;}
199 tracking_non_reachable_types(
bool f)
200 {m_tracking_non_reachable_types = f;}
208 drop_undefined_syms()
const
209 {
return m_drop_undefined_syms;}
216 drop_undefined_syms(
bool f)
217 {m_drop_undefined_syms = f;}
224 {
return corpus_path();}
230 set_path(
const string& s)
240 {
return options().env;}
246 get_environment()
const
247 {
return const_cast<reader*
>(
this)->get_environment();}
250 get_libxml_reader()
const
259 get_corpus_node()
const
260 {
return m_corp_node;}
268 set_corpus_node(xmlNodePtr node)
269 {m_corp_node = node;}
271 const string_xml_node_map&
272 get_id_xml_node_map()
const
273 {
return m_id_xml_node_map;}
276 get_id_xml_node_map()
277 {
return m_id_xml_node_map;}
280 clear_id_xml_node_map()
281 {get_id_xml_node_map().clear();}
283 const xml_node_decl_base_sptr_map&
284 get_xml_node_decl_map()
const
285 {
return m_xml_node_decl_map;}
287 xml_node_decl_base_sptr_map&
288 get_xml_node_decl_map()
289 {
return m_xml_node_decl_map;}
292 map_xml_node_to_decl(xmlNodePtr node,
296 get_xml_node_decl_map()[node]= decl;
300 get_decl_for_xml_node(xmlNodePtr node)
const
302 xml_node_decl_base_sptr_map::const_iterator i =
303 get_xml_node_decl_map().find(node);
305 if (i != get_xml_node_decl_map().end())
308 return decl_base_sptr();
312 clear_xml_node_decl_map()
313 {get_xml_node_decl_map().clear();}
316 map_id_and_node (
const string&
id,
322 string_xml_node_map::iterator i = get_id_xml_node_map().find(
id);
323 if (i != get_id_xml_node_map().end())
325 bool is_declaration =
false;
326 read_is_declaration_only(node, is_declaration);
331 get_id_xml_node_map()[id] = node;
335 get_xml_node_from_id(
const string&
id)
const
337 string_xml_node_map::const_iterator i = get_id_xml_node_map().find(
id);
338 if (i != get_id_xml_node_map().end())
344 get_scope_for_node(xmlNodePtr node,
348 get_scope_for_node(xmlNodePtr node);
351 get_scope_ptr_for_node(xmlNodePtr node);
356 build_or_get_type_decl(
const string&
id,
371 get_type_decl(
const string&
id)
const
373 const_types_map_it i = m_types_map.find(
id);
374 if (i == m_types_map.end())
375 return type_base_sptr();
376 type_base_sptr result = i->second[0];
392 const vector<type_base_sptr>*
393 get_all_type_decls(
const string&
id)
const
395 const_types_map_it i = m_types_map.find(
id);
396 if (i == m_types_map.end())
413 shared_ptr<function_tdecl>
414 get_fn_tmpl_decl(
const string&
id)
const
416 const_fn_tmpl_map_it i = m_fn_tmpl_map.find(
id);
417 if (i == m_fn_tmpl_map.end())
418 return shared_ptr<function_tdecl>();
432 shared_ptr<class_tdecl>
433 get_class_tmpl_decl(
const string&
id)
const
435 const_class_tmpl_map_it i = m_class_tmpl_map.find(
id);
436 if (i == m_class_tmpl_map.end())
437 return shared_ptr<class_tdecl>();
443 get_cur_scope()
const
445 shared_ptr<decl_base> cur_decl = get_cur_decl();
447 if (
dynamic_cast<scope_decl*
>(cur_decl.get()))
449 return dynamic_pointer_cast<scope_decl>(cur_decl).get();
453 return cur_decl->get_scope();
462 if (m_decls_stack.empty())
463 return shared_ptr<decl_base>(
static_cast<decl_base*
>(0));
464 return m_decls_stack.back();
471 for (deque<shared_ptr<decl_base> >::reverse_iterator i =
472 m_decls_stack.rbegin();
473 i != m_decls_stack.rend();
475 if (decl_base_sptr d = *i)
480 return global->get_translation_unit();
491 type_is_from_translation_unit(type_base_sptr type)
503 push_decl(decl_base_sptr d)
505 m_decls_stack.push_back(d);
511 if (m_decls_stack.empty())
512 return decl_base_sptr();
514 shared_ptr<decl_base> t = get_cur_decl();
515 m_decls_stack.pop_back();
542 return dynamic_pointer_cast<scope_decl>(d) == scope;
555 {m_decls_stack.clear();}
559 {m_types_map.clear();}
564 clear_types_to_canonicalize()
565 {m_types_to_canonicalize.clear();}
581 types_equal(type_base_sptr t1, type_base_sptr t2)
583 if (t1.get() == t2.get())
602 key_type_decl(
const type_base_sptr& type,
const string&
id)
607 m_types_map[id].push_back(type);
622 key_fn_tmpl_decl(shared_ptr<function_tdecl> fn_tmpl_decl,
627 const_fn_tmpl_map_it i = m_fn_tmpl_map.find(
id);
628 if (i != m_fn_tmpl_map.end())
631 m_fn_tmpl_map[id] = fn_tmpl_decl;
645 key_class_tmpl_decl(shared_ptr<class_tdecl> class_tmpl_decl,
650 const_class_tmpl_map_it i = m_class_tmpl_map.find(
id);
651 if (i != m_class_tmpl_map.end())
654 m_class_tmpl_map[id] = class_tmpl_decl;
658#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
671 if (m_artifact_used_by_map.find(used) == m_artifact_used_by_map.end())
673 vector<type_or_decl_base*> v;
674 m_artifact_used_by_map[used] = v;
676 m_artifact_used_by_map[used].push_back(user);
690 {record_artifact_as_used_by(used.get(), user.get());}
702 record_artifact_as_used_by(t.get(),
const_cast<function_decl*
>(fn));
706 type_base_sptr t = pit->get_type();
707 record_artifact_as_used_by(t.get(),
const_cast<function_decl*
>(fn));
716 {record_artifacts_as_used_in_fn_decl(fn.get());}
722 record_artifacts_as_used_in_fn_type(
const function_type *fn_type)
728 record_artifact_as_used_by(t.get(),
const_cast<function_type*
>(fn_type));
732 type_base_sptr t = pit->get_type();
733 record_artifact_as_used_by(t.get(),
743 {record_artifacts_as_used_in_fn_type(fn_type.get());}
755 push_decl_to_scope(
const decl_base_sptr& decl, xmlNodePtr node)
758 scope = get_scope_ptr_for_node(node);
759 return push_decl_to_scope(decl, scope);
768 push_decl_to_scope(
const decl_base_sptr& decl,
774 if (!decl->get_translation_unit())
793 push_and_key_type_decl(
const type_base_sptr& t,
800 push_decl_to_scope(decl, scope);
801 if (!t->get_translation_unit())
804 key_type_decl(t,
id);
819 push_and_key_type_decl(
const type_base_sptr& t,
820 const xmlNodePtr node,
821 bool add_to_current_scope)
824 if (!read_type_id_string(node,
id))
829 scope = get_scope_ptr_for_node(node);
830 return push_and_key_type_decl(t,
id, scope);
839 get_exported_decls_builder()
853 corpus_is_suppressed_by_soname_or_filename(
const string& soname,
854 const string& filename)
860 for (suppressions_type::const_iterator s = suppressions().begin();
861 s != suppressions().end();
874 clear_per_translation_unit_data()
881 clear_per_corpus_data()
884 clear_types_to_canonicalize();
885 clear_xml_node_decl_map();
886 clear_id_xml_node_map();
890#ifdef WITH_DEBUG_SELF_COMPARISON
910 maybe_check_abixml_canonical_type_stability(type_base_sptr& t)
912 if (!get_environment().self_comparison_debug_is_on()
913 || get_environment().get_type_id_canonical_type_map().empty())
925 get_environment().get_type_id_from_pointer(
reinterpret_cast<uintptr_t
>(t.get()));
927 if (!type_id.empty())
932 auto j = get_environment().get_type_id_canonical_type_map().find(type_id);
933 if (j == get_environment().get_type_id_canonical_type_map().end())
935 if (t->get_naked_canonical_type())
936 std::cerr <<
"error: no type with type-id: '"
938 <<
"' could be read back from the typeid file\n";
941 !=
reinterpret_cast<uintptr_t
>(t->get_canonical_type().get()))
946 std::cerr <<
"error: canonical type for type '"
947 << t->get_pretty_representation(
true,
949 <<
"' of type-id '" << type_id
950 <<
"' changed from '" << std::hex
951 << j->second <<
"' to '" << std::hex
952 <<
reinterpret_cast<uintptr_t
>(t->get_canonical_type().get())
966 maybe_canonicalize_type(type_base_sptr t,
967 bool force_delay =
false)
972 if (t->get_canonical_type())
1007#ifdef WITH_DEBUG_SELF_COMPARISON
1008 maybe_check_abixml_canonical_type_stability(t);
1018 schedule_type_for_late_canonicalizing(t);
1027 schedule_type_for_late_canonicalizing(type_base_sptr t)
1028 {m_types_to_canonicalize.push_back(t);}
1034 perform_late_type_canonicalizing()
1036 for (vector<type_base_sptr>::iterator i = m_types_to_canonicalize.begin();
1037 i != m_types_to_canonicalize.end();
1041#ifdef WITH_DEBUG_SELF_COMPARISON
1042 maybe_check_abixml_canonical_type_stability(*i);
1060 const string& fn_name)
const
1064 return suppression_matches_function_name(*s, fn_name);
1077 corpus_sptr corp =
corpus();
1079 if (!s.priv_->matches_soname(corp->get_soname()))
1086 if (!s.priv_->matches_binary_name(corp->get_path()))
1109 const string& fn_name)
const
1111 if (!s.get_drops_artifact_from_ir()
1115 return suppr::suppression_matches_function_name(s, fn_name);
1131 const string& type_name,
1132 const location& type_location)
const
1141 virtual ir::corpus_sptr
1152 bool call_reader_next =
false;
1154 xmlNodePtr node = get_corpus_node();
1161 status = advance_cursor (*
this);
1164 BAD_CAST(
"abi-corpus")))
1167#ifdef WITH_DEBUG_SELF_COMPARISON
1168 if (get_environment().self_comparison_debug_is_on())
1169 get_environment().set_self_comparison_debug_input(
corpus());
1173 clear_per_corpus_data();
1179 handle_version_attribute(xml_reader, corp);
1186 path =
reinterpret_cast<char*
>(path_str.get());
1193 if (architecture_str)
1195 (
reinterpret_cast<char*
>(architecture_str.get()));
1203 soname =
reinterpret_cast<char*
>(soname_str.get());
1215 if ((!soname.empty() || !path.empty())
1216 && corpus_is_suppressed_by_soname_or_filename(soname, path))
1219 node = xmlTextReaderExpand(xml_reader.get());
1223 call_reader_next =
true;
1227#ifdef WITH_DEBUG_SELF_COMPARISON
1228 if (get_environment().self_comparison_debug_is_on())
1229 get_environment().set_self_comparison_debug_input(
corpus());
1233 clear_per_corpus_data();
1240 corp.
set_path(
reinterpret_cast<char*
>(path_str.get()));
1244 if (architecture_str)
1246 (
reinterpret_cast<char*
>(architecture_str.get()));
1251 corp.
set_soname(
reinterpret_cast<char*
>(soname_str.get()));
1259 xmlNodePtr n = xmlFirstElementChild(node);
1265 walk_xml_node_to_map_type_ids(*
this, node);
1268 vector<string> needed;
1269 read_elf_needed_from_input(*
this, needed);
1270 if (!needed.empty())
1276 read_symbol_db_from_input(*
this, fn_sym_db, var_sym_db);
1282 get_environment().canonicalization_is_done(
false);
1285 while (read_translation_unit_from_input(*
this))
1288 if (tracking_non_reachable_types())
1290 bool is_tracking_non_reachable_types =
false;
1291 read_tracking_non_reachable_types(node, is_tracking_non_reachable_types);
1295 == is_tracking_non_reachable_types);
1302 std::cerr <<
"perform late type canonicalization ...\n";
1306 perform_late_type_canonicalizing();
1311 std::cerr <<
"late type canonicalization DONE@"
1313 <<
":" << t <<
"\n";
1316 get_environment().canonicalization_is_done(
true);
1318 if (call_reader_next)
1322 xmlTextReaderNext(xml_reader.get());
1330 node = get_corpus_node();
1331 node = xmlNextElementSibling(node);
1334 node = get_corpus_node();
1336 node = xmlNextElementSibling(node->parent);
1338 set_corpus_node(node);
1346typedef shared_ptr<reader> reader_sptr;
1348static int advance_cursor(reader&);
1352static bool read_symbol_db_from_input(reader&,
1355static bool read_location(
const reader&, xmlNodePtr,
location&);
1356static bool read_artificial_location(
const reader&,
1358static bool maybe_set_artificial_location(
const reader&,
1364static bool read_size_and_alignment(xmlNodePtr,
size_t&,
size_t&);
1365static bool read_static(xmlNodePtr,
bool&);
1366static bool read_offset_in_bits(xmlNodePtr,
size_t&);
1367static bool read_cdtor_const(xmlNodePtr,
bool&,
bool&,
bool&);
1368static bool read_is_virtual(xmlNodePtr,
bool&);
1369static bool read_is_struct(xmlNodePtr,
bool&);
1370static bool read_is_anonymous(xmlNodePtr,
bool&);
1373static bool read_elf_symbol_visibility(xmlNodePtr,
1377build_namespace_decl(reader&,
const xmlNodePtr,
bool);
1387build_elf_symbol(reader&,
const xmlNodePtr,
bool);
1390build_elf_symbol_from_reference(reader&,
const xmlNodePtr);
1393build_elf_symbol_db(reader&,
const xmlNodePtr,
bool);
1396build_function_parameter (reader&,
const xmlNodePtr);
1399build_function_decl(reader&,
const xmlNodePtr,
1400 class_or_union_sptr,
bool);
1403build_function_decl_if_not_suppressed(reader&,
const xmlNodePtr,
1404 class_or_union_sptr,
bool);
1407function_is_suppressed(
const reader& rdr,
1411build_var_decl_if_not_suppressed(reader&,
const xmlNodePtr,
bool);
1414build_var_decl(reader&,
const xmlNodePtr,
bool);
1417variable_is_suppressed(
const reader& rdr,
1420static shared_ptr<type_decl>
1421build_type_decl(reader&,
const xmlNodePtr,
bool);
1423static qualified_type_def_sptr
1424build_qualified_type_decl(reader&,
const xmlNodePtr,
bool);
1426static shared_ptr<pointer_type_def>
1427build_pointer_type_def(reader&,
const xmlNodePtr,
bool);
1429static shared_ptr<reference_type_def>
1430build_reference_type_def(reader&,
const xmlNodePtr,
bool);
1432static shared_ptr<function_type>
1433build_function_type(reader&,
const xmlNodePtr,
bool);
1436build_subrange_type(reader&,
const xmlNodePtr,
bool);
1439build_array_type_def(reader&,
const xmlNodePtr,
bool);
1442build_enum_type_decl(reader&,
const xmlNodePtr,
bool);
1444static shared_ptr<typedef_decl>
1445build_typedef_decl(reader&,
const xmlNodePtr,
bool);
1448build_class_decl(reader&,
const xmlNodePtr,
bool);
1450static union_decl_sptr
1451build_union_decl(reader&,
const xmlNodePtr,
bool);
1453static shared_ptr<function_tdecl>
1454build_function_tdecl(reader&,
const xmlNodePtr,
bool);
1456static shared_ptr<class_tdecl>
1457build_class_tdecl(reader&,
const xmlNodePtr,
bool);
1460build_type_tparameter(reader&,
const xmlNodePtr,
1464build_type_composition(reader&,
const xmlNodePtr,
1468build_non_type_tparameter(reader&,
const xmlNodePtr,
1472build_template_tparameter(reader&,
const xmlNodePtr,
1476build_template_parameter(reader&,
const xmlNodePtr,
1483static shared_ptr<type_base>
1484build_type(reader&,
const xmlNodePtr,
bool);
1488static decl_base_sptr handle_type_decl(reader&, xmlNodePtr,
bool);
1489static decl_base_sptr handle_namespace_decl(reader&, xmlNodePtr,
bool);
1490static decl_base_sptr handle_qualified_type_decl(reader&,
1492static decl_base_sptr handle_pointer_type_def(reader&,
1494static decl_base_sptr handle_reference_type_def(reader&,
1496static type_base_sptr handle_function_type(reader&,
1498static decl_base_sptr handle_array_type_def(reader&,
1500static decl_base_sptr handle_enum_type_decl(reader&, xmlNodePtr,
bool);
1501static decl_base_sptr handle_typedef_decl(reader&, xmlNodePtr,
bool);
1502static decl_base_sptr handle_var_decl(reader&, xmlNodePtr,
bool);
1503static decl_base_sptr handle_function_decl(reader&, xmlNodePtr,
bool);
1504static decl_base_sptr handle_class_decl(reader&, xmlNodePtr,
bool);
1505static decl_base_sptr handle_union_decl(reader&, xmlNodePtr,
bool);
1506static decl_base_sptr handle_function_tdecl(reader&, xmlNodePtr,
bool);
1507static decl_base_sptr handle_class_tdecl(reader&, xmlNodePtr,
bool);
1509#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
1510#define RECORD_ARTIFACT_AS_USED_BY(rdr, used, user) \
1511 rdr.record_artifact_as_used_by(used,user)
1512#define RECORD_ARTIFACTS_AS_USED_IN_FN_DECL(rdr, fn) \
1513 rdr.record_artifacts_as_used_in_fn_decl(fn)
1514#define RECORD_ARTIFACTS_AS_USED_IN_FN_TYPE(rdr, fn_type)\
1515 rdr.record_artifacts_as_used_in_fn_type(fn_type)
1517#define RECORD_ARTIFACT_AS_USED_BY(rdr, used, user)
1518#define RECORD_ARTIFACTS_AS_USED_IN_FN_DECL(rdr, fn)
1519#define RECORD_ARTIFACTS_AS_USED_IN_FN_TYPE(rdr, fn_type)
1542 xmlNodePtr parent = node->parent;
1545 && (xmlStrEqual(parent->name, BAD_CAST(
"data-member"))
1546 || xmlStrEqual(parent->name, BAD_CAST(
"member-type"))
1547 || xmlStrEqual(parent->name, BAD_CAST(
"member-function"))
1548 || xmlStrEqual(parent->name, BAD_CAST(
"member-template"))
1549 || xmlStrEqual(parent->name, BAD_CAST(
"template-parameter-type-composition"))
1550 || xmlStrEqual(parent->name, BAD_CAST(
"array-type-def"))))
1552 read_access(parent, access);
1553 parent = parent->parent;
1556 xml_node_decl_base_sptr_map::const_iterator i =
1557 get_xml_node_decl_map().find(parent);
1558 if (i == get_xml_node_decl_map().end())
1560 if (xmlStrEqual(parent->name, BAD_CAST(
"abi-instr")))
1563 get_or_read_and_add_translation_unit(*
this, parent);
1564 return tu->get_global_scope();
1569 push_decl(parent_scope);
1570 scope = dynamic_pointer_cast<scope_decl>
1571 (handle_element_node(*
this, parent,
true));
1573 pop_scope_or_abort(parent_scope);
1576 scope = dynamic_pointer_cast<scope_decl>(i->second);
1591reader::get_scope_for_node(xmlNodePtr node)
1594 return get_scope_for_node(node, access);
1607reader::get_scope_ptr_for_node(xmlNodePtr node)
1627 type_base_sptr t = get_type_decl(
id);
1631 xmlNodePtr n = get_xml_node_from_id(
id);
1638 scope = get_scope_for_node(n, access);
1646 if ((t = get_type_decl(
id)))
1664 pop_scope_or_abort(scope);
1678advance_cursor(reader& rdr)
1681 return xmlTextReaderRead(reader.get());
1693walk_xml_node_to_map_type_ids(reader& rdr,
1696 xmlNodePtr n = node;
1698 if (!n || n->type != XML_ELEMENT_NODE)
1703 string id = CHAR_STR(s);
1704 rdr.map_id_and_node(
id, n);
1707 for (n = xmlFirstElementChild(n); n; n = xmlNextElementSibling(n))
1708 walk_xml_node_to_map_type_ids(rdr, n);
1714 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
1716 if (!rdr.corpus()->is_empty())
1723 char address_size = atoi(
reinterpret_cast<char*
>(addrsize_str.get()));
1729 tu.
set_path(
reinterpret_cast<char*
>(path_str.get()));
1733 if (comp_dir_path_str)
1735 (comp_dir_path_str.get()));
1740 (
reinterpret_cast<char*
>(language_str.get())));
1748 if (rdr.get_id_xml_node_map().empty()
1750 walk_xml_node_to_map_type_ids(rdr, node);
1752 for (xmlNodePtr n = xmlFirstElementChild(node);
1754 n = xmlNextElementSibling(n))
1755 handle_element_node(rdr, n,
true);
1763 rdr.clear_per_translation_unit_data();
1782get_or_read_and_add_translation_unit(reader& rdr, xmlNodePtr node)
1784 corpus_sptr corp = rdr.corpus();
1792 tu_path =
reinterpret_cast<char*
>(path_str.get());
1795 if (corp && !corp->is_empty())
1796 tu = corp->find_translation_unit(tu_path);
1803 if (corp && !corp->is_empty())
1806 if (read_translation_unit(rdr, *tu, node))
1821read_translation_unit_from_input(
fe_iface& iface)
1825 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
1827 xmlNodePtr node = rdr.get_corpus_node();
1838 status = advance_cursor (rdr);
1841 BAD_CAST(
"abi-instr")))
1844 node = xmlTextReaderExpand(reader.get());
1851 for (xmlNodePtr n = rdr.get_corpus_node();
1853 n = xmlNextElementSibling(n))
1855 if (!xmlStrEqual(n->name, BAD_CAST(
"abi-instr")))
1865 tu = get_or_read_and_add_translation_unit(rdr, node);
1867 if (rdr.get_corpus_node())
1873 node = xmlNextElementSibling(node);
1874 rdr.set_corpus_node(node);
1898read_symbol_db_from_input(reader& rdr,
1906 if (!rdr.get_corpus_node())
1912 status = advance_cursor (rdr);
1917 bool has_fn_syms =
false, has_var_syms =
false;
1919 BAD_CAST(
"elf-function-symbols")))
1922 BAD_CAST(
"elf-variable-symbols")))
1923 has_var_syms =
true;
1927 xmlNodePtr node = xmlTextReaderExpand(reader.get());
1932 fn_symdb = build_elf_symbol_db(rdr, node,
true);
1933 else if (has_var_syms)
1934 var_symdb = build_elf_symbol_db(rdr, node,
false);
1936 xmlTextReaderNext(reader.get());
1939 for (xmlNodePtr n = rdr.get_corpus_node(); n; n = xmlNextElementSibling(n))
1941 bool has_fn_syms =
false, has_var_syms =
false;
1942 if (xmlStrEqual(n->name, BAD_CAST(
"elf-function-symbols")))
1944 else if (xmlStrEqual(n->name, BAD_CAST(
"elf-variable-symbols")))
1945 has_var_syms =
true;
1948 rdr.set_corpus_node(n);
1953 fn_symdb = build_elf_symbol_db(rdr, n,
true);
1954 else if (has_var_syms)
1955 var_symdb = build_elf_symbol_db(rdr, n,
false);
1974build_needed(xmlNode* node, vector<string>& needed)
1976 if (!node || !xmlStrEqual(node->name,BAD_CAST(
"elf-needed")))
1979 for (xmlNodePtr n = xmlFirstElementChild(node);
1981 n = xmlNextElementSibling(n))
1983 if (!xmlStrEqual(n->name, BAD_CAST(
"dependency")))
1991 needed.push_back(name);
2007read_elf_needed_from_input(reader& rdr,
2008 vector<string>& needed)
2014 xmlNodePtr node = 0;
2016 if (rdr.get_corpus_node() == 0)
2021 status = advance_cursor (rdr);
2027 BAD_CAST(
"elf-needed")))
2030 node = xmlTextReaderExpand(reader.get());
2036 for (xmlNodePtr n = rdr.get_corpus_node();
2038 n = xmlNextElementSibling(n))
2040 if (!xmlStrEqual(n->name, BAD_CAST(
"elf-needed")))
2047 bool result =
false;
2050 result = build_needed(node, needed);
2051 node = xmlNextElementSibling(node);
2052 rdr.set_corpus_node(node);
2087 for (suppr::suppressions_type::const_iterator i = supprs.begin();
2090 if ((*i)->get_drops_artifact_from_ir())
2091 rdr.suppressions().push_back(*i);
2106 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
2107 rdr.tracking_non_reachable_types(flag);
2110#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
2119vector<type_base_sptr>*
2120get_types_from_type_id(
fe_iface& iface,
const string& type_id)
2122 xml_reader::reader& rdr =
dynamic_cast<xml_reader::reader&
>(iface);
2123 auto it = rdr.m_types_map.find(type_id);
2124 if (it == rdr.m_types_map.end())
2135unordered_map<type_or_decl_base*, vector<type_or_decl_base*>>*
2136get_artifact_used_by_relation_map(fe_iface& iface)
2138 xml_reader::reader& rdr =
dynamic_cast<xml_reader::reader&
>(iface);
2139 return &rdr.m_artifact_used_by_map;
2159 string version_string;
2164 if (version_string.empty())
2171 corp.set_format_major_version_number(v[0]);
2172 corp.set_format_minor_version_number(v[1]);
2185 corpus_group_sptr nil;
2187 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
2196 status = advance_cursor (rdr);
2199 BAD_CAST(
"abi-corpus-group")))
2202 if (!rdr.corpus_group())
2204 corpus_group_sptr g(
new corpus_group(rdr.get_environment(),
2206 g->set_origin(corpus::NATIVE_XML_ORIGIN);
2207 rdr.corpus_group(g);
2210 corpus_group_sptr group = rdr.corpus_group();
2212 handle_version_attribute(reader, *group);
2216 group->set_path(
reinterpret_cast<char*
>(path_str.get()));
2218 xmlNodePtr node = xmlTextReaderExpand(reader.get());
2222 node = xmlFirstElementChild(node);
2223 rdr.set_corpus_node(node);
2227 while ((corp = rdr.read_corpus(sts)))
2228 rdr.corpus_group()->add_corpus(corp);
2230 xmlTextReaderNext(reader.get());
2232 return rdr.corpus_group();
2294 rdr.perform_late_type_canonicalizing();
2316 rdr.perform_late_type_canonicalizing();
2331 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
2333 rdr.options().env.canonicalization_is_done(
false);
2334 rdr.perform_late_type_canonicalizing();
2335 rdr.options().env.canonicalization_is_done(
true);
2348handle_element_node(reader& rdr, xmlNodePtr node,
2349 bool add_to_current_scope)
2355 ((decl = handle_namespace_decl(rdr, node, add_to_current_scope))
2356 ||(decl = handle_type_decl(rdr, node, add_to_current_scope))
2357 ||(decl = handle_qualified_type_decl(rdr, node,
2358 add_to_current_scope))
2359 ||(decl = handle_pointer_type_def(rdr, node,
2360 add_to_current_scope))
2361 || (decl = handle_reference_type_def(rdr, node, add_to_current_scope))
2362 || (decl = handle_function_type(rdr, node, add_to_current_scope))
2363 || (decl = handle_array_type_def(rdr, node, add_to_current_scope))
2364 || (decl = handle_enum_type_decl(rdr, node,
2365 add_to_current_scope))
2366 || (decl = handle_typedef_decl(rdr, node,
2367 add_to_current_scope))
2368 || (decl = handle_var_decl(rdr, node,
2369 add_to_current_scope))
2370 || (decl = handle_function_decl(rdr, node,
2371 add_to_current_scope))
2372 || (decl = handle_class_decl(rdr, node,
2373 add_to_current_scope))
2374 || (decl = handle_union_decl(rdr, node,
2375 add_to_current_scope))
2376 || (decl = handle_function_tdecl(rdr, node,
2377 add_to_current_scope))
2378 || (decl = handle_class_tdecl(rdr, node,
2379 add_to_current_scope)));
2384 if (rdr.tracking_non_reachable_types())
2386 if (type_base_sptr t =
is_type(decl))
2388 corpus_sptr abi = rdr.corpus();
2390 bool is_non_reachable_type =
false;
2391 read_is_non_reachable_type(node, is_non_reachable_type);
2392 if (!is_non_reachable_type)
2393 abi->record_type_as_reachable_from_public_interfaces(*t);
2408read_location(
const reader& rdr,
2413 size_t line = 0, column = 0;
2416 file_path = CHAR_STR(f);
2418 if (file_path.empty())
2419 return read_artificial_location(rdr, node, loc);
2422 line = atoi(CHAR_STR(l));
2424 return read_artificial_location(rdr, node, loc);
2427 column = atoi(CHAR_STR(c));
2429 reader& c =
const_cast<reader&
>(rdr);
2430 loc = c.get_translation_unit()->get_loc_mgr().create_new_location(file_path,
2447read_artificial_location(
const reader& rdr,
2455 size_t line = 0, column = 0;
2460 file_path =
reinterpret_cast<const char*
>(node->doc->URL);
2462 reader& c =
const_cast<reader&
>(rdr);
2464 c.get_translation_unit()->get_loc_mgr().create_new_location(file_path,
2466 loc.set_is_artificial(
true);
2486maybe_set_artificial_location(
const reader& rdr,
2490 if (artefact && !artefact->has_artificial_location())
2493 if (read_artificial_location(rdr, node, l))
2495 artefact->set_artificial_location(l);
2514 string v = CHAR_STR(s);
2517 vis = decl_base::VISIBILITY_DEFAULT;
2518 else if (v ==
"hidden")
2519 vis = decl_base::VISIBILITY_HIDDEN;
2520 else if (v ==
"internal")
2521 vis = decl_base::VISIBILITY_INTERNAL;
2522 else if (v ==
"protected")
2523 vis = decl_base::VISIBILITY_PROTECTED;
2525 vis = decl_base::VISIBILITY_DEFAULT;
2543 string b = CHAR_STR(s);
2546 bind = decl_base::BINDING_GLOBAL;
2547 else if (b ==
"local")
2548 bind = decl_base::BINDING_LOCAL;
2549 else if (b ==
"weak")
2550 bind = decl_base::BINDING_WEAK;
2552 bind = decl_base::BINDING_GLOBAL;
2571 string a = CHAR_STR(s);
2574 access = private_access;
2575 else if (a ==
"protected")
2576 access = protected_access;
2577 else if (a ==
"public")
2578 access = public_access;
2606read_size_and_alignment(xmlNodePtr node,
2607 size_t& size_in_bits,
2608 size_t& align_in_bits)
2611 bool got_something =
false;
2614 size_in_bits = atoll(CHAR_STR(s));
2615 got_something =
true;
2620 align_in_bits = atoll(CHAR_STR(s));
2621 got_something =
true;
2623 return got_something;
2636read_static(xmlNodePtr node,
bool& is_static)
2640 string b = CHAR_STR(s);
2641 is_static = b ==
"yes";
2654read_offset_in_bits(xmlNodePtr node,
2655 size_t& offset_in_bits)
2659 offset_in_bits = strtoull(CHAR_STR(s), 0, 0);
2687read_cdtor_const(xmlNodePtr node,
2688 bool& is_constructor,
2689 bool& is_destructor,
2694 string b = CHAR_STR(s);
2696 is_constructor =
true;
2698 is_constructor =
false;
2705 string b = CHAR_STR(s);
2707 is_destructor =
true;
2709 is_destructor =
false;
2716 string b = CHAR_STR(s);
2737read_is_declaration_only(xmlNodePtr node,
bool& is_decl_only)
2741 string str = CHAR_STR(s);
2743 is_decl_only =
true;
2745 is_decl_only =
false;
2761read_is_artificial(xmlNodePtr node,
bool& is_artificial)
2765 string is_artificial_str = CHAR_STR(s) ? CHAR_STR(s) :
"";
2766 is_artificial = is_artificial_str ==
"yes";
2785read_tracking_non_reachable_types(xmlNodePtr node,
2786 bool& tracking_non_reachable_types)
2791 string tracking_non_reachable_types_str = CHAR_STR(s) ? CHAR_STR(s) :
"";
2792 tracking_non_reachable_types =
2793 (tracking_non_reachable_types_str ==
"yes")
2812read_is_non_reachable_type(xmlNodePtr node,
bool& is_non_reachable_type)
2817 string is_non_reachable_type_str = CHAR_STR(s) ? CHAR_STR(s) :
"";
2818 is_non_reachable_type =
2819 (is_non_reachable_type_str ==
"yes")
2837read_naming_typedef_id_string(xmlNodePtr node,
string& naming_typedef_id)
2856read_is_virtual(xmlNodePtr node,
bool& is_virtual)
2860 string str = CHAR_STR(s);
2879read_is_struct(xmlNodePtr node,
bool& is_struct)
2883 string str = CHAR_STR(s);
2902read_is_anonymous(xmlNodePtr node,
bool& is_anonymous)
2906 string str = CHAR_STR(s);
2907 is_anonymous = (str ==
"yes");
2984read_type_id_string(xmlNodePtr node,
string& type_id)
2988 type_id = CHAR_STR(s);
2994#ifdef WITH_DEBUG_SELF_COMPARISON
3009maybe_map_type_with_type_id(
const type_base_sptr& t,
3010 const string& type_id)
3015 const environment& env = t->get_environment();
3016 if (!env.self_comparison_debug_is_on()
3020 const_cast<environment&
>(env).
3021 get_pointer_type_id_map()[
reinterpret_cast<uintptr_t
>(t.get())] = type_id;
3040maybe_map_type_with_type_id(
const type_base_sptr& t,
3046 const environment&env = t->get_environment();
3047 if (!env.self_comparison_debug_is_on()
3052 if (!read_type_id_string(node, type_id) || type_id.empty())
3055 return maybe_map_type_with_type_id(t, type_id);
3069maybe_set_naming_typedef(reader& rdr,
3071 const decl_base_sptr& decl)
3073 string naming_typedef_id;
3074 read_naming_typedef_id_string(node, naming_typedef_id);
3075 if (!naming_typedef_id.empty())
3078 is_typedef(rdr.build_or_get_type_decl(naming_typedef_id,
true));
3080 decl->set_naming_typedef(naming_typedef);
3100build_namespace_decl(reader& rdr,
3101 const xmlNodePtr node,
3102 bool add_to_current_scope)
3105 if (!node || !xmlStrEqual(node->name, BAD_CAST(
"namespace-decl")))
3108 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
3120 read_location(rdr, node, loc);
3122 const environment& env = rdr.get_environment();
3124 maybe_set_artificial_location(rdr, node, decl);
3125 rdr.push_decl_to_scope(decl,
3126 add_to_current_scope
3127 ? rdr.get_scope_ptr_for_node(node)
3129 rdr.map_xml_node_to_decl(node, decl);
3131 for (xmlNodePtr n = xmlFirstElementChild(node);
3133 n = xmlNextElementSibling(n))
3134 handle_element_node(rdr, n,
true);
3136 rdr.pop_scope_or_abort(decl);
3153build_elf_symbol(reader& rdr,
const xmlNodePtr node,
3154 bool drop_if_suppressed)
3159 || node->type != XML_ELEMENT_NODE
3160 || !xmlStrEqual(node->name, BAD_CAST(
"elf-symbol")))
3169 size = strtol(CHAR_STR(s), NULL, 0);
3171 bool is_defined =
true;
3176 if (value ==
"true" || value ==
"yes")
3182 bool is_common =
false;
3187 if (value ==
"true" || value ==
"yes")
3193 string version_string;
3197 bool is_default_version =
false;
3202 if (value ==
"true" || value ==
"yes")
3203 is_default_version =
true;
3207 read_elf_symbol_type(node, type);
3210 read_elf_symbol_binding(node, binding);
3213 read_elf_symbol_visibility(node, visibility);
3215 elf_symbol::version version(version_string, is_default_version);
3218 if (drop_if_suppressed && is_suppressed)
3221 const environment& env = rdr.get_environment();
3223 size, name, type, binding,
3224 is_defined, is_common,
3225 version, visibility);
3227 e->set_is_suppressed(is_suppressed);
3230 e->set_crc(strtoull(CHAR_STR(s), NULL, 0));
3236 e->set_namespace(ns);
3256build_elf_symbol_from_reference(reader& rdr,
const xmlNodePtr node)
3276 rdr.corpus()->get_symtab()->lookup_symbol(name);
3278 for (
const auto& symbol : symbols)
3279 if (symbol->get_id_string() == sym_id)
3298build_elf_symbol_db(reader& rdr,
3299 const xmlNodePtr node,
3309 && !xmlStrEqual(node->name, BAD_CAST(
"elf-function-symbols")))
3313 && !xmlStrEqual(node->name, BAD_CAST(
"elf-variable-symbols")))
3316 rdr.set_corpus_node(node);
3318 typedef std::unordered_map<xmlNodePtr, elf_symbol_sptr>
3319 xml_node_ptr_elf_symbol_sptr_map_type;
3320 xml_node_ptr_elf_symbol_sptr_map_type xml_node_ptr_elf_symbol_map;
3323 for (xmlNodePtr n = xmlFirstElementChild(node);
3325 n = xmlNextElementSibling(n))
3326 if ((sym = build_elf_symbol(rdr, n,
false)))
3328 id_sym_map[sym->get_id_string()] = sym;
3329 xml_node_ptr_elf_symbol_map[n] = sym;
3332 if (id_sym_map.empty())
3336 string_elf_symbols_map_type::iterator it;
3337 for (string_elf_symbol_sptr_map_type::const_iterator i = id_sym_map.begin();
3338 i != id_sym_map.end();
3340 (*map)[i->second->get_name()].push_back(i->second);
3343 for (xml_node_ptr_elf_symbol_sptr_map_type::const_iterator x =
3344 xml_node_ptr_elf_symbol_map.begin();
3345 x != xml_node_ptr_elf_symbol_map.end();
3350 string alias_id = CHAR_STR(s);
3353 std::vector<std::string> elems;
3354 std::stringstream aliases(alias_id);
3356 while (std::getline(aliases, item,
','))
3357 elems.push_back(item);
3358 for (std::vector<string>::iterator alias = elems.begin();
3359 alias != elems.end(); ++alias)
3361 string_elf_symbol_sptr_map_type::const_iterator i =
3362 id_sym_map.find(*alias);
3366 x->second->get_main_symbol()->add_alias(i->second);
3379static shared_ptr<function_decl::parameter>
3380build_function_parameter(reader& rdr,
const xmlNodePtr node)
3382 shared_ptr<function_decl::parameter> nil;
3384 if (!node || !xmlStrEqual(node->name, BAD_CAST(
"parameter")))
3387 bool is_variadic =
false;
3388 string is_variadic_str;
3392 is_variadic_str = CHAR_STR(s) ? CHAR_STR(s) :
"";
3393 is_variadic = is_variadic_str ==
"yes";
3396 bool is_artificial =
false;
3397 read_is_artificial(node, is_artificial);
3401 type_id = CHAR_STR(a);
3403 type_base_sptr type;
3405 type = rdr.get_environment().get_variadic_parameter_type();
3409 type = rdr.build_or_get_type_decl(type_id,
true);
3418 read_location(rdr, node, loc);
3421 (
new function_decl::parameter(type, name, loc,
3422 is_variadic, is_artificial));
3446build_function_decl(reader& rdr,
3447 const xmlNodePtr node,
3448 class_or_union_sptr as_method_decl,
3449 bool add_to_current_scope)
3453 if (!xmlStrEqual(node->name, BAD_CAST(
"function-decl")))
3460 string mangled_name;
3465 && !mangled_name.empty()
3466 && as_method_decl->find_member_function_sptr(mangled_name))
3469 as_method_decl->find_member_function_sptr(mangled_name);
3476 inline_prop = CHAR_STR(s);
3477 bool declared_inline = inline_prop ==
"yes";
3480 read_visibility(node, vis);
3483 read_binding(node, bind);
3485 size_t size = rdr.get_translation_unit()->get_address_size(), align = 0;
3486 read_size_and_alignment(node, size, align);
3489 read_location(rdr, node, loc);
3491 const environment& env = rdr.get_environment();
3493 std::vector<function_decl::parameter_sptr> parms;
3494 type_base_sptr return_type = env.get_void_type();
3496 for (xmlNodePtr n = xmlFirstElementChild(node);
3498 n = xmlNextElementSibling(n))
3500 if (xmlStrEqual(n->name, BAD_CAST(
"parameter")))
3503 build_function_parameter(rdr, n))
3506 else if (xmlStrEqual(n->name, BAD_CAST(
"return")))
3511 type_id = CHAR_STR(s);
3512 if (!type_id.empty())
3513 return_type = rdr.build_or_get_type_decl(type_id,
true);
3518 ?
new method_type(return_type, as_method_decl,
3521 :
new function_type(return_type,
3522 parms, size, align));
3526 fn_type->set_is_artificial(
true);
3529 ?
new method_decl (name, fn_type,
3530 declared_inline, loc,
3531 mangled_name, vis, bind)
3532 :
new function_decl(name, fn_type,
3533 declared_inline, loc,
3537 maybe_set_artificial_location(rdr, node, fn_decl);
3538 rdr.push_decl_to_scope(fn_decl,
3539 add_to_current_scope
3540 ? rdr.get_scope_ptr_for_node(node)
3542 RECORD_ARTIFACTS_AS_USED_IN_FN_DECL(rdr, fn_decl);
3546 fn_decl->set_symbol(sym);
3548 if (fn_decl->get_symbol() && fn_decl->get_symbol()->is_public())
3549 fn_decl->set_is_in_public_symbol_table(
true);
3551 rdr.get_translation_unit()->bind_function_type_life_time(fn_type);
3553 rdr.maybe_canonicalize_type(fn_type, !add_to_current_scope);
3555 rdr.maybe_add_fn_to_exported_decls(fn_decl.get());
3582build_function_decl_if_not_suppressed(reader& rdr,
3583 const xmlNodePtr node,
3584 class_or_union_sptr as_method_decl,
3585 bool add_to_current_scope)
3589 if (function_is_suppressed(rdr, node))
3595 fn = build_function_decl(rdr, node, as_method_decl,
3596 add_to_current_scope);
3612function_is_suppressed(
const reader& rdr, xmlNodePtr node)
3618 string flinkage_name;
3622 scope_decl* scope = rdr.get_cur_scope();
3641type_is_suppressed(
const reader& rdr, xmlNodePtr node)
3647 location type_location;
3648 read_location(rdr, node, type_location);
3650 scope_decl* scope = rdr.get_cur_scope();
3654 bool type_is_private =
false;
3673build_var_decl_if_not_suppressed(reader& rdr,
3674 const xmlNodePtr node,
3675 bool add_to_current_scope)
3678 if (!variable_is_suppressed(rdr, node))
3679 var = build_var_decl(rdr, node, add_to_current_scope);
3692variable_is_suppressed(
const reader& rdr, xmlNodePtr node)
3698 string linkage_name;
3702 scope_decl* scope = rdr.get_cur_scope();
3720variable_is_suppressed(
const reader& rdr,
3721 const scope_decl* scope,
3726 v.get_linkage_name());
3737static shared_ptr<var_decl>
3738build_var_decl(reader& rdr,
3739 const xmlNodePtr node,
3740 bool add_to_current_scope)
3742 shared_ptr<var_decl> nil;
3744 if (!xmlStrEqual(node->name, BAD_CAST(
"var-decl")))
3753 type_id = CHAR_STR(s);
3754 type_base_sptr underlying_type = rdr.build_or_get_type_decl(type_id,
3758 string mangled_name;
3763 read_visibility(node, vis);
3766 read_binding(node, bind);
3769 read_location(rdr, node, locus);
3772 locus, mangled_name,
3774 maybe_set_artificial_location(rdr, node, decl);
3778 decl->set_symbol(sym);
3780 rdr.push_decl_to_scope(decl,
3781 add_to_current_scope
3782 ? rdr.get_scope_ptr_for_node(node)
3784 if (add_to_current_scope)
3788 RECORD_ARTIFACT_AS_USED_BY(rdr, underlying_type, decl);
3791 if (decl->get_symbol() && decl->get_symbol()->is_public())
3792 decl->set_is_in_public_symbol_table(
true);
3802static decl_base_sptr
3803build_ir_node_for_void_type(reader& rdr)
3805 const environment& env = rdr.get_environment();
3807 type_base_sptr t = env.get_void_type();
3811 return type_declaration;
3825static decl_base_sptr
3826build_ir_node_for_void_pointer_type(reader& rdr)
3828 const environment& env = rdr.get_environment();
3830 type_base_sptr t = env.get_void_pointer_type();
3834 return type_declaration;
3849build_type_decl(reader& rdr,
3850 const xmlNodePtr node,
3851 bool add_to_current_scope)
3853 shared_ptr<type_decl> nil;
3855 if (!xmlStrEqual(node->name, BAD_CAST(
"type-decl")))
3858 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
3874 size_t size_in_bits= 0;
3876 size_in_bits = atoi(CHAR_STR(s));
3878 size_t alignment_in_bits = 0;
3880 alignment_in_bits = atoi(CHAR_STR(s));
3882 bool is_decl_only =
false;
3883 read_is_declaration_only(node, is_decl_only);
3886 read_location(rdr, node, loc);
3888 bool is_anonymous =
false;
3889 read_is_anonymous(node, is_anonymous);
3891 if (type_base_sptr d = rdr.get_type_decl(
id))
3899 ABG_ASSERT(ty->get_size_in_bits() == size_in_bits);
3900 ABG_ASSERT(ty->get_alignment_in_bits() == alignment_in_bits);
3904 const environment& env = rdr.get_environment();
3906 if (name == env.get_variadic_parameter_type_name())
3907 decl =
is_type_decl(env.get_variadic_parameter_type());
3908 else if (name ==
"void")
3911 decl.reset(
new type_decl(env, name, size_in_bits,
3912 alignment_in_bits, loc));
3913 maybe_set_artificial_location(rdr, node, decl);
3914 decl->set_is_anonymous(is_anonymous);
3915 decl->set_is_declaration_only(is_decl_only);
3916 if (rdr.push_and_key_type_decl(decl, node, add_to_current_scope))
3918 rdr.map_xml_node_to_decl(node, decl);
3936static qualified_type_def_sptr
3937build_qualified_type_decl(reader& rdr,
3938 const xmlNodePtr node,
3939 bool add_to_current_scope)
3941 qualified_type_def_sptr nil;
3942 if (!xmlStrEqual(node->name, BAD_CAST(
"qualified-type-def")))
3945 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
3947 qualified_type_def_sptr result =
3948 dynamic_pointer_cast<qualified_type_def>(d);
3960 read_location(rdr, node, loc);
3965 const_str = CHAR_STR(s);
3966 bool const_cv = const_str ==
"yes";
3968 string volatile_str;
3970 volatile_str = CHAR_STR(s);
3971 bool volatile_cv = volatile_str ==
"yes";
3973 string restrict_str;
3975 restrict_str = CHAR_STR(s);
3976 bool restrict_cv = restrict_str ==
"yes";
3979 cv = cv | qualified_type_def::CV_CONST;
3981 cv = cv | qualified_type_def::CV_VOLATILE;
3983 cv = cv | qualified_type_def::CV_RESTRICT;
3987 type_id = CHAR_STR(s);
3990 shared_ptr<type_base> underlying_type =
3991 rdr.build_or_get_type_decl(type_id,
true);
3994 qualified_type_def_sptr decl;
3995 if (type_base_sptr t = rdr.get_type_decl(
id))
4002 decl.reset(
new qualified_type_def(underlying_type, cv, loc));
4003 maybe_set_artificial_location(rdr, node, decl);
4004 rdr.push_and_key_type_decl(decl, node, add_to_current_scope);
4005 RECORD_ARTIFACT_AS_USED_BY(rdr, underlying_type, decl);
4008 rdr.map_xml_node_to_decl(node, decl);
4025build_pointer_type_def(reader& rdr,
4026 const xmlNodePtr node,
4027 bool add_to_current_scope)
4030 shared_ptr<pointer_type_def> nil;
4032 if (!xmlStrEqual(node->name, BAD_CAST(
"pointer-type-def")))
4035 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4038 dynamic_pointer_cast<pointer_type_def>(d);
4048 if (type_base_sptr t = rdr.get_type_decl(
id))
4057 type_id = CHAR_STR(s);
4059 size_t size_in_bits = rdr.get_translation_unit()->get_address_size();
4060 size_t alignment_in_bits = 0;
4061 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
4063 read_location(rdr, node, loc);
4065 type_base_sptr pointed_to_type =
4066 rdr.build_or_get_type_decl(type_id,
true);
4070 if (rdr.get_environment().is_void_type(pointed_to_type))
4078 t.reset(
new pointer_type_def(pointed_to_type,
4083 maybe_set_artificial_location(rdr, node, t);
4085 if (rdr.push_and_key_type_decl(t, node, add_to_current_scope))
4086 rdr.map_xml_node_to_decl(node, t);
4088 RECORD_ARTIFACT_AS_USED_BY(rdr, pointed_to_type, t);
4104static shared_ptr<reference_type_def>
4105build_reference_type_def(reader& rdr,
4106 const xmlNodePtr node,
4107 bool add_to_current_scope)
4109 shared_ptr<reference_type_def> nil;
4111 if (!xmlStrEqual(node->name, BAD_CAST(
"reference-type-def")))
4114 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4117 dynamic_pointer_cast<reference_type_def>(d);
4127 if (type_base_sptr d = rdr.get_type_decl(
id))
4135 read_location(rdr, node, loc);
4139 bool is_lvalue = kind ==
"lvalue";
4141 size_t size_in_bits = rdr.get_translation_unit()->get_address_size();
4142 size_t alignment_in_bits = 0;
4143 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
4147 type_id = CHAR_STR(s);
4157 is_lvalue, size_in_bits,
4158 alignment_in_bits, loc));
4159 maybe_set_artificial_location(rdr, node, t);
4160 if (rdr.push_and_key_type_decl(t, node, add_to_current_scope))
4161 rdr.map_xml_node_to_decl(node, t);
4163 type_base_sptr pointed_to_type =
4164 rdr.build_or_get_type_decl(type_id,
true);
4166 t->set_pointed_to_type(pointed_to_type);
4167 RECORD_ARTIFACT_AS_USED_BY(rdr, pointed_to_type, t);
4185build_function_type(reader& rdr,
4186 const xmlNodePtr node,
4191 if (!xmlStrEqual(node->name, BAD_CAST(
"function-type")))
4199 string method_class_id;
4201 method_class_id = CHAR_STR(s);
4203 bool is_method_t = !method_class_id.empty();
4205 size_t size = rdr.get_translation_unit()->get_address_size(), align = 0;
4206 read_size_and_alignment(node, size, align);
4208 const environment& env = rdr.get_environment();
4209 std::vector<shared_ptr<function_decl::parameter> > parms;
4210 type_base_sptr return_type = env.get_void_type();
4212 class_or_union_sptr method_class_type;
4222 ?
new method_type(method_class_type,
4225 :
new function_type(return_type,
4226 parms, size, align));
4228 rdr.get_translation_unit()->bind_function_type_life_time(fn_type);
4229 rdr.key_type_decl(fn_type,
id);
4230 RECORD_ARTIFACTS_AS_USED_IN_FN_TYPE(rdr, fn_type);
4232 for (xmlNodePtr n = xmlFirstElementChild(node);
4234 n = xmlNextElementSibling(n))
4236 if (xmlStrEqual(n->name, BAD_CAST(
"parameter")))
4239 build_function_parameter(rdr, n))
4242 else if (xmlStrEqual(n->name, BAD_CAST(
"return")))
4247 type_id = CHAR_STR(s);
4248 if (!type_id.empty())
4249 fn_type->set_return_type(rdr.build_or_get_type_decl
4254 fn_type->set_parameters(parms);
4270build_subrange_type(reader& rdr,
4271 const xmlNodePtr node,
4272 bool add_to_current_scope)
4276 if (!node || !xmlStrEqual(node->name, BAD_CAST(
"subrange")))
4279 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4282 dynamic_pointer_cast<array_type_def::subrange_type>(d);
4296 if (type_base_sptr d = rdr.get_type_decl(
id))
4307 uint64_t length = 0;
4309 bool is_infinite =
false;
4312 if (
string(CHAR_STR(s)) ==
"infinite" ||
string(CHAR_STR(s)) ==
"unknown")
4315 length = strtoull(CHAR_STR(s), NULL, 0);
4318 int64_t lower_bound = 0, upper_bound = 0;
4319 bool bounds_present =
false;
4322 lower_bound = strtoll(CHAR_STR(s), NULL, 0);
4324 if (!
string(CHAR_STR(s)).empty())
4325 upper_bound = strtoll(CHAR_STR(s), NULL, 0);
4326 bounds_present =
true;
4328 || (length == (uint64_t) upper_bound - lower_bound + 1));
4331 string underlying_type_id;
4333 underlying_type_id = CHAR_STR(s);
4335 type_base_sptr underlying_type;
4336 if (!underlying_type_id.empty())
4338 underlying_type = rdr.build_or_get_type_decl(underlying_type_id,
true);
4343 read_location(rdr, node, loc);
4347 array_type_def::subrange_type::bound_value max_bound;
4348 array_type_def::subrange_type::bound_value min_bound;
4354 max_bound.set_signed(length - 1);
4360 min_bound.set_signed(lower_bound);
4361 max_bound.set_signed(upper_bound);
4365 (
new array_type_def::subrange_type(rdr.get_environment(),
4366 name, min_bound, max_bound,
4367 underlying_type, loc));
4368 maybe_set_artificial_location(rdr, node, p);
4369 p->is_infinite(is_infinite);
4371 if (rdr.push_and_key_type_decl(p, node, add_to_current_scope))
4372 rdr.map_xml_node_to_decl(node, p);
4389build_array_type_def(reader& rdr,
4390 const xmlNodePtr node,
4391 bool add_to_current_scope)
4396 if (!xmlStrEqual(node->name, BAD_CAST(
"array-type-def")))
4399 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4402 dynamic_pointer_cast<array_type_def>(d);
4412 if (type_base_sptr d = rdr.get_type_decl(
id))
4421 dimensions = atoi(CHAR_STR(s));
4425 type_id = CHAR_STR(s);
4429 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4432 dynamic_pointer_cast<array_type_def>(d);
4437 size_t size_in_bits = 0, alignment_in_bits = 0;
4438 bool has_size_in_bits =
false;
4443 size_in_bits = strtoull(CHAR_STR(s), &endptr, 0);
4444 if (*endptr !=
'\0')
4446 if (!strcmp(CHAR_STR(s),
"infinite")
4447 ||!strcmp(CHAR_STR(s),
"unknown"))
4448 size_in_bits = (size_t) -1;
4452 has_size_in_bits =
true;
4457 alignment_in_bits = strtoull(CHAR_STR(s), &endptr, 0);
4458 if (*endptr !=
'\0')
4463 read_location(rdr, node, loc);
4466 for (xmlNodePtr n = xmlFirstElementChild(node);
4468 n = xmlNextElementSibling(n))
4469 if (xmlStrEqual(n->name, BAD_CAST(
"subrange")))
4472 build_subrange_type(rdr, n,
true))
4474 MAYBE_MAP_TYPE_WITH_TYPE_ID(s, n);
4475 if (add_to_current_scope)
4478 rdr.maybe_canonicalize_type(s);
4480 subranges.push_back(s);
4485 type_base_sptr type =
4486 rdr.build_or_get_type_decl(type_id,
true);
4490 maybe_set_artificial_location(rdr, node, ar_type);
4491 if (rdr.push_and_key_type_decl(ar_type, node, add_to_current_scope))
4492 rdr.map_xml_node_to_decl(node, ar_type);
4493 RECORD_ARTIFACT_AS_USED_BY(rdr, type, ar_type);
4495 if (dimensions != ar_type->get_dimension_count()
4496 || (alignment_in_bits
4497 != ar_type->get_element_type()->get_alignment_in_bits()))
4500 if (has_size_in_bits && size_in_bits != (
size_t) -1
4501 && size_in_bits != ar_type->get_size_in_bits())
4504 size_t element_size = ar_type->get_element_type()->get_size_in_bits();
4505 if (element_size && element_size != (
size_t)-1)
4508 size_t bad_count = 0;
4509 for (vector<array_type_def::subrange_sptr>::const_iterator i =
4511 i != subranges.end();
4513 bad_count += (*i)->get_length();
4514 if (size_in_bits == bad_count * element_size)
4516 static bool reported =
false;
4519 std::cerr <<
"notice: Found incorrectly calculated array "
4520 <<
"sizes in XML - this is benign.\nOlder versions "
4521 <<
"of libabigail miscalculated multidimensional "
4522 <<
"array sizes." << std::endl;
4528 std::cerr <<
"error: Found incorrectly calculated array size in "
4529 <<
"XML (id=\"" <<
id <<
"\")." << std::endl;
4553build_enum_type_decl_if_not_suppressed(reader& rdr,
4554 const xmlNodePtr node,
4555 bool add_to_current_scope)
4558 if (!type_is_suppressed(rdr, node))
4559 enum_type = build_enum_type_decl(rdr, node, add_to_current_scope);
4575build_enum_type_decl(reader& rdr,
4576 const xmlNodePtr node,
4577 bool add_to_current_scope)
4581 if (!xmlStrEqual(node->name, BAD_CAST(
"enum-decl")))
4584 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4587 dynamic_pointer_cast<enum_type_decl>(d);
4596 string linkage_name;
4601 read_location(rdr, node, loc);
4603 bool is_decl_only =
false;
4604 read_is_declaration_only(node, is_decl_only);
4606 bool is_anonymous =
false;
4607 read_is_anonymous(node, is_anonymous);
4609 bool is_artificial =
false;
4610 read_is_artificial(node, is_artificial);
4618 string base_type_id;
4620 for (xmlNodePtr n = xmlFirstElementChild(node);
4622 n = xmlNextElementSibling(n))
4624 if (xmlStrEqual(n->name, BAD_CAST(
"underlying-type")))
4628 base_type_id = CHAR_STR(a);
4631 else if (xmlStrEqual(n->name, BAD_CAST(
"enumerator")))
4643 value = strtoll(CHAR_STR(a), NULL, 0);
4647 if ((errno == ERANGE)
4648 && (value == LLONG_MIN || value == LLONG_MAX))
4652 enums.push_back(enum_type_decl::enumerator(name, value));
4656 type_base_sptr underlying_type =
4657 rdr.build_or_get_type_decl(base_type_id,
true);
4662 enums, linkage_name));
4663 maybe_set_artificial_location(rdr, node, t);
4664 t->set_is_anonymous(is_anonymous);
4665 t->set_is_artificial(is_artificial);
4666 t->set_is_declaration_only(is_decl_only);
4667 if (rdr.push_and_key_type_decl(t, node, add_to_current_scope))
4669 maybe_set_naming_typedef(rdr, node, t);
4670 rdr.map_xml_node_to_decl(node, t);
4671 RECORD_ARTIFACT_AS_USED_BY(rdr, underlying_type, t);
4686static shared_ptr<typedef_decl>
4687build_typedef_decl(reader& rdr,
4688 const xmlNodePtr node,
4689 bool add_to_current_scope)
4691 shared_ptr<typedef_decl> nil;
4693 if (!xmlStrEqual(node->name, BAD_CAST(
"typedef-decl")))
4696 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4708 if (type_base_sptr t = rdr.get_type_decl(
id))
4720 read_location(rdr, node, loc);
4724 type_id = CHAR_STR(s);
4727 type_base_sptr underlying_type(rdr.build_or_get_type_decl(type_id,
true));
4731 maybe_set_artificial_location(rdr, node, t);
4732 rdr.push_and_key_type_decl(t, node, add_to_current_scope);
4733 rdr.map_xml_node_to_decl(node, t);
4734 RECORD_ARTIFACT_AS_USED_BY(rdr, underlying_type, t);
4751build_class_decl_if_not_suppressed(reader& rdr,
4752 const xmlNodePtr node,
4753 bool add_to_current_scope)
4756 if (!type_is_suppressed(rdr, node))
4757 class_type = build_class_decl(rdr, node, add_to_current_scope);
4773static union_decl_sptr
4774build_union_decl_if_not_suppressed(reader& rdr,
4775 const xmlNodePtr node,
4776 bool add_to_current_scope)
4778 union_decl_sptr union_type;
4779 if (!type_is_suppressed(rdr, node))
4780 union_type = build_union_decl(rdr, node, add_to_current_scope);
4797build_class_decl(reader& rdr,
4798 const xmlNodePtr node,
4799 bool add_to_current_scope)
4803 if (!xmlStrEqual(node->name, BAD_CAST(
"class-decl")))
4806 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4817 size_t size_in_bits = 0, alignment_in_bits = 0;
4818 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
4821 read_visibility(node, vis);
4823 bool is_artificial =
false;
4824 read_is_artificial(node, is_artificial);
4831 read_location(rdr, node, loc);
4840 bool is_decl_only =
false;
4841 read_is_declaration_only(node, is_decl_only);
4843 bool is_struct =
false;
4844 read_is_struct(node, is_struct);
4846 bool is_anonymous =
false;
4847 read_is_anonymous(node, is_anonymous);
4853 if (type_base_sptr t = rdr.get_type_decl(
id))
4859 const vector<type_base_sptr> *types_ptr = 0;
4860 if (!is_anonymous && !previous_definition)
4861 types_ptr = rdr.get_all_type_decls(
id);
4867 for (vector<type_base_sptr>::const_iterator i = types_ptr->begin();
4868 i != types_ptr->end();
4873 if (klass->get_is_declaration_only()
4874 && !klass->get_definition_of_declaration())
4875 previous_declaration = klass;
4876 else if (!klass->get_is_declaration_only()
4877 && !previous_definition)
4878 previous_definition = klass;
4879 if (previous_definition && previous_declaration)
4883 if (previous_declaration)
4884 ABG_ASSERT(previous_declaration->get_name() == name);
4886 if (previous_definition)
4887 ABG_ASSERT(previous_definition->get_name() == name);
4889 if (is_decl_only && previous_declaration)
4890 return previous_declaration;
4893 const environment& env = rdr.get_environment();
4895 if (!is_decl_only && previous_definition)
4901 decl = previous_definition;
4906 decl.reset(
new class_decl(env, name, is_struct));
4908 decl->set_size_in_bits(size_in_bits);
4910 decl->set_is_anonymous(is_anonymous);
4911 decl->set_location(loc);
4914 decl.reset(
new class_decl(env, name, size_in_bits, alignment_in_bits,
4915 is_struct, loc, vis, bases, mbrs,
4916 data_mbrs, mbr_functions, is_anonymous));
4919 maybe_set_artificial_location(rdr, node, decl);
4920 decl->set_is_artificial(is_artificial);
4923 bool is_def_of_decl =
false;
4925 def_id = CHAR_STR(s);
4927 if (!def_id.empty())
4929 decl_base_sptr d =
is_decl(rdr.get_type_decl(def_id));
4930 if (d && d->get_is_declaration_only())
4932 is_def_of_decl =
true;
4933 decl->set_earlier_declaration(d);
4934 d->set_definition_of_declaration(decl);
4940 && !decl->get_is_declaration_only()
4941 && previous_declaration)
4947 decl->set_earlier_declaration(
is_decl(previous_declaration));
4948 for (vector<type_base_sptr>::const_iterator i = types_ptr->begin();
4949 i != types_ptr->end();
4954 if (d->get_is_declaration_only()
4955 && !d->get_definition_of_declaration())
4957 previous_declaration->set_definition_of_declaration(decl);
4958 is_def_of_decl =
true;
4963 if (is_decl_only && previous_definition)
4968 && !decl->get_definition_of_declaration());
4969 decl->set_definition_of_declaration(previous_definition);
4972 ABG_ASSERT(!is_decl_only || !is_def_of_decl);
4974 rdr.push_decl_to_scope(decl,
4975 add_to_current_scope
4976 ? rdr.get_scope_ptr_for_node(node)
4979 rdr.map_xml_node_to_decl(node, decl);
4980 rdr.key_type_decl(decl,
id);
4983 maybe_set_naming_typedef(rdr, node, decl);
4985 for (xmlNodePtr n = xmlFirstElementChild(node);
4987 n = xmlNextElementSibling(n))
4989 if (xmlStrEqual(n->name, BAD_CAST(
"base-class")))
4995 read_access(n, access);
4999 type_id = CHAR_STR(s);
5000 shared_ptr<class_decl> b =
5001 dynamic_pointer_cast<class_decl>
5002 (rdr.build_or_get_type_decl(type_id,
true));
5005 if (decl->find_base_class(b->get_qualified_name()))
5011 size_t offset_in_bits = 0;
5012 bool offset_present = read_offset_in_bits (n, offset_in_bits);
5014 bool is_virtual =
false;
5015 read_is_virtual (n, is_virtual);
5017 shared_ptr<class_decl::base_spec> base (
new class_decl::base_spec
5020 ? (
long) offset_in_bits
5023 decl->add_base_specifier(base);
5025 else if (xmlStrEqual(n->name, BAD_CAST(
"member-type")))
5031 read_access(n, access);
5033 rdr.map_xml_node_to_decl(n, decl);
5035 for (xmlNodePtr p = xmlFirstElementChild(n);
5037 p = xmlNextElementSibling(p))
5039 if (type_base_sptr t =
5040 build_type(rdr, p,
true))
5045 rdr.maybe_canonicalize_type(t, !add_to_current_scope);
5047 string id = CHAR_STR(i);
5049 rdr.key_type_decl(t,
id);
5050 rdr.map_xml_node_to_decl(p, td);
5054 else if (xmlStrEqual(n->name, BAD_CAST(
"data-member")))
5056 rdr.map_xml_node_to_decl(n, decl);
5062 read_access(n, access);
5064 bool is_laid_out =
false;
5065 size_t offset_in_bits = 0;
5066 if (read_offset_in_bits(n, offset_in_bits))
5069 bool is_static =
false;
5070 read_static(n, is_static);
5072 for (xmlNodePtr p = xmlFirstElementChild(n);
5074 p = xmlNextElementSibling(p))
5077 build_var_decl(rdr, p,
false))
5079 if (decl->find_data_member(v))
5087 decl_base_sptr d = rdr.pop_decl();
5092 if (!variable_is_suppressed(rdr, decl.get(), *v))
5094 decl->add_data_member(v, access,
5099 rdr.maybe_add_var_to_exported_decls(v.get());
5109 RECORD_ARTIFACT_AS_USED_BY(rdr, v->get_type(), decl);
5112 RECORD_ARTIFACT_AS_USED_BY(rdr, v->get_type(), v);
5113 RECORD_ARTIFACT_AS_USED_BY(rdr, v, decl);
5119 else if (xmlStrEqual(n->name, BAD_CAST(
"member-function")))
5125 read_access(n, access);
5127 bool is_virtual =
false;
5128 ssize_t vtable_offset = -1;
5133 vtable_offset = atoi(CHAR_STR(s));
5136 bool is_static =
false;
5137 read_static(n, is_static);
5139 bool is_ctor =
false, is_dtor =
false, is_const =
false;
5140 read_cdtor_const(n, is_ctor, is_dtor, is_const);
5142 for (xmlNodePtr p = xmlFirstElementChild(n);
5144 p = xmlNextElementSibling(p))
5147 build_function_decl_if_not_suppressed(rdr, p, decl,
5154 if (vtable_offset != -1)
5160 rdr.map_xml_node_to_decl(n, decl);
5165 else if (xmlStrEqual(n->name, BAD_CAST(
"member-template")))
5167 rdr.map_xml_node_to_decl(n, decl);
5173 read_access(n, access);
5175 bool is_static =
false;
5176 read_static(n, is_static);
5178 bool is_ctor =
false, is_dtor =
false, is_const =
false;
5179 read_cdtor_const(n, is_ctor, is_dtor, is_const);
5181 for (xmlNodePtr p = xmlFirstElementChild(n);
5183 p = xmlNextElementSibling(p))
5185 if (shared_ptr<function_tdecl> f =
5186 build_function_tdecl(rdr, p,
5189 shared_ptr<member_function_template> m
5190 (
new member_function_template(f, access, is_static,
5191 is_ctor, is_const));
5193 decl->add_member_function_template(m);
5195 else if (shared_ptr<class_tdecl> c =
5196 build_class_tdecl(rdr, p,
5199 member_class_template_sptr m(
new member_class_template(c,
5203 decl->add_member_class_template(m);
5209 rdr.pop_scope_or_abort(decl);
5226static union_decl_sptr
5227build_union_decl(reader& rdr,
5228 const xmlNodePtr node,
5229 bool add_to_current_scope)
5231 union_decl_sptr nil;
5233 if (!xmlStrEqual(node->name, BAD_CAST(
"union-decl")))
5236 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
5238 union_decl_sptr result = dynamic_pointer_cast<union_decl>(d);
5247 size_t size_in_bits = 0, alignment_in_bits = 0;
5248 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
5251 read_visibility(node, vis);
5253 bool is_artificial =
false;
5254 read_is_artificial(node, is_artificial);
5261 read_location(rdr, node, loc);
5267 union_decl_sptr decl;
5269 bool is_decl_only =
false;
5270 read_is_declaration_only(node, is_decl_only);
5272 bool is_anonymous =
false;
5273 read_is_anonymous(node, is_anonymous);
5276 union_decl_sptr previous_definition, previous_declaration;
5277 const vector<type_base_sptr> *types_ptr = 0;
5279 types_ptr = rdr.get_all_type_decls(
id);
5285 for (vector<type_base_sptr>::const_iterator i = types_ptr->begin();
5286 i != types_ptr->end();
5291 if (onion->get_is_declaration_only()
5292 && !onion->get_definition_of_declaration())
5293 previous_declaration = onion;
5294 else if (!onion->get_is_declaration_only()
5295 && !previous_definition)
5296 previous_definition = onion;
5297 if (previous_definition && previous_declaration)
5301 if (previous_declaration)
5302 ABG_ASSERT(previous_declaration->get_name() == name);
5304 if (previous_definition)
5305 ABG_ASSERT(previous_definition->get_name() == name);
5307 if (is_decl_only && previous_declaration)
5308 return previous_declaration;
5311 const environment& env = rdr.get_environment();
5313 if (!is_decl_only && previous_definition)
5319 decl = previous_definition;
5323 decl.reset(
new union_decl(env, name));
5325 decl.reset(
new union_decl(env, name,
5333 maybe_set_artificial_location(rdr, node, decl);
5334 decl->set_is_artificial(is_artificial);
5337 bool is_def_of_decl =
false;
5339 def_id = CHAR_STR(s);
5341 if (!def_id.empty())
5344 dynamic_pointer_cast<class_decl>(rdr.get_type_decl(def_id));
5345 if (d && d->get_is_declaration_only())
5347 is_def_of_decl =
true;
5348 decl->set_earlier_declaration(d);
5349 d->set_definition_of_declaration(decl);
5355 && !decl->get_is_declaration_only()
5356 && previous_declaration)
5362 decl->set_earlier_declaration(previous_declaration);
5363 for (vector<type_base_sptr>::const_iterator i = types_ptr->begin();
5364 i != types_ptr->end();
5369 if (d->get_is_declaration_only()
5370 && !d->get_definition_of_declaration())
5372 previous_declaration->set_definition_of_declaration(decl);
5373 is_def_of_decl =
true;
5378 if (is_decl_only && previous_definition)
5383 && !decl->get_definition_of_declaration());
5384 decl->set_definition_of_declaration(previous_definition);
5387 ABG_ASSERT(!is_decl_only || !is_def_of_decl);
5389 rdr.push_decl_to_scope(decl,
5390 add_to_current_scope
5391 ? rdr.get_scope_ptr_for_node(node)
5394 rdr.map_xml_node_to_decl(node, decl);
5395 rdr.key_type_decl(decl,
id);
5397 maybe_set_naming_typedef(rdr, node, decl);
5399 for (xmlNodePtr n = xmlFirstElementChild(node);
5401 n = xmlNextElementSibling(n))
5403 if (xmlStrEqual(n->name, BAD_CAST(
"member-type")))
5406 read_access(n, access);
5408 rdr.map_xml_node_to_decl(n, decl);
5410 for (xmlNodePtr p = xmlFirstElementChild(n);
5412 p = xmlNextElementSibling(p))
5414 if (type_base_sptr t =
5415 build_type(rdr, p,
true))
5420 rdr.maybe_canonicalize_type(t, !add_to_current_scope);
5422 string id = CHAR_STR(i);
5424 rdr.key_type_decl(t,
id);
5425 rdr.map_xml_node_to_decl(p, td);
5429 else if (xmlStrEqual(n->name, BAD_CAST(
"data-member")))
5431 rdr.map_xml_node_to_decl(n, decl);
5434 read_access(n, access);
5436 bool is_laid_out =
true;
5437 size_t offset_in_bits = 0;
5438 bool is_static =
false;
5439 read_static(n, is_static);
5441 for (xmlNodePtr p = xmlFirstElementChild(n);
5443 p = xmlNextElementSibling(p))
5446 build_var_decl(rdr, p,
false))
5448 if (decl->find_data_member(v))
5456 decl_base_sptr d = rdr.pop_decl();
5461 || !variable_is_suppressed(rdr, decl.get(), *v))
5463 decl->add_data_member(v, access,
5476 RECORD_ARTIFACT_AS_USED_BY(rdr, v->get_type(), decl);
5479 RECORD_ARTIFACT_AS_USED_BY(rdr, v->get_type(), v);
5480 RECORD_ARTIFACT_AS_USED_BY(rdr, v, decl);
5486 else if (xmlStrEqual(n->name, BAD_CAST(
"member-function")))
5488 rdr.map_xml_node_to_decl(n, decl);
5491 read_access(n, access);
5493 bool is_static =
false;
5494 read_static(n, is_static);
5496 bool is_ctor =
false, is_dtor =
false, is_const =
false;
5497 read_cdtor_const(n, is_ctor, is_dtor, is_const);
5499 for (xmlNodePtr p = xmlFirstElementChild(n);
5501 p = xmlNextElementSibling(p))
5504 build_function_decl_if_not_suppressed(rdr, p, decl,
5518 else if (xmlStrEqual(n->name, BAD_CAST(
"member-template")))
5520 rdr.map_xml_node_to_decl(n, decl);
5523 read_access(n, access);
5525 bool is_static =
false;
5526 read_static(n, is_static);
5528 bool is_ctor =
false, is_dtor =
false, is_const =
false;
5529 read_cdtor_const(n, is_ctor, is_dtor, is_const);
5531 for (xmlNodePtr p = xmlFirstElementChild(n);
5533 p = xmlNextElementSibling(p))
5536 build_function_tdecl(rdr, p,
5539 member_function_template_sptr m
5540 (
new member_function_template(f, access, is_static,
5541 is_ctor, is_const));
5543 decl->add_member_function_template(m);
5546 build_class_tdecl(rdr, p,
5549 member_class_template_sptr m(
new member_class_template(c,
5553 decl->add_member_class_template(m);
5559 rdr.pop_scope_or_abort(decl);
5576static shared_ptr<function_tdecl>
5577build_function_tdecl(reader& rdr,
5578 const xmlNodePtr node,
5579 bool add_to_current_scope)
5581 shared_ptr<function_tdecl> nil, result;
5583 if (!xmlStrEqual(node->name, BAD_CAST(
"function-template-decl")))
5589 if (
id.empty() || rdr.get_fn_tmpl_decl(
id))
5593 read_location(rdr, node, loc);
5596 read_visibility(node, vis);
5599 read_binding(node, bind);
5601 const environment& env = rdr.get_environment();
5604 maybe_set_artificial_location(rdr, node, fn_tmpl_decl);
5606 rdr.push_decl_to_scope(fn_tmpl_decl,
5607 add_to_current_scope
5608 ? rdr.get_scope_ptr_for_node(node)
5610 rdr.key_fn_tmpl_decl(fn_tmpl_decl,
id);
5611 rdr.map_xml_node_to_decl(node, fn_tmpl_decl);
5613 unsigned parm_index = 0;
5614 for (xmlNodePtr n = xmlFirstElementChild(node);
5616 n = xmlNextElementSibling(n))
5619 build_template_parameter(rdr, n, parm_index, fn_tmpl_decl))
5621 fn_tmpl_decl->add_template_parameter(parm);
5627 fn_tmpl_decl->set_pattern(f);
5630 rdr.key_fn_tmpl_decl(fn_tmpl_decl,
id);
5632 return fn_tmpl_decl;
5648build_class_tdecl(reader& rdr,
5649 const xmlNodePtr node,
5650 bool add_to_current_scope)
5654 if (!xmlStrEqual(node->name, BAD_CAST(
"class-template-decl")))
5660 if (
id.empty() || rdr.get_class_tmpl_decl(
id))
5664 read_location(rdr, node, loc);
5667 read_visibility(node, vis);
5669 const environment& env = rdr.get_environment();
5672 maybe_set_artificial_location(rdr, node, class_tmpl);
5674 if (add_to_current_scope)
5675 rdr.push_decl_to_scope(class_tmpl, node);
5676 rdr.key_class_tmpl_decl(class_tmpl,
id);
5677 rdr.map_xml_node_to_decl(node, class_tmpl);
5679 unsigned parm_index = 0;
5680 for (xmlNodePtr n = xmlFirstElementChild(node);
5682 n = xmlNextElementSibling(n))
5685 build_template_parameter(rdr, n, parm_index, class_tmpl))
5687 class_tmpl->add_template_parameter(parm);
5691 build_class_decl_if_not_suppressed(rdr, n,
5692 add_to_current_scope))
5695 rdr.maybe_canonicalize_type(c,
false);
5696 class_tmpl->set_pattern(c);
5700 rdr.key_class_tmpl_decl(class_tmpl,
id);
5721build_type_tparameter(reader& rdr,
5722 const xmlNodePtr node,
5728 if (!xmlStrEqual(node->name, BAD_CAST(
"template-type-parameter")))
5739 type_id = CHAR_STR(s);
5740 if (!type_id.empty()
5741 && !(result = dynamic_pointer_cast<type_tparameter>
5742 (rdr.build_or_get_type_decl(type_id,
true))))
5750 read_location(rdr, node,loc);
5752 result.reset(
new type_tparameter(index, tdecl, name, loc));
5753 maybe_set_artificial_location(rdr, node, result);
5756 rdr.push_decl_to_scope(
is_decl(result), node);
5758 rdr.push_and_key_type_decl(result, node,
true);
5760 rdr.maybe_canonicalize_type(result,
false);
5780build_type_composition(reader& rdr,
5781 const xmlNodePtr node,
5787 if (!xmlStrEqual(node->name, BAD_CAST(
"template-parameter-type-composition")))
5790 type_base_sptr composed_type;
5791 result.reset(
new type_composition(index, tdecl, composed_type));
5792 rdr.push_decl_to_scope(
is_decl(result), node);
5794 for (xmlNodePtr n = xmlFirstElementChild(node);
5796 n = xmlNextElementSibling(n))
5798 if ((composed_type =
5799 build_pointer_type_def(rdr, n,
5802 build_reference_type_def(rdr, n,
5805 build_array_type_def(rdr, n,
5808 build_qualified_type_decl(rdr, n,
5811 rdr.maybe_canonicalize_type(composed_type,
5813 result->set_composed_type(composed_type);
5837build_non_type_tparameter(reader& rdr,
5838 const xmlNodePtr node,
5844 if (!xmlStrEqual(node->name, BAD_CAST(
"template-non-type-parameter")))
5849 type_id = CHAR_STR(s);
5850 type_base_sptr type;
5852 || !(type = rdr.build_or_get_type_decl(type_id,
true)))
5860 read_location(rdr, node,loc);
5862 r.reset(
new non_type_tparameter(index, tdecl, name, type, loc));
5863 maybe_set_artificial_location(rdr, node, r);
5864 rdr.push_decl_to_scope(
is_decl(r), node);
5884build_template_tparameter(reader& rdr,
5885 const xmlNodePtr node,
5891 if (!xmlStrEqual(node->name, BAD_CAST(
"template-template-parameter")))
5902 type_id = CHAR_STR(s);
5904 if (!type_id.empty()
5905 && !(dynamic_pointer_cast<template_tparameter>
5906 (rdr.build_or_get_type_decl(type_id,
true))))
5914 read_location(rdr, node, loc);
5918 maybe_set_artificial_location(rdr, node, result);
5919 rdr.push_decl_to_scope(result, node);
5923 for (xmlNodePtr n = xmlFirstElementChild(node);
5925 n = xmlNextElementSibling(n))
5926 if (shared_ptr<template_parameter> p =
5927 build_template_parameter(rdr, n, parm_index, result))
5929 result->add_template_parameter(p);
5935 rdr.key_type_decl(result,
id);
5936 rdr.maybe_canonicalize_type(result,
false);
5958build_template_parameter(reader& rdr,
5959 const xmlNodePtr node,
5963 shared_ptr<template_parameter> r;
5964 ((r = build_type_tparameter(rdr, node, index, tdecl))
5965 || (r = build_non_type_tparameter(rdr, node, index, tdecl))
5966 || (r = build_template_tparameter(rdr, node, index, tdecl))
5967 || (r = build_type_composition(rdr, node, index, tdecl)));
5980static type_base_sptr
5981build_type(reader& rdr,
5982 const xmlNodePtr node,
5983 bool add_to_current_scope)
5987 ((t = build_type_decl(rdr, node, add_to_current_scope))
5988 || (t = build_qualified_type_decl(rdr, node, add_to_current_scope))
5989 || (t = build_pointer_type_def(rdr, node, add_to_current_scope))
5990 || (t = build_reference_type_def(rdr, node , add_to_current_scope))
5991 || (t = build_function_type(rdr, node, add_to_current_scope))
5992 || (t = build_array_type_def(rdr, node, add_to_current_scope))
5993 || (t = build_subrange_type(rdr, node, add_to_current_scope))
5994 || (t = build_enum_type_decl_if_not_suppressed(rdr, node,
5995 add_to_current_scope))
5996 || (t = build_typedef_decl(rdr, node, add_to_current_scope))
5997 || (t = build_class_decl_if_not_suppressed(rdr, node,
5998 add_to_current_scope))
5999 || (t = build_union_decl_if_not_suppressed(rdr, node,
6000 add_to_current_scope)));
6002 if (rdr.tracking_non_reachable_types() && t)
6004 corpus_sptr abi = rdr.corpus();
6006 bool is_non_reachable_type =
false;
6007 read_is_non_reachable_type(node, is_non_reachable_type);
6008 if (!is_non_reachable_type)
6009 abi->record_type_as_reachable_from_public_interfaces(*t);
6012 MAYBE_MAP_TYPE_WITH_TYPE_ID(t, node);
6015 rdr.maybe_canonicalize_type(t,
false );
6024static decl_base_sptr
6025handle_type_decl(reader& rdr,
6027 bool add_to_current_scope)
6029 type_decl_sptr decl = build_type_decl(rdr, node, add_to_current_scope);
6030 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6031 if (decl && decl->get_scope())
6032 rdr.maybe_canonicalize_type(decl,
false);
6041static decl_base_sptr
6042handle_namespace_decl(reader& rdr,
6044 bool add_to_current_scope)
6047 add_to_current_scope);
6056static decl_base_sptr
6057handle_qualified_type_decl(reader& rdr,
6059 bool add_to_current_scope)
6061 qualified_type_def_sptr decl =
6062 build_qualified_type_decl(rdr, node,
6063 add_to_current_scope);
6064 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6065 if (decl && decl->get_scope())
6066 rdr.maybe_canonicalize_type(decl,
false);
6075static decl_base_sptr
6076handle_pointer_type_def(reader& rdr,
6078 bool add_to_current_scope)
6081 add_to_current_scope);
6082 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6083 if (decl && decl->get_scope())
6084 rdr.maybe_canonicalize_type(decl,
false);
6093static decl_base_sptr
6094handle_reference_type_def(reader& rdr,
6096 bool add_to_current_scope)
6099 add_to_current_scope);
6100 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6101 if (decl && decl->get_scope())
6102 rdr.maybe_canonicalize_type(decl,
false);
6111static type_base_sptr
6112handle_function_type(reader& rdr,
6114 bool add_to_current_scope)
6117 add_to_current_scope);
6118 MAYBE_MAP_TYPE_WITH_TYPE_ID(type, node);
6119 rdr.maybe_canonicalize_type(type,
true);
6128static decl_base_sptr
6129handle_array_type_def(reader& rdr,
6131 bool add_to_current_scope)
6134 add_to_current_scope);
6135 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6136 rdr.maybe_canonicalize_type(decl,
false);
6143static decl_base_sptr
6144handle_enum_type_decl(reader& rdr,
6146 bool add_to_current_scope)
6149 build_enum_type_decl_if_not_suppressed(rdr, node,
6150 add_to_current_scope);
6151 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6152 if (decl && decl->get_scope())
6153 rdr.maybe_canonicalize_type(decl,
false);
6160static decl_base_sptr
6161handle_typedef_decl(reader& rdr,
6163 bool add_to_current_scope)
6166 add_to_current_scope);
6167 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6168 if (decl && decl->get_scope())
6169 rdr.maybe_canonicalize_type(decl,
false);
6181static decl_base_sptr
6182handle_var_decl(reader& rdr,
6184 bool add_to_current_scope)
6186 decl_base_sptr decl = build_var_decl_if_not_suppressed(rdr, node,
6187 add_to_current_scope);
6188 rdr.maybe_add_var_to_exported_decls(
is_var_decl(decl).get());
6198static decl_base_sptr
6199handle_function_decl(reader& rdr,
6201 bool add_to_current_scope)
6203 return build_function_decl_if_not_suppressed(rdr, node,
class_decl_sptr(),
6204 add_to_current_scope);
6213static decl_base_sptr
6214handle_class_decl(reader& rdr,
6216 bool add_to_current_scope)
6219 build_class_decl_if_not_suppressed(rdr, node, add_to_current_scope);
6220 MAYBE_MAP_TYPE_WITH_TYPE_ID(
is_type(decl), node);
6221 if (decl && decl->get_scope())
6222 rdr.maybe_canonicalize_type(decl,
false);
6232static decl_base_sptr
6233handle_union_decl(reader& rdr,
6235 bool add_to_current_scope)
6237 union_decl_sptr decl =
6238 build_union_decl_if_not_suppressed(rdr, node, add_to_current_scope);
6239 MAYBE_MAP_TYPE_WITH_TYPE_ID(
is_type(decl), node);
6240 if (decl && decl->get_scope())
6241 rdr.maybe_canonicalize_type(decl,
false);
6251static decl_base_sptr
6252handle_function_tdecl(reader& rdr,
6254 bool add_to_current_scope)
6257 add_to_current_scope);
6266static decl_base_sptr
6267handle_class_tdecl(reader& rdr,
6269 bool add_to_current_scope)
6272 add_to_current_scope);
6289 return read_translation_unit_from_input(read_rdr);
6314 corpus_sptr corp = result->corpus();
6315 corp->set_origin(corpus::NATIVE_XML_ORIGIN);
6316#ifdef WITH_DEBUG_SELF_COMPARISON
6317 if (env.self_comparison_debug_is_on())
6318 env.set_self_comparison_debug_input(result->corpus());
6320 result->set_path(path);
6337 corpus_sptr corp = result->corpus();
6338 corp->set_origin(corpus::NATIVE_XML_ORIGIN);
6339#ifdef WITH_DEBUG_SELF_COMPARISON
6340 if (env.self_comparison_debug_is_on())
6341 env.set_self_comparison_debug_input(result->corpus());
6364 return rdr->read_corpus(sts);
6386 corpus_sptr corp = rdr->read_corpus(sts);
6392#ifdef WITH_DEBUG_SELF_COMPARISON
6411load_canonical_type_ids(fe_iface& iface,
const string &file_path)
6413 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
6415 xmlDocPtr doc = xmlReadFile(file_path.c_str(), NULL, XML_PARSE_NOERROR);
6419 xmlNodePtr node = xmlDocGetRootElement(doc);
6442 if (xmlStrcmp(node->name, (xmlChar*)
"abixml-types-check"))
6445 for (node = xmlFirstElementChild(node);
6447 node = xmlNextElementSibling(node))
6449 if (xmlStrcmp(node->name, (xmlChar*)
"type"))
6452 string id, canonical_address;
6453 xmlNodePtr data = xmlFirstElementChild(node);
6454 if (data && !xmlStrcmp(data->name, (xmlChar*)
"id")
6455 && data->children && xmlNodeIsText(data->children))
6456 id = (
char*) XML_GET_CONTENT(data->children);
6458 data = xmlNextElementSibling(data);
6459 if (data && !xmlStrcmp(data->name, (xmlChar*)
"c")
6460 && data->children && xmlNodeIsText(data->children))
6462 canonical_address = (
char*) XML_GET_CONTENT(data->children);
6463 std::stringstream s;
6464 s << canonical_address;
6472 rdr.get_environment().get_type_id_canonical_type_map()[id] = v;
This file contains the declarations for the fe_iface a.k.a "Front End Interface".
#define ABG_ASSERT(cond)
This is a wrapper around the 'assert' glibc call. It allows for its argument to have side effects,...
#define XML_READER_GET_NODE_NAME(reader)
Get the name of the current element node the reader is pointing to. Note that this macro returns an i...
#define XML_READER_GET_ATTRIBUTE(reader, name)
Get the value of attribute 'name' on the current node of 'reader' which is an instance of shared_ptr<...
#define XML_NODE_GET_ATTRIBUTE(node, name)
Get the value of attribute 'name' ont the instance of xmlNodePtr denoted by 'node'.
#define XML_READER_GET_NODE_TYPE(reader)
Get the type of the current node of the shared_ptr<xmlTextReader> passed in argument.
This file contains the declarations of the entry points to de-serialize an instance of abigail::trans...
This contains the private implementation of the suppression engine of libabigail.
This contains the declarations for the symtab reader.
The base class of all libabigail front-ends: The Front End Interface.
status
The status of the fe_iface::read_corpus call.
shared_ptr< subrange_type > subrange_sptr
Convenience typedef for a shared pointer on a function_decl::subrange.
std::vector< subrange_sptr > subranges_type
Convenience typedef for a vector of subrange_sptr.
vector< base_spec_sptr > base_specs
Convenience typedef.
vector< method_decl_sptr > member_functions
Convenience typedef.
vector< var_decl_sptr > data_members
Convenience typedef.
vector< type_base_sptr > member_types
Convenience typedef.
Abstracts the building of the set of exported variables and functions.
Abstraction of a group of corpora.
This is the abstraction of a set of translation units (themselves seen as bundles of unitary abi arte...
void set_soname(const string &)
Setter for the soname property of the corpus.
exported_decls_builder_sptr get_exported_decls_builder() const
Getter for the object that is responsible for determining what decls ought to be in the set of export...
string & get_path() const
Get the file path associated to the corpus file.
void set_origin(origin)
Setter for the origin of the corpus.
void set_path(const string &)
Set the file path associated to the corpus file.
virtual bool recording_types_reachable_from_public_interface_supported()
Test if the recording of reachable types (and thus, indirectly, the recording of non-reachable types)...
void set_needed(const vector< string > &)
Setter of the needed property of the corpus.
void set_architecture_name(const string &)
Setter for the architecture name of the corpus.
void set_symtab(symtab_reader::symtab_sptr)
Setter for the symtab object.
The base type of all declarations.
visibility
ELF visibility.
binding
The binding of a symbol.
static bool get_name_and_version_from_id(const string &id, string &name, string &ver)
Given the ID of a symbol, get the name and the version of said symbol.
type
The type of a symbol.
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, const abg_compat::optional< uint32_t > &crc={}, const abg_compat::optional< std::string > &ns={}, bool is_suppressed=false)
Factory of instances of elf_symbol.
visibility
The visibility of the symbol.
std::vector< enumerator > enumerators
Convenience typedef for a list of enumerator.
This is an abstraction of the set of resources necessary to manage several aspects of the internal re...
bool canonicalization_is_done() const
Test if the canonicalization of types created out of the current environment is done.
Abstraction for a function declaration.
shared_ptr< parameter > parameter_sptr
Convenience typedef for a shared pointer on a function_decl::parameter.
const type_base_sptr get_return_type() const
const std::vector< parameter_sptr > & get_parameters() const
Abstraction of a function type.
type_base_sptr get_return_type() const
Getter for the return type of the current instance of function_type.
const parameters & get_parameters() const
Getter for the set of parameters of the current intance of function_type.
This abstracts the global scope of a given translation unit.
The source location of a token.
CV
Bit field values representing the cv qualifiers of the underlying type.
A declaration that introduces a scope.
This is the abstraction of the set of relevant artefacts (types, variable declarations,...
void set_address_size(char)
Setter of the address size in this translation unit.
void set_corpus(corpus *)
Set the corpus this translation unit is a member of.
void set_language(language l)
Setter of the language of the source code of the translation unit.
const scope_decl_sptr & get_global_scope() const
Getter of the the global scope of the translation unit.
void set_compilation_dir_path(const std::string &)
Set the path of the directory that was 'current' when the translation unit was compiled.
void set_path(const string &)
Set the path associated to the current instance of translation_unit.
The base class of both types and declarations.
const translation_unit * get_translation_unit() const
Get the translation_unit this ABI artifact belongs to.
Abstraction of a function suppression specification.
Base type of a direct suppression specifications types.
bool has_soname_related_property() const
Test if the current suppression has a property related to SONAMEs.
bool has_file_name_related_property() const
Test if the current suppression has a property related to file name.
Abstraction of a type suppression specification.
static symtab_ptr load(Elf *elf_handle, const ir::environment &env, symbol_predicate is_suppressed=NULL)
Construct a symtab object and instantiate it from an ELF handle. Also pass in the ir::environment we ...
translation_unit_sptr read_translation_unit_from_buffer(const string &buffer, environment &env)
Parse an ABI instrumentation file (in XML format) from an in-memory buffer.
void add_reader_suppressions(reader &rdr, const suppr::suppressions_type &supprs)
Add suppressions specifications to the set of suppressions to be used during the construction of the ...
translation_unit_sptr read_translation_unit_from_istream(istream *in, environment &env)
De-serialize a translation unit from an ABI Instrumentation xml file coming from an input stream.
corpus_sptr read_corpus_from_abixml(std::istream *in, environment &env)
De-serialize an ABI corpus from an input XML document which root node is 'abi-corpus'.
corpus_group_sptr read_corpus_group_from_input(fe_iface &iface)
Parse the input XML document containing an ABI corpus group, represented by an 'abi-corpus-group' ele...
corpus_sptr read_corpus_from_abixml_file(const string &path, environment &env)
De-serialize an ABI corpus from an XML document file which root node is 'abi-corpus'.
translation_unit_sptr read_translation_unit_from_file(const string &input_file, environment &env)
Parse an ABI instrumentation file (in XML format) at a given path.
corpus_group_sptr read_corpus_group_from_abixml(std::istream *in, environment &env)
De-serialize an ABI corpus group from an input XML document which root node is 'abi-corpus-group'.
fe_iface_sptr create_reader(const string &path, environment &env)
Create an xml_reader::reader to read a native XML ABI file.
void consider_types_not_reachable_from_public_interfaces(fe_iface &iface, bool flag)
Configure the reader so that types not reachable from public interface are taken into account when th...
corpus_group_sptr read_corpus_group_from_abixml_file(const string &path, environment &env)
De-serialize an ABI corpus group from an XML document file which root node is 'abi-corpus-group'.
shared_ptr< type_tparameter > type_tparameter_sptr
Convenience typedef for a shared pointer to type_tparameter.
shared_ptr< reference_type_def > reference_type_def_sptr
Convenience typedef for a shared pointer on a reference_type_def.
bool is_non_canonicalized_type(const type_base *t)
Test if a given type is allowed to be non canonicalized.
shared_ptr< function_decl > function_decl_sptr
Convenience typedef for a shared pointer on a function_decl.
access_specifier
Access specifier for class members.
shared_ptr< class_tdecl > class_tdecl_sptr
Convenience typedef for a shared pointer on a class_tdecl.
void set_member_function_is_virtual(function_decl &f, bool is_virtual)
Set the virtual-ness of a member function.
scope_decl * get_type_scope(type_base *t)
Get the scope of a given type.
bool is_type(const type_or_decl_base &tod)
Test whether a declaration is a type.
bool is_anonymous_data_member(const decl_base &d)
Test if a decl is an anonymous data member.
array_type_def::subrange_type * is_subrange_type(const type_or_decl_base *type)
Test if a type is an array_type_def::subrange_type.
shared_ptr< elf_symbol > elf_symbol_sptr
A convenience typedef for a shared pointer to elf_symbol.
void set_member_function_vtable_offset(function_decl &f, ssize_t s)
Set the vtable offset of a member function.
shared_ptr< non_type_tparameter > non_type_tparameter_sptr
Convenience typedef for shared pointer to non_type_template_parameter.
bool odr_is_relevant(const type_or_decl_base &artifact)
By looking at the language of the TU a given ABI artifact belongs to, test if the ONE Definition Rule...
bool is_class_type(const type_or_decl_base &t)
Test whether a type is a class.
shared_ptr< array_type_def > array_type_def_sptr
Convenience typedef for a shared pointer on a array_type_def.
array_type_def * is_array_type(const type_or_decl_base *type)
Test if a type is an array_type_def.
reference_type_def * is_reference_type(type_or_decl_base *t)
Test whether a type is a reference_type_def.
void set_member_function_is_dtor(function_decl &f, bool d)
Set the destructor-ness property of a member function.
shared_ptr< template_parameter > template_parameter_sptr
Convenience typedef for shared pointer to template parameter.
class_or_union * is_class_or_union_type(const type_or_decl_base *t)
Test if a type is a class_or_union.
shared_ptr< class_decl > class_decl_sptr
Convenience typedef for a shared pointer on a class_decl.
void set_member_function_is_const(function_decl &f, bool is_const)
set the const-ness property of a member function.
bool string_to_elf_symbol_type(const string &s, elf_symbol::type &t)
Convert a string representing a symbol type into an elf_symbol::type.
const type_decl * is_type_decl(const type_or_decl_base *t)
Test whether a type is a type_decl (a builtin type).
function_type_sptr is_function_type(const type_or_decl_base_sptr &t)
Test whether a type is a function_type.
void set_member_access_specifier(decl_base &d, access_specifier a)
Sets the access specifier for a class member.
typedef_decl_sptr is_typedef(const type_or_decl_base_sptr t)
Test whether a type is a typedef.
shared_ptr< template_tparameter > template_tparameter_sptr
Convenience typedef for a shared_ptr to template_tparameter.
shared_ptr< function_type > function_type_sptr
Convenience typedef for a shared pointer on a function_type.
shared_ptr< typedef_decl > typedef_decl_sptr
Convenience typedef for a shared pointer on a typedef_decl.
std::unordered_map< string, elf_symbol_sptr > string_elf_symbol_sptr_map_type
Convenience typedef for a map which key is a string and which value if the elf symbol of the same nam...
const enum_type_decl * is_enum_type(const type_or_decl_base *d)
Test if a decl is an enum_type_decl.
const global_scope * get_global_scope(const decl_base &decl)
return the global scope as seen by a given declaration.
shared_ptr< var_decl > var_decl_sptr
Convenience typedef for a shared pointer on a var_decl.
shared_ptr< scope_decl > scope_decl_sptr
Convenience typedef for a shared pointer on a scope_decl.
bool string_to_elf_symbol_binding(const string &s, elf_symbol::binding &b)
Convert a string representing a an elf symbol binding into an elf_symbol::binding.
shared_ptr< type_or_decl_base > type_or_decl_base_sptr
A convenience typedef for a shared_ptr to type_or_decl_base.
shared_ptr< translation_unit > translation_unit_sptr
Convenience typedef for a shared pointer on a translation_unit type.
shared_ptr< string_elf_symbols_map_type > string_elf_symbols_map_sptr
Convenience typedef for a shared pointer to string_elf_symbols_map_type.
type_base * type_has_non_canonicalized_subtype(type_base_sptr t)
Test if a type has sub-types that are non-canonicalized.
bool string_to_elf_symbol_visibility(const string &s, elf_symbol::visibility &v)
Convert a string representing a an elf symbol visibility into an elf_symbol::visibility.
type_base_sptr canonicalize(type_base_sptr t)
Compute the canonical type of a given type.
shared_ptr< pointer_type_def > pointer_type_def_sptr
Convenience typedef for a shared pointer on a pointer_type_def.
pointer_type_def * is_pointer_type(type_or_decl_base *t)
Test whether a type is a pointer_type_def.
translation_unit::language string_to_translation_unit_language(const string &l)
Parse a string representing a language into a translation_unit::language enumerator into a string.
var_decl * is_var_decl(const type_or_decl_base *tod)
Tests if a declaration is a variable declaration.
decl_base * is_decl(const type_or_decl_base *d)
Test if an ABI artifact is a declaration.
method_decl * is_method_decl(const type_or_decl_base *d)
Test if a function_decl is actually a method_decl.
bool is_member_type(const type_base_sptr &t)
Tests if a type is a class member.
decl_base_sptr add_decl_to_scope(decl_base_sptr decl, scope_decl *scope)
Appends a declaration to a given scope, if the declaration doesn't already belong to one and if the d...
shared_ptr< enum_type_decl > enum_type_decl_sptr
Convenience typedef for shared pointer to a enum_type_decl.
bool is_union_type(const type_or_decl_base &t)
Test if a type is a union_decl.
shared_ptr< template_decl > template_decl_sptr
Convenience typedef for a shared pointer to template_decl.
function_type_sptr lookup_function_type(const interned_string &type_name, const translation_unit &tu)
Lookup a function type from a translation unit.
const decl_base * get_type_declaration(const type_base *t)
Get the declaration for a given type.
shared_ptr< type_composition > type_composition_sptr
Convenience typedef for shared pointer to type_composition.
void set_member_is_static(decl_base &d, bool s)
Sets the static-ness property of a class member.
shared_ptr< type_decl > type_decl_sptr
Convenience typedef for a shared pointer on a type_decl.
translation_unit * get_translation_unit(const decl_base &decl)
Return the translation unit a declaration belongs to.
shared_ptr< namespace_decl > namespace_decl_sptr
Convenience typedef for a shared pointer on namespace_decl.
bool is_unique_type(const type_base_sptr &t)
Test if a type is unique in the entire environment.
interned_string get_type_name(const type_base_sptr &t, bool qualified, bool internal)
Get the name of a given type and return a copy of it.
method_type_sptr is_method_type(const type_or_decl_base_sptr &t)
Test whether a type is a method_type.
qualified_type_def * is_qualified_type(const type_or_decl_base *t)
Test whether a type is a reference_type_def.
string build_qualified_name(const scope_decl *scope, const string &name)
Build and return a qualified name from a name and its scope.
shared_ptr< function_tdecl > function_tdecl_sptr
Convenience typedef for a shared pointer on a function_tdecl.
void set_member_function_is_ctor(function_decl &f, bool c)
Setter for the is_ctor property of the member function.
shared_ptr< T > build_sptr(T *p)
This is to be specialized for the diverse C types that needs wrapping in shared_ptr.
shared_ptr< file_suppression > file_suppression_sptr
A convenience typedef for a shared_ptr to file_suppression.
vector< suppression_sptr > suppressions_type
Convenience typedef for a vector of suppression_sptr.
shared_ptr< function_suppression > function_suppression_sptr
Convenience typedef for a shared pointer to function_suppression.
bool suppression_can_match(const fe_iface &fe, const suppression_base &s)
Test if a given suppression specification can match an ABI artifact coming from the corpus being anal...
file_suppression_sptr is_file_suppression(const suppression_sptr s)
Test if a given suppression specification is a file suppression specification.
bool is_elf_symbol_suppressed(const fe_iface &fe, const elf_symbol_sptr &symbol)
Test if an ELF symbol is suppressed by at least one of the suppression specifications associated with...
bool suppression_matches_soname_or_filename(const string &soname, const string &filename, const suppression_base &suppr)
Test if a given SONAME or file name is matched by a given suppression specification.
bool is_type_suppressed(const fe_iface &fe, const string &type_name, const location &type_location, bool &type_is_private, bool require_drop_property)
Test if a type is matched by at least one suppression specification associated with a given front-end...
bool suppression_matches_type_name_or_location(const type_suppression &s, const string &type_name, const location &type_location)
Test if a type suppression matches a type name and location.
bool is_function_suppressed(const fe_iface &fe, const string &fn_name, const string &fn_linkage_name, bool require_drop_property)
Test if a function is matched by at least one suppression specification associated with a given front...
bool is_variable_suppressed(const fe_iface &fe, const string &var_name, const string &var_linkage_name, bool require_drop_property)
Test if a variable is matched by at least one suppression specification associated with a given front...
reader_sptr new_reader_from_file(const std::string &path)
Instantiate an xmlTextReader that parses the content of an on-disk file, wrap it into a smart pointer...
bool xml_char_sptr_to_string(xml_char_sptr ssptr, std::string &s)
Convert a shared pointer to xmlChar into an std::string.
reader_sptr new_reader_from_buffer(const std::string &buffer)
Instanciate an xmlTextReader that parses the content of an in-memory buffer, wrap it into a smart poi...
shared_ptr< xmlChar > xml_char_sptr
A convenience typedef for a shared pointer of xmlChar.
void unescape_xml_string(const std::string &str, std::string &escaped)
Read a string, detect the 5 predefined XML entities it may contain and un-escape them,...
reader_sptr new_reader_from_istream(std::istream *in)
Instanciate an xmlTextReader that parses a content coming from an input stream.
shared_ptr< xmlTextReader > reader_sptr
A convenience typedef for a shared pointer of xmlTextReader.
Toplevel namespace for libabigail.