56using std::unordered_map;
57using std::dynamic_pointer_cast;
65static bool read_is_declaration_only(xmlNodePtr,
bool&);
66static bool read_is_artificial(xmlNodePtr,
bool&);
67static bool read_tracking_non_reachable_types(xmlNodePtr,
bool&);
68static bool read_is_non_reachable_type(xmlNodePtr,
bool&);
69static bool read_naming_typedef_id_string(xmlNodePtr,
string&);
70static bool read_type_id_string(xmlNodePtr,
string&);
71static bool read_name(xmlNodePtr,
string&);
72#ifdef WITH_DEBUG_SELF_COMPARISON
73static bool maybe_map_type_with_type_id(
const type_base_sptr&,
75static bool maybe_map_type_with_type_id(
const type_base_sptr&,
78#define MAYBE_MAP_TYPE_WITH_TYPE_ID(type, xml_node) \
79 maybe_map_type_with_type_id(type, xml_node)
81#define MAYBE_MAP_TYPE_WITH_TYPE_ID(type, xml_node)
83static void maybe_set_naming_typedef(reader& rdr,
85 const decl_base_sptr &);
86static int advance_cursor(reader& rdr);
92walk_xml_node_to_map_type_ids(reader& rdr, xmlNodePtr node);
95read_elf_needed_from_input(reader& rdr, vector<string>& needed);
98read_symbol_db_from_input(reader& rdr,
105read_translation_unit_from_input(
fe_iface& rdr);
108build_ir_node_for_void_type(reader& rdr);
111build_ir_node_for_void_pointer_type(reader& rdr);
114build_ir_node_for_variadic_parameter_type(reader& rdr);
122read_type_hash_and_cti(xmlNodePtr, uint64_t& hash, uint64_t& cti);
135 typedef unordered_map<string, vector<type_base_sptr> >
138 typedef unordered_map<string,
139 vector<type_base_sptr> >::const_iterator
142 typedef unordered_map<string,
143 vector<type_base_sptr> >::iterator
146 typedef unordered_map<string,
147 shared_ptr<function_tdecl> >::const_iterator
148 const_fn_tmpl_map_it;
150 typedef unordered_map<string,
151 shared_ptr<class_tdecl> >::const_iterator
152 const_class_tmpl_map_it;
154 typedef unordered_map<string, xmlNodePtr> string_xml_node_map;
156 typedef unordered_map<xmlNodePtr, decl_base_sptr> xml_node_decl_base_sptr_map;
158 friend vector<type_base_sptr>* get_types_from_type_id(reader&,
161 friend unordered_map<type_or_decl_base*, vector<type_or_decl_base*>>*
162 get_artifact_used_by_relation_map(reader& rdr);
164 types_map_type m_types_map;
165 unordered_map<string, shared_ptr<function_tdecl> > m_fn_tmpl_map;
166 unordered_map<string, shared_ptr<class_tdecl> > m_class_tmpl_map;
167 vector<type_base_sptr> m_types_to_canonicalize;
168 string_xml_node_map m_id_xml_node_map;
169 xml_node_decl_base_sptr_map m_xml_node_decl_map;
171 xmlNodePtr m_corp_node;
172 deque<shared_ptr<decl_base> > m_decls_stack;
173 bool m_tracking_non_reachable_types;
174 bool m_drop_undefined_syms;
175 bool m_drop_hash_value;
176#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
178 vector<type_or_decl_base*>> m_artifact_used_by_map;
189 m_tracking_non_reachable_types(),
190 m_drop_undefined_syms(),
208 clear_types_to_canonicalize();
224 tracking_non_reachable_types()
const
225 {
return m_tracking_non_reachable_types;}
233 tracking_non_reachable_types(
bool f)
234 {m_tracking_non_reachable_types = f;}
242 drop_undefined_syms()
const
243 {
return m_drop_undefined_syms;}
250 drop_undefined_syms(
bool f)
251 {m_drop_undefined_syms = f;}
264 set_path(
const string& s)
280 get_environment()
const
281 {
return const_cast<reader*
>(
this)->get_environment();}
284 get_libxml_reader()
const
293 get_corpus_node()
const
294 {
return m_corp_node;}
302 set_corpus_node(xmlNodePtr node)
303 {m_corp_node = node;}
305 const string_xml_node_map&
306 get_id_xml_node_map()
const
307 {
return m_id_xml_node_map;}
310 get_id_xml_node_map()
311 {
return m_id_xml_node_map;}
314 clear_id_xml_node_map()
315 {get_id_xml_node_map().clear();}
317 const xml_node_decl_base_sptr_map&
318 get_xml_node_decl_map()
const
319 {
return m_xml_node_decl_map;}
321 xml_node_decl_base_sptr_map&
322 get_xml_node_decl_map()
323 {
return m_xml_node_decl_map;}
326 map_xml_node_to_decl(xmlNodePtr node,
330 get_xml_node_decl_map()[node]= decl;
334 get_decl_for_xml_node(xmlNodePtr node)
const
336 xml_node_decl_base_sptr_map::const_iterator i =
337 get_xml_node_decl_map().find(node);
339 if (i != get_xml_node_decl_map().end())
342 return decl_base_sptr();
346 clear_xml_node_decl_map()
347 {get_xml_node_decl_map().clear();}
350 map_id_and_node (
const string&
id,
356 string_xml_node_map::iterator i = get_id_xml_node_map().find(
id);
357 if (i != get_id_xml_node_map().end())
359 bool is_declaration =
false;
360 read_is_declaration_only(node, is_declaration);
365 get_id_xml_node_map()[id] = node;
369 get_xml_node_from_id(
const string&
id)
const
371 string_xml_node_map::const_iterator i = get_id_xml_node_map().find(
id);
372 if (i != get_id_xml_node_map().end())
378 get_scope_for_node(xmlNodePtr node,
382 get_scope_for_node(xmlNodePtr node);
385 get_scope_ptr_for_node(xmlNodePtr node);
390 build_or_get_type_decl(
const string&
id,
405 get_type_decl(
const string&
id)
const
407 const_types_map_it i = m_types_map.find(
id);
408 if (i == m_types_map.end())
409 return type_base_sptr();
410 type_base_sptr result = i->second[0];
426 const vector<type_base_sptr>*
427 get_all_type_decls(
const string&
id)
const
429 const_types_map_it i = m_types_map.find(
id);
430 if (i == m_types_map.end())
447 shared_ptr<function_tdecl>
448 get_fn_tmpl_decl(
const string&
id)
const
450 const_fn_tmpl_map_it i = m_fn_tmpl_map.find(
id);
451 if (i == m_fn_tmpl_map.end())
452 return shared_ptr<function_tdecl>();
466 shared_ptr<class_tdecl>
467 get_class_tmpl_decl(
const string&
id)
const
469 const_class_tmpl_map_it i = m_class_tmpl_map.find(
id);
470 if (i == m_class_tmpl_map.end())
471 return shared_ptr<class_tdecl>();
477 get_cur_scope()
const
479 shared_ptr<decl_base> cur_decl = get_cur_decl();
481 if (
dynamic_cast<scope_decl*
>(cur_decl.get()))
483 return dynamic_pointer_cast<scope_decl>(cur_decl).get();
487 return cur_decl->get_scope();
496 if (m_decls_stack.empty())
497 return shared_ptr<decl_base>(
static_cast<decl_base*
>(0));
498 return m_decls_stack.back();
504 const global_scope* global = 0;
505 for (deque<shared_ptr<decl_base> >::reverse_iterator i =
506 m_decls_stack.rbegin();
507 i != m_decls_stack.rend();
509 if (decl_base_sptr d = *i)
514 return global->get_translation_unit();
525 type_is_from_translation_unit(type_base_sptr type)
537 push_decl(decl_base_sptr d)
539 m_decls_stack.push_back(d);
545 if (m_decls_stack.empty())
546 return decl_base_sptr();
548 shared_ptr<decl_base> t = get_cur_decl();
549 m_decls_stack.pop_back();
576 return dynamic_pointer_cast<scope_decl>(d) == scope;
589 {m_decls_stack.clear();}
593 {m_types_map.clear();}
598 clear_types_to_canonicalize()
599 {m_types_to_canonicalize.clear();}
615 types_equal(type_base_sptr t1, type_base_sptr t2)
617 if (t1.get() == t2.get())
636 key_type_decl(
const type_base_sptr& type,
const string&
id)
641 m_types_map[id].push_back(type);
656 key_fn_tmpl_decl(shared_ptr<function_tdecl> fn_tmpl_decl,
661 const_fn_tmpl_map_it i = m_fn_tmpl_map.find(
id);
662 if (i != m_fn_tmpl_map.end())
665 m_fn_tmpl_map[id] = fn_tmpl_decl;
679 key_class_tmpl_decl(shared_ptr<class_tdecl> class_tmpl_decl,
684 const_class_tmpl_map_it i = m_class_tmpl_map.find(
id);
685 if (i != m_class_tmpl_map.end())
688 m_class_tmpl_map[id] = class_tmpl_decl;
692#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
702 record_artifact_as_used_by(type_or_decl_base* used,
703 type_or_decl_base* user)
705 if (m_artifact_used_by_map.find(used) == m_artifact_used_by_map.end())
707 vector<type_or_decl_base*> v;
708 m_artifact_used_by_map[used] = v;
710 m_artifact_used_by_map[used].push_back(user);
724 {record_artifact_as_used_by(used.get(), user.get());}
730 record_artifacts_as_used_in_fn_decl(
const function_decl *fn)
735 type_base_sptr t = fn->get_return_type();
736 record_artifact_as_used_by(t.get(),
const_cast<function_decl*
>(fn));
738 for (
auto pit : fn->get_parameters())
740 type_base_sptr t = pit->get_type();
741 record_artifact_as_used_by(t.get(),
const_cast<function_decl*
>(fn));
750 {record_artifacts_as_used_in_fn_decl(fn.get());}
756 record_artifacts_as_used_in_fn_type(
const function_type *fn_type)
761 type_base_sptr t = fn_type->get_return_type();
762 record_artifact_as_used_by(t.get(),
const_cast<function_type*
>(fn_type));
764 for (
auto pit : fn_type->get_parameters())
766 type_base_sptr t = pit->get_type();
767 record_artifact_as_used_by(t.get(),
768 const_cast<function_type*
>(fn_type));
777 {record_artifacts_as_used_in_fn_type(fn_type.get());}
789 push_decl_to_scope(
const decl_base_sptr& decl, xmlNodePtr node)
791 scope_decl* scope =
nullptr;
792 scope = get_scope_ptr_for_node(node);
793 return push_decl_to_scope(decl, scope);
802 push_decl_to_scope(
const decl_base_sptr& decl,
809 if (!decl->get_translation_unit())
829 push_and_key_type_decl(
const type_base_sptr& t,
836 push_decl_to_scope(decl, scope);
837 if (!t->get_translation_unit())
840 key_type_decl(t,
id);
855 push_and_key_type_decl(
const type_base_sptr& t,
856 const xmlNodePtr node,
857 bool add_to_current_scope)
860 if (!read_type_id_string(node,
id))
863 scope_decl* scope =
nullptr;
865 scope = get_scope_ptr_for_node(node);
866 return push_and_key_type_decl(t,
id, scope);
874 corpus::exported_decls_builder*
875 get_exported_decls_builder()
876 {
return corpus()->get_exported_decls_builder().get();}
889 corpus_is_suppressed_by_soname_or_filename(
const string& soname,
890 const string& filename)
896 for (suppressions_type::const_iterator s =
suppressions().begin();
910 clear_per_translation_unit_data()
914#ifdef WITH_DEBUG_SELF_COMPARISON
934 maybe_check_abixml_canonical_type_stability(type_base_sptr& t)
936 if (!get_environment().self_comparison_debug_is_on()
937 || get_environment().get_type_id_canonical_type_map().empty())
949 get_environment().get_type_id_from_pointer(
reinterpret_cast<uintptr_t
>(t.get()));
951 if (!type_id.empty())
956 auto j = get_environment().get_type_id_canonical_type_map().find(type_id);
957 if (j == get_environment().get_type_id_canonical_type_map().end())
959 if (t->get_naked_canonical_type())
960 std::cerr <<
"error: no type with type-id: '"
962 <<
"' could be read back from the typeid file\n";
965 !=
reinterpret_cast<uintptr_t
>(t->get_canonical_type().get()))
970 std::cerr <<
"error: canonical type for type '"
971 << t->get_pretty_representation(
true,
973 <<
"' of type-id '" << type_id
974 <<
"' changed from '" << std::hex
975 << j->second <<
"' to '" << std::hex
976 <<
reinterpret_cast<uintptr_t
>(t->get_canonical_type().get())
988 schedule_type_for_canonicalization(type_base_sptr t)
991 m_types_to_canonicalize.push_back(t);
998 perform_type_canonicalization()
1000 tools_utils::timer cn_timer;
1003 std::cerr <<
"ABIXML Reader is going to canonicalize "
1004 << m_types_to_canonicalize.size()
1006 corpus_sptr c =
corpus();
1008 std::cerr <<
" of corpus " <<
corpus()->get_path() <<
"\n";
1014 m_types_to_canonicalize.end(),
1015 [](
const vector<type_base_sptr>::const_iterator& i)
1022 std::cerr <<
"ABIXML Reader: canonicalized all types in: " << cn_timer <<
"\n";
1039 const string& fn_name)
const
1043 return suppression_matches_function_name(*s, fn_name);
1056 corpus_sptr corp =
corpus();
1058 if (!s.priv_->matches_soname(corp->get_soname()))
1059 if (s.has_soname_related_property())
1065 if (!s.priv_->matches_binary_name(corp->get_path()))
1066 if (s.has_file_name_related_property())
1087 suppression_matches_function_name(
const suppr::function_suppression& s,
1088 const string& fn_name)
const
1090 if (!s.get_drops_artifact_from_ir()
1094 return suppr::suppression_matches_function_name(s, fn_name);
1110 const string& type_name,
1111 const location& type_location)
const
1120 virtual ir::corpus_sptr
1123 tools_utils::timer global_timer;
1124 global_timer.start();
1134 bool call_reader_next =
false;
1136 xmlNodePtr node = get_corpus_node();
1143 status = advance_cursor (*
this);
1146 BAD_CAST(
"abi-corpus")))
1149#ifdef WITH_DEBUG_SELF_COMPARISON
1150 if (get_environment().self_comparison_debug_is_on())
1151 get_environment().set_self_comparison_debug_input(
corpus());
1154 ir::corpus& corp = *
corpus();
1156 corp.set_origin(corpus::NATIVE_XML_ORIGIN);
1158 handle_version_attribute(xml_reader, corp);
1160 maybe_drop_hash_values();
1167 path =
reinterpret_cast<char*
>(path_str.get());
1169 corp.set_path(path);
1174 if (architecture_str)
1175 corp.set_architecture_name
1176 (
reinterpret_cast<char*
>(architecture_str.get()));
1184 soname =
reinterpret_cast<char*
>(soname_str.get());
1186 corp.set_soname(soname);
1196 if ((!soname.empty() || !path.empty())
1197 && corpus_is_suppressed_by_soname_or_filename(soname, path))
1200 node = xmlTextReaderExpand(xml_reader.get());
1204 call_reader_next =
true;
1208#ifdef WITH_DEBUG_SELF_COMPARISON
1209 if (get_environment().self_comparison_debug_is_on())
1210 get_environment().set_self_comparison_debug_input(
corpus());
1213 ir::corpus& corp = *
corpus();
1214 corp.set_origin(corpus::NATIVE_XML_ORIGIN);
1218 corp.set_path(
reinterpret_cast<char*
>(path_str.get()));
1222 if (architecture_str)
1223 corp.set_architecture_name
1224 (
reinterpret_cast<char*
>(architecture_str.get()));
1229 corp.set_soname(
reinterpret_cast<char*
>(soname_str.get()));
1237 xmlNodePtr n = xmlFirstElementChild(node);
1241 ir::corpus& corp = *
corpus();
1243 tools_utils::timer t;
1247 std::cerr <<
"ABIXML Reader: mapping XML nodes to type ID "
1248 <<
"for corpus " << corp.get_path()
1253 walk_xml_node_to_map_type_ids(*
this, node);
1258 std::cerr <<
"ABIXML Reader: mapped XML nodes to type ID "
1259 <<
"for corpus " << corp.get_path()
1266 vector<string> needed;
1267 read_elf_needed_from_input(*
this, needed);
1268 if (!needed.empty())
1269 corp.set_needed(needed);
1276 std::cerr <<
"ABIXML Reader: reading symbols information "
1277 <<
"for corpus " << corp.get_path()
1284 read_symbol_db_from_input(*
this, fn_sym_db, var_sym_db,
1285 non_resolved_fn_syms_aliases,
1286 non_resolved_var_syms_aliases);
1287 resolve_symbol_aliases(fn_sym_db, var_sym_db,
1288 non_resolved_fn_syms_aliases,
1289 non_resolved_var_syms_aliases);
1298 std::cerr <<
"ABIXML Reader: read symbols information "
1299 <<
"for corpus " << corp.get_path()
1305 get_environment().canonicalization_is_done(
false);
1309 std::cerr <<
"ABIXML Reader: building IR "
1310 <<
"for corpus " << corp.get_path()
1316 while (read_translation_unit_from_input(*
this))
1322 std::cerr <<
"ABIXML Reader: built IR "
1323 <<
"for corpus " << corp.get_path()
1324 <<
" in: " << t <<
"\n";
1327 if (tracking_non_reachable_types())
1329 bool is_tracking_non_reachable_types =
false;
1330 read_tracking_non_reachable_types(node, is_tracking_non_reachable_types);
1333 (corp.recording_types_reachable_from_public_interface_supported()
1334 == is_tracking_non_reachable_types);
1340 std::cerr <<
"ABIXML Reader: canonicalizing types "
1341 <<
"for corpus " << corp.get_path()
1346 perform_type_canonicalization();
1351 std::cerr <<
"ABIXML Reader: canonicalized types for corpus "
1353 <<
" in :" << t <<
"\n";
1356 get_environment().canonicalization_is_done(
true);
1358 if (call_reader_next)
1362 xmlTextReaderNext(xml_reader.get());
1370 node = get_corpus_node();
1371 node = xmlNextElementSibling(node);
1374 node = get_corpus_node();
1376 node = xmlNextElementSibling(node->parent);
1378 set_corpus_node(node);
1383 std::cerr <<
"ABIXML Reader: sorting functions and variables for corpus "
1389 corpus()->sort_functions();
1390 corpus()->sort_variables();
1395 std::cerr <<
"ABIXML Reader: sorted functions and variables for corpus "
1403 global_timer.stop();
1404 std::cerr <<
"ABIXML Reader: Analyzed corpus " <<
corpus()->get_path()
1405 <<
" in " << global_timer <<
"\n";
1406 std::cerr <<
"======================================================\n";
1421 maybe_drop_hash_values()
1423 string current_major, current_minor;
1426 if (current_major.empty() || current_minor.empty())
1429 ir::corpus& corp = *
corpus();
1430 bool drop_hash_values_from_abixml =
false;
1431 if (current_major > corp.get_format_major_version_number()
1432 || current_minor > corp.get_format_minor_version_number())
1433 drop_hash_values_from_abixml =
true;
1435 if (drop_hash_values_from_abixml)
1436 m_drop_hash_value =
true;
1446 read_hash_and_stash(
const xmlNodePtr node,
1449 uint64_t
hash = 0, cti = 0;
1450 if (!m_drop_hash_value
1451 && read_type_hash_and_cti(node, hash, cti))
1453 ir_node->priv_->force_set_hash_value(hash);
1454 type_base_sptr type;
1456 type = fn->get_type();
1462 type->type_or_decl_base::priv_->force_set_hash_value(hash);
1463 type->priv_->canonical_type_index = cti;
1476{
return dynamic_pointer_cast<reader>(iface);}
1478static int advance_cursor(reader&);
1482static bool read_symbol_db_from_input(reader&,
1487static bool read_location(
const reader&, xmlNodePtr,
location&);
1488static bool read_artificial_location(
const reader&,
1490static bool maybe_set_artificial_location(
const reader&,
1496static bool read_size_and_alignment(xmlNodePtr,
size_t&,
size_t&);
1497static bool read_static(xmlNodePtr,
bool&);
1498static bool read_offset_in_bits(xmlNodePtr,
size_t&);
1499static bool read_cdtor_const(xmlNodePtr,
bool&,
bool&,
bool&);
1500static bool read_is_virtual(xmlNodePtr,
bool&);
1501static bool read_is_struct(xmlNodePtr,
bool&);
1502static bool read_is_anonymous(xmlNodePtr,
bool&);
1505static bool read_elf_symbol_visibility(xmlNodePtr,
1508build_namespace_decl(reader&,
const xmlNodePtr,
bool);
1518build_elf_symbol(reader&,
const xmlNodePtr,
bool);
1521build_elf_symbol_from_reference(reader&,
const xmlNodePtr);
1524build_elf_symbol_db(reader&,
const xmlNodePtr,
bool,
1529build_function_parameter (reader&,
const xmlNodePtr);
1532build_function_decl(reader&,
const xmlNodePtr,
1533 class_or_union_sptr,
bool,
bool);
1536build_function_decl_if_not_suppressed(reader&,
const xmlNodePtr,
1537 class_or_union_sptr,
bool,
bool);
1540function_is_suppressed(
const reader& rdr,
1544build_var_decl_if_not_suppressed(reader&,
const xmlNodePtr,
bool);
1547build_var_decl(reader&,
const xmlNodePtr,
bool);
1550variable_is_suppressed(
const reader& rdr,
1553static shared_ptr<type_decl>
1554build_type_decl(reader&,
const xmlNodePtr,
bool);
1556static qualified_type_def_sptr
1557build_qualified_type_decl(reader&,
const xmlNodePtr,
bool);
1559static shared_ptr<pointer_type_def>
1560build_pointer_type_def(reader&,
const xmlNodePtr,
bool);
1562static shared_ptr<reference_type_def>
1563build_reference_type_def(reader&,
const xmlNodePtr,
bool);
1566build_ptr_to_mbr_type(reader&,
const xmlNodePtr,
bool);
1568static shared_ptr<function_type>
1569build_function_type(reader&,
const xmlNodePtr,
bool);
1572build_subrange_type(reader&,
const xmlNodePtr,
bool);
1575build_array_type_def(reader&,
const xmlNodePtr,
bool);
1578build_enum_type_decl(reader&,
const xmlNodePtr,
bool);
1580static shared_ptr<typedef_decl>
1581build_typedef_decl(reader&,
const xmlNodePtr,
bool);
1584build_class_decl(reader&,
const xmlNodePtr,
bool);
1586static union_decl_sptr
1587build_union_decl(reader&,
const xmlNodePtr,
bool);
1589static shared_ptr<function_tdecl>
1590build_function_tdecl(reader&,
const xmlNodePtr,
bool);
1592static shared_ptr<class_tdecl>
1593build_class_tdecl(reader&,
const xmlNodePtr,
bool);
1596build_type_tparameter(reader&,
const xmlNodePtr,
1600build_type_composition(reader&,
const xmlNodePtr,
1604build_non_type_tparameter(reader&,
const xmlNodePtr,
1608build_template_tparameter(reader&,
const xmlNodePtr,
1612build_template_parameter(reader&,
const xmlNodePtr,
1619static shared_ptr<type_base>
1620build_type(reader&,
const xmlNodePtr,
bool);
1624static decl_base_sptr handle_type_decl(reader&, xmlNodePtr,
bool);
1625static decl_base_sptr handle_namespace_decl(reader&, xmlNodePtr,
bool);
1626static decl_base_sptr handle_qualified_type_decl(reader&,
1628static decl_base_sptr handle_pointer_type_def(reader&,
1630static decl_base_sptr handle_reference_type_def(reader&,
1632static type_base_sptr handle_function_type(reader&,
1634static decl_base_sptr handle_array_type_def(reader&,
1636static decl_base_sptr handle_enum_type_decl(reader&, xmlNodePtr,
bool);
1637static decl_base_sptr handle_typedef_decl(reader&, xmlNodePtr,
bool);
1638static decl_base_sptr handle_var_decl(reader&, xmlNodePtr,
bool);
1639static decl_base_sptr handle_function_decl(reader&, xmlNodePtr,
bool);
1640static decl_base_sptr handle_class_decl(reader&, xmlNodePtr,
bool);
1641static decl_base_sptr handle_union_decl(reader&, xmlNodePtr,
bool);
1642static decl_base_sptr handle_function_tdecl(reader&, xmlNodePtr,
bool);
1643static decl_base_sptr handle_class_tdecl(reader&, xmlNodePtr,
bool);
1645#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
1646#define RECORD_ARTIFACT_AS_USED_BY(rdr, used, user) \
1647 rdr.record_artifact_as_used_by(used,user)
1648#define RECORD_ARTIFACTS_AS_USED_IN_FN_DECL(rdr, fn) \
1649 rdr.record_artifacts_as_used_in_fn_decl(fn)
1650#define RECORD_ARTIFACTS_AS_USED_IN_FN_TYPE(rdr, fn_type)\
1651 rdr.record_artifacts_as_used_in_fn_type(fn_type)
1653#define RECORD_ARTIFACT_AS_USED_BY(rdr, used, user)
1654#define RECORD_ARTIFACTS_AS_USED_IN_FN_DECL(rdr, fn)
1655#define RECORD_ARTIFACTS_AS_USED_IN_FN_TYPE(rdr, fn_type)
1678 xmlNodePtr parent = node->parent;
1681 && (xmlStrEqual(parent->name, BAD_CAST(
"data-member"))
1682 || xmlStrEqual(parent->name, BAD_CAST(
"member-type"))
1683 || xmlStrEqual(parent->name, BAD_CAST(
"member-function"))
1684 || xmlStrEqual(parent->name, BAD_CAST(
"member-template"))
1685 || xmlStrEqual(parent->name, BAD_CAST(
"template-parameter-type-composition"))
1686 || xmlStrEqual(parent->name, BAD_CAST(
"array-type-def"))))
1688 read_access(parent, access);
1689 parent = parent->parent;
1692 xml_node_decl_base_sptr_map::const_iterator i =
1693 get_xml_node_decl_map().find(parent);
1694 if (i == get_xml_node_decl_map().end())
1696 if (xmlStrEqual(parent->name, BAD_CAST(
"abi-instr")))
1699 get_or_read_and_add_translation_unit(*
this, parent);
1700 return tu->get_global_scope();
1705 push_decl(parent_scope);
1706 scope = dynamic_pointer_cast<scope_decl>
1707 (handle_element_node(*
this, parent,
true));
1709 pop_scope_or_abort(parent_scope);
1712 scope = dynamic_pointer_cast<scope_decl>(i->second);
1727reader::get_scope_for_node(xmlNodePtr node)
1730 return get_scope_for_node(node, access);
1743reader::get_scope_ptr_for_node(xmlNodePtr node)
1763 type_base_sptr t = get_type_decl(
id);
1767 xmlNodePtr n = get_xml_node_from_id(
id);
1774 scope = get_scope_for_node(n, access);
1782 if ((t = get_type_decl(
id)))
1800 pop_scope_or_abort(scope);
1802 schedule_type_for_canonicalization(t);
1814advance_cursor(reader& rdr)
1817 return xmlTextReaderRead(reader.get());
1829walk_xml_node_to_map_type_ids(reader& rdr,
1832 xmlNodePtr n = node;
1834 if (!n || n->type != XML_ELEMENT_NODE)
1839 string id = CHAR_STR(s);
1840 rdr.map_id_and_node(
id, n);
1843 for (n = xmlFirstElementChild(n); n; n = xmlNextElementSibling(n))
1844 walk_xml_node_to_map_type_ids(rdr, n);
1848read_translation_unit(fe_iface& iface, translation_unit& tu, xmlNodePtr node)
1850 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
1852 if (!rdr.corpus()->is_empty())
1853 tu.set_corpus(rdr.corpus().get());
1859 char address_size = atoi(
reinterpret_cast<char*
>(addrsize_str.get()));
1860 tu.set_address_size(address_size);
1865 tu.set_path(
reinterpret_cast<char*
>(path_str.get()));
1869 if (comp_dir_path_str)
1870 tu.set_compilation_dir_path(
reinterpret_cast<char*
>
1871 (comp_dir_path_str.get()));
1876 (
reinterpret_cast<char*
>(language_str.get())));
1881 rdr.push_decl(tu.get_global_scope());
1882 rdr.map_xml_node_to_decl(node, tu.get_global_scope());
1884 if (rdr.get_id_xml_node_map().empty()
1886 walk_xml_node_to_map_type_ids(rdr, node);
1888 for (xmlNodePtr n = xmlFirstElementChild(node);
1890 n = xmlNextElementSibling(n))
1891 handle_element_node(rdr, n,
true);
1893 rdr.pop_scope_or_abort(tu.get_global_scope());
1899 rdr.clear_per_translation_unit_data();
1918get_or_read_and_add_translation_unit(reader& rdr, xmlNodePtr node)
1920 corpus_sptr corp = rdr.corpus();
1926 if (corp && !corp->is_empty())
1929 tu_path =
reinterpret_cast<char*
>(path_str.get());
1930 tu = corp->find_translation_unit(tu_path);
1935 tu.reset(
new translation_unit(rdr.get_environment(), tu_path));
1936 if (corp && !corp->is_empty())
1939 if (read_translation_unit(rdr, *tu, node))
1954read_translation_unit_from_input(fe_iface& iface)
1958 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
1960 xmlNodePtr node = rdr.get_corpus_node();
1971 status = advance_cursor (rdr);
1974 BAD_CAST(
"abi-instr")))
1977 node = xmlTextReaderExpand(reader.get());
1984 for (xmlNodePtr n = rdr.get_corpus_node();
1986 n = xmlNextElementSibling(n))
1988 if (!xmlStrEqual(n->name, BAD_CAST(
"abi-instr")))
1998 tu = get_or_read_and_add_translation_unit(rdr, node);
2000 if (rdr.get_corpus_node())
2006 node = xmlNextElementSibling(node);
2007 rdr.set_corpus_node(node);
2060read_symbol_db_from_input(reader& rdr,
2070 if (!rdr.get_corpus_node())
2076 status = advance_cursor (rdr);
2081 bool has_fn_syms =
false, has_undefined_fn_syms =
false,
2082 has_var_syms =
false, has_undefined_var_syms =
false;
2084 BAD_CAST(
"elf-function-symbols")))
2087 BAD_CAST(
"elf-variable-symbols")))
2088 has_var_syms =
true;
2090 BAD_CAST(
"undefined-elf-function-symbols")))
2091 has_undefined_fn_syms =
true;
2093 BAD_CAST(
"undefined-elf-variable-symbols")))
2094 has_undefined_var_syms =
true;
2098 xmlNodePtr node = xmlTextReaderExpand(reader.get());
2103 build_elf_symbol_db(rdr, node,
true, fn_symdb,
2104 non_resolved_fn_syms_aliases);
2105 else if (has_undefined_fn_syms)
2106 build_elf_symbol_db(rdr, node,
true, fn_symdb,
2107 non_resolved_fn_syms_aliases);
2108 else if (has_var_syms)
2109 build_elf_symbol_db(rdr, node,
false, var_symdb,
2110 non_resolved_var_syms_aliases);
2111 else if (has_undefined_var_syms)
2112 build_elf_symbol_db(rdr, node,
false, var_symdb,
2113 non_resolved_var_syms_aliases);
2115 xmlTextReaderNext(reader.get());
2118 for (xmlNodePtr n = rdr.get_corpus_node(); n; n = xmlNextElementSibling(n))
2120 bool has_fn_syms =
false, has_undefined_fn_syms =
false,
2121 has_var_syms =
false, has_undefined_var_syms =
false;
2122 if (xmlStrEqual(n->name, BAD_CAST(
"elf-function-symbols")))
2124 else if (xmlStrEqual(n->name, BAD_CAST(
"undefined-elf-function-symbols")))
2125 has_undefined_fn_syms =
true;
2126 else if (xmlStrEqual(n->name, BAD_CAST(
"elf-variable-symbols")))
2127 has_var_syms =
true;
2128 else if (xmlStrEqual(n->name,
2129 BAD_CAST(
"undefined-elf-variable-symbols")))
2130 has_undefined_var_syms =
true;
2133 rdr.set_corpus_node(n);
2138 build_elf_symbol_db(rdr, n,
true, fn_symdb,
2139 non_resolved_fn_syms_aliases);
2140 else if (has_undefined_fn_syms)
2141 build_elf_symbol_db(rdr, n,
true, fn_symdb,
2142 non_resolved_fn_syms_aliases);
2143 else if (has_var_syms)
2144 build_elf_symbol_db(rdr, n,
false, var_symdb,
2145 non_resolved_var_syms_aliases);
2146 else if (has_undefined_var_syms)
2147 build_elf_symbol_db(rdr, n,
false, var_symdb,
2148 non_resolved_var_syms_aliases);
2167build_needed(xmlNode* node, vector<string>& needed)
2169 if (!node || !xmlStrEqual(node->name,BAD_CAST(
"elf-needed")))
2172 for (xmlNodePtr n = xmlFirstElementChild(node);
2174 n = xmlNextElementSibling(n))
2176 if (!xmlStrEqual(n->name, BAD_CAST(
"dependency")))
2184 needed.push_back(name);
2200read_elf_needed_from_input(reader& rdr,
2201 vector<string>& needed)
2207 xmlNodePtr node = 0;
2209 if (rdr.get_corpus_node() == 0)
2214 status = advance_cursor (rdr);
2220 BAD_CAST(
"elf-needed")))
2223 node = xmlTextReaderExpand(reader.get());
2229 for (xmlNodePtr n = rdr.get_corpus_node();
2231 n = xmlNextElementSibling(n))
2233 if (!xmlStrEqual(n->name, BAD_CAST(
"elf-needed")))
2240 bool result =
false;
2243 result = build_needed(node, needed);
2244 node = xmlNextElementSibling(node);
2245 rdr.set_corpus_node(node);
2280 for (suppr::suppressions_type::const_iterator i = supprs.begin();
2283 if ((*i)->get_drops_artifact_from_ir())
2284 rdr.suppressions().push_back(*i);
2298 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
2299 rdr.tracking_non_reachable_types(flag);
2302#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
2311vector<type_base_sptr>*
2312get_types_from_type_id(
fe_iface& iface,
const string& type_id)
2314 reader& rdr =
dynamic_cast<reader&
>(iface);
2315 auto it = rdr.m_types_map.find(type_id);
2316 if (it == rdr.m_types_map.end())
2327unordered_map<type_or_decl_base*, vector<type_or_decl_base*>>*
2328get_artifact_used_by_relation_map(fe_iface& iface)
2330 reader& rdr =
dynamic_cast<reader&
>(iface);
2331 return &rdr.m_artifact_used_by_map;
2351 string version_string;
2356 if (version_string.empty())
2363 corp.set_format_major_version_number(v[0]);
2364 corp.set_format_minor_version_number(v[1]);
2377 corpus_group_sptr nil;
2379 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
2388 status = advance_cursor (rdr);
2391 BAD_CAST(
"abi-corpus-group")))
2396 if (!rdr.corpus_group())
2398 corpus_group_sptr g(
new corpus_group(rdr.get_environment(),
2400 g->set_origin(corpus::NATIVE_XML_ORIGIN);
2401 rdr.corpus_group(g);
2404 corpus_group_sptr group = rdr.corpus_group();
2406 handle_version_attribute(reader, *group);
2410 group->set_path(
reinterpret_cast<char*
>(path_str.get()));
2414 std::cerr <<
"ABIXML Reader: reading corpus group : '"
2415 << group->get_path()
2420 xmlNodePtr node = xmlTextReaderExpand(reader.get());
2424 node = xmlFirstElementChild(node);
2425 rdr.set_corpus_node(node);
2429 while ((corp = rdr.read_corpus(sts)))
2431 rdr.corpus_group()->add_corpus(corp);
2432 node = xmlNextElementSibling(node);
2433 if (!node || !xmlStrEqual(node->name, BAD_CAST(
"abi-corpus")))
2436 rdr.set_corpus_node(node);
2439 xmlTextReaderNext(reader.get());
2444 std::cerr <<
"ABIXML Reader: Read corpus group : "
2445 << group->get_path()
2446 <<
" in: " << t <<
"\n";
2449 return rdr.corpus_group();
2511 rdr.perform_type_canonicalization();
2533 rdr.perform_type_canonicalization();
2548 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
2550 rdr.options().env.canonicalization_is_done(
false);
2551 rdr.perform_type_canonicalization();
2552 rdr.options().env.canonicalization_is_done(
true);
2565handle_element_node(reader& rdr, xmlNodePtr node,
2566 bool add_to_current_scope)
2572 ((decl = handle_namespace_decl(rdr, node, add_to_current_scope))
2573 ||(decl = handle_type_decl(rdr, node, add_to_current_scope))
2574 ||(decl = handle_qualified_type_decl(rdr, node,
2575 add_to_current_scope))
2576 ||(decl = handle_pointer_type_def(rdr, node,
2577 add_to_current_scope))
2578 || (decl = handle_reference_type_def(rdr, node, add_to_current_scope))
2579 || (decl = handle_function_type(rdr, node, add_to_current_scope))
2580 || (decl = handle_array_type_def(rdr, node, add_to_current_scope))
2581 || (decl = handle_enum_type_decl(rdr, node,
2582 add_to_current_scope))
2583 || (decl = handle_typedef_decl(rdr, node,
2584 add_to_current_scope))
2585 || (decl = handle_var_decl(rdr, node,
2586 add_to_current_scope))
2587 || (decl = handle_function_decl(rdr, node,
2588 add_to_current_scope))
2589 || (decl = handle_class_decl(rdr, node,
2590 add_to_current_scope))
2591 || (decl = handle_union_decl(rdr, node,
2592 add_to_current_scope))
2593 || (decl = handle_function_tdecl(rdr, node,
2594 add_to_current_scope))
2595 || (decl = handle_class_tdecl(rdr, node,
2596 add_to_current_scope)));
2601 if (rdr.tracking_non_reachable_types())
2603 if (type_base_sptr t =
is_type(decl))
2605 corpus_sptr abi = rdr.corpus();
2607 bool is_non_reachable_type =
false;
2608 read_is_non_reachable_type(node, is_non_reachable_type);
2609 if (!is_non_reachable_type)
2610 abi->record_type_as_reachable_from_public_interfaces(*t);
2625read_location(
const reader& rdr,
2630 size_t line = 0, column = 0;
2632 if (xml_char_sptr f = xml::build_sptr(xmlGetProp(node, BAD_CAST(
"filepath"))))
2633 file_path = CHAR_STR(f);
2635 if (file_path.empty())
2636 return read_artificial_location(rdr, node, loc);
2638 if (xml_char_sptr l = xml::build_sptr(xmlGetProp(node, BAD_CAST(
"line"))))
2639 line = atoi(CHAR_STR(l));
2641 return read_artificial_location(rdr, node, loc);
2643 if (xml_char_sptr c = xml::build_sptr(xmlGetProp(node, BAD_CAST(
"column"))))
2644 column = atoi(CHAR_STR(c));
2646 reader& c =
const_cast<reader&
>(rdr);
2647 loc = c.get_translation_unit()->get_loc_mgr().create_new_location(file_path,
2664read_artificial_location(
const reader& rdr,
2672 size_t line = 0, column = 0;
2677 file_path =
reinterpret_cast<const char*
>(node->doc->URL);
2679 reader& c =
const_cast<reader&
>(rdr);
2681 c.get_translation_unit()->get_loc_mgr().create_new_location(file_path,
2683 loc.set_is_artificial(
true);
2703maybe_set_artificial_location(
const reader& rdr,
2707 if (artefact && !artefact->has_artificial_location())
2710 if (read_artificial_location(rdr, node, l))
2712 artefact->set_artificial_location(l);
2731 string v = CHAR_STR(s);
2734 vis = decl_base::VISIBILITY_DEFAULT;
2735 else if (v ==
"hidden")
2736 vis = decl_base::VISIBILITY_HIDDEN;
2737 else if (v ==
"internal")
2738 vis = decl_base::VISIBILITY_INTERNAL;
2739 else if (v ==
"protected")
2740 vis = decl_base::VISIBILITY_PROTECTED;
2742 vis = decl_base::VISIBILITY_DEFAULT;
2760 string b = CHAR_STR(s);
2763 bind = decl_base::BINDING_GLOBAL;
2764 else if (b ==
"local")
2765 bind = decl_base::BINDING_LOCAL;
2766 else if (b ==
"weak")
2767 bind = decl_base::BINDING_WEAK;
2769 bind = decl_base::BINDING_GLOBAL;
2788 string a = CHAR_STR(s);
2791 access = private_access;
2792 else if (a ==
"protected")
2793 access = protected_access;
2794 else if (a ==
"public")
2795 access = public_access;
2823read_size_and_alignment(xmlNodePtr node,
2824 size_t& size_in_bits,
2825 size_t& align_in_bits)
2828 bool got_something =
false;
2831 size_in_bits = atoll(CHAR_STR(s));
2832 got_something =
true;
2837 align_in_bits = atoll(CHAR_STR(s));
2838 got_something =
true;
2840 return got_something;
2853read_static(xmlNodePtr node,
bool& is_static)
2857 string b = CHAR_STR(s);
2858 is_static = b ==
"yes";
2871read_offset_in_bits(xmlNodePtr node,
2872 size_t& offset_in_bits)
2876 offset_in_bits = strtoull(CHAR_STR(s), 0, 0);
2904read_cdtor_const(xmlNodePtr node,
2905 bool& is_constructor,
2906 bool& is_destructor,
2911 string b = CHAR_STR(s);
2913 is_constructor =
true;
2915 is_constructor =
false;
2922 string b = CHAR_STR(s);
2924 is_destructor =
true;
2926 is_destructor =
false;
2933 string b = CHAR_STR(s);
2954read_is_declaration_only(xmlNodePtr node,
bool& is_decl_only)
2958 string str = CHAR_STR(s);
2960 is_decl_only =
true;
2962 is_decl_only =
false;
2978read_is_artificial(xmlNodePtr node,
bool& is_artificial)
2982 string is_artificial_str = CHAR_STR(s) ? CHAR_STR(s) :
"";
2983 is_artificial = is_artificial_str ==
"yes";
3002read_tracking_non_reachable_types(xmlNodePtr node,
3003 bool& tracking_non_reachable_types)
3005 if (xml_char_sptr s =
3008 string tracking_non_reachable_types_str = CHAR_STR(s) ? CHAR_STR(s) :
"";
3009 tracking_non_reachable_types =
3010 (tracking_non_reachable_types_str ==
"yes")
3029read_is_non_reachable_type(xmlNodePtr node,
bool& is_non_reachable_type)
3031 if (xml_char_sptr s =
3034 string is_non_reachable_type_str = CHAR_STR(s) ? CHAR_STR(s) :
"";
3035 is_non_reachable_type =
3036 (is_non_reachable_type_str ==
"yes")
3054read_naming_typedef_id_string(xmlNodePtr node,
string& naming_typedef_id)
3073read_is_virtual(xmlNodePtr node,
bool& is_virtual)
3077 string str = CHAR_STR(s);
3096read_is_struct(xmlNodePtr node,
bool& is_struct)
3100 string str = CHAR_STR(s);
3119read_is_anonymous(xmlNodePtr node,
bool& is_anonymous)
3123 string str = CHAR_STR(s);
3124 is_anonymous = (str ==
"yes");
3201read_type_id_string(xmlNodePtr node,
string& type_id)
3205 type_id = CHAR_STR(s);
3221read_name(xmlNodePtr node,
string& name)
3247read_type_hash_and_cti(xmlNodePtr node, uint64_t& hash, uint64_t& cti)
3251 string str = CHAR_STR(s);
3252 vector<string> parts;
3254 if (!parts.empty() && !parts.front().empty())
3257 if (parts.size() > 1)
3258 cti = atoll(parts[1].c_str());
3265#ifdef WITH_DEBUG_SELF_COMPARISON
3280maybe_map_type_with_type_id(
const type_base_sptr& t,
3281 const string& type_id)
3286 const environment& env = t->get_environment();
3287 if (!env.self_comparison_debug_is_on()
3291 const_cast<environment&
>(env).
3292 get_pointer_type_id_map()[
reinterpret_cast<uintptr_t
>(t.get())] = type_id;
3311maybe_map_type_with_type_id(
const type_base_sptr& t,
3317 const environment&env = t->get_environment();
3318 if (!env.self_comparison_debug_is_on()
3323 if (!read_type_id_string(node, type_id) || type_id.empty())
3326 return maybe_map_type_with_type_id(t, type_id);
3340maybe_set_naming_typedef(reader& rdr,
3342 const decl_base_sptr& decl)
3344 string naming_typedef_id;
3345 read_naming_typedef_id_string(node, naming_typedef_id);
3346 if (!naming_typedef_id.empty())
3349 is_typedef(rdr.build_or_get_type_decl(naming_typedef_id,
true));
3351 decl->set_naming_typedef(naming_typedef);
3371build_namespace_decl(reader& rdr,
3372 const xmlNodePtr node,
3373 bool add_to_current_scope)
3376 if (!node || !xmlStrEqual(node->name, BAD_CAST(
"namespace-decl")))
3379 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
3391 read_location(rdr, node, loc);
3393 const environment& env = rdr.get_environment();
3395 maybe_set_artificial_location(rdr, node, decl);
3396 rdr.push_decl_to_scope(decl,
3397 add_to_current_scope
3398 ? rdr.get_scope_ptr_for_node(node)
3400 rdr.map_xml_node_to_decl(node, decl);
3402 for (xmlNodePtr n = xmlFirstElementChild(node);
3404 n = xmlNextElementSibling(n))
3405 handle_element_node(rdr, n,
true);
3407 rdr.pop_scope_or_abort(decl);
3424build_elf_symbol(reader& rdr,
const xmlNodePtr node,
3425 bool drop_if_suppressed)
3430 || node->type != XML_ELEMENT_NODE
3431 || !xmlStrEqual(node->name, BAD_CAST(
"elf-symbol")))
3440 size = strtol(CHAR_STR(s), NULL, 0);
3442 bool is_defined =
true;
3447 if (value ==
"true" || value ==
"yes")
3453 bool is_common =
false;
3458 if (value ==
"true" || value ==
"yes")
3464 string version_string;
3468 bool is_default_version =
false;
3473 if (value ==
"true" || value ==
"yes")
3474 is_default_version =
true;
3478 read_elf_symbol_type(node, type);
3481 read_elf_symbol_binding(node, binding);
3484 read_elf_symbol_visibility(node, visibility);
3486 elf_symbol::version version(version_string, is_default_version);
3489 if (drop_if_suppressed && is_suppressed)
3492 const environment& env = rdr.get_environment();
3494 size, name, type, binding,
3495 is_defined, is_common,
3496 version, visibility);
3498 e->set_is_suppressed(is_suppressed);
3501 e->set_crc(strtoull(CHAR_STR(s), NULL, 0));
3507 e->set_namespace(ns);
3527build_elf_symbol_from_reference(reader& rdr,
const xmlNodePtr node)
3546 if (rdr.corpus()->get_symtab())
3549 rdr.corpus()->get_symtab()->lookup_symbol(name);
3551 for (
const auto& symbol : symbols)
3552 if (symbol->get_id_string() == sym_id)
3585build_elf_symbol_db(reader& rdr,
3586 const xmlNodePtr node,
3597 && !xmlStrEqual(node->name, BAD_CAST(
"elf-function-symbols"))
3598 && !xmlStrEqual(node->name, BAD_CAST(
"undefined-elf-function-symbols")))
3602 && !xmlStrEqual(node->name, BAD_CAST(
"elf-variable-symbols"))
3603 && !xmlStrEqual(node->name, BAD_CAST(
"undefined-elf-variable-symbols")))
3606 rdr.set_corpus_node(node);
3608 typedef std::unordered_map<xmlNodePtr, elf_symbol_sptr>
3609 xml_node_ptr_elf_symbol_sptr_map_type;
3610 xml_node_ptr_elf_symbol_sptr_map_type xml_node_ptr_elf_symbol_map;
3613 for (xmlNodePtr n = xmlFirstElementChild(node);
3615 n = xmlNextElementSibling(n))
3616 if ((sym = build_elf_symbol(rdr, n,
false)))
3618 id_sym_map[sym->get_id_string()] = sym;
3619 xml_node_ptr_elf_symbol_map[n] = sym;
3622 if (id_sym_map.empty())
3625 string_elf_symbols_map_type::iterator it;
3626 for (string_elf_symbol_sptr_map_type::const_iterator i = id_sym_map.begin();
3627 i != id_sym_map.end();
3629 (*map)[i->second->get_name()].push_back(i->second);
3632 for (xml_node_ptr_elf_symbol_sptr_map_type::const_iterator x =
3633 xml_node_ptr_elf_symbol_map.begin();
3634 x != xml_node_ptr_elf_symbol_map.end();
3639 string alias_id = CHAR_STR(s);
3642 std::vector<std::string> elems;
3643 std::stringstream aliases(alias_id);
3645 while (std::getline(aliases, item,
','))
3646 elems.push_back(item);
3647 for (std::vector<string>::iterator alias = elems.begin();
3648 alias != elems.end(); ++alias)
3650 string_elf_symbol_sptr_map_type::const_iterator i =
3651 id_sym_map.find(*alias);
3652 if (i == id_sym_map.end())
3658 non_resolved_aliases[x->second->get_name()].push_back(*alias);
3662 x->second->get_main_symbol()->add_alias(i->second);
3700 for (
auto& entry : non_resolved_fn_sym_aliases)
3702 auto i = fn_syms->find(entry.first);
3707 sym = sym->get_main_symbol();
3709 for (
string& alias : entry.second)
3711 auto fn_a = fn_syms->find(alias);
3712 if (fn_a == fn_syms->end())
3716 auto var_a = var_syms->find(alias);
3718 alias_sym = var_a->second.front();
3723 alias_sym = fn_a->second.front();
3726 sym->add_alias(alias_sym);
3730 for (
auto& entry : non_resolved_var_sym_aliases)
3732 auto i = var_syms->find(entry.first);
3737 sym = sym->get_main_symbol();
3739 for (
string& alias : entry.second)
3741 auto var_a = var_syms->find(alias);
3742 if (var_a == var_syms->end())
3746 auto fn_a = fn_syms->find(alias);
3748 alias_sym = fn_a->second.front();
3753 alias_sym = var_a->second.front();
3756 sym->add_alias(alias_sym);
3766static shared_ptr<function_decl::parameter>
3767build_function_parameter(reader& rdr,
const xmlNodePtr node)
3769 shared_ptr<function_decl::parameter> nil;
3771 if (!node || !xmlStrEqual(node->name, BAD_CAST(
"parameter")))
3774 bool is_variadic =
false;
3775 string is_variadic_str;
3776 if (xml_char_sptr s =
3777 xml::build_sptr(xmlGetProp(node, BAD_CAST(
"is-variadic"))))
3779 is_variadic_str = CHAR_STR(s) ? CHAR_STR(s) :
"";
3780 is_variadic = is_variadic_str ==
"yes";
3783 bool is_artificial =
false;
3784 read_is_artificial(node, is_artificial);
3787 if (xml_char_sptr a = xml::build_sptr(xmlGetProp(node, BAD_CAST(
"type-id"))))
3788 type_id = CHAR_STR(a);
3790 type_base_sptr type;
3792 type =
is_type(build_ir_node_for_variadic_parameter_type(rdr));
3796 type = rdr.build_or_get_type_decl(type_id,
true);
3801 if (xml_char_sptr a = xml::build_sptr(xmlGetProp(node, BAD_CAST(
"name"))))
3805 read_location(rdr, node, loc);
3808 (
new function_decl::parameter(type, name, loc,
3809 is_variadic, is_artificial));
3837build_function_decl(reader& rdr,
3838 const xmlNodePtr node,
3839 class_or_union_sptr as_method_decl,
3840 bool add_to_current_scope,
3841 bool add_to_exported_decls)
3845 if (!xmlStrEqual(node->name, BAD_CAST(
"function-decl")))
3852 string mangled_name;
3857 && !mangled_name.empty()
3858 && as_method_decl->find_member_function_sptr(mangled_name))
3861 as_method_decl->find_member_function_sptr(mangled_name);
3868 inline_prop = CHAR_STR(s);
3869 bool declared_inline = inline_prop ==
"yes";
3872 read_visibility(node, vis);
3875 read_binding(node, bind);
3877 size_t size = rdr.get_translation_unit()->get_address_size(), align = 0;
3878 read_size_and_alignment(node, size, align);
3881 read_location(rdr, node, loc);
3883 const environment& env = rdr.get_environment();
3885 std::vector<function_decl::parameter_sptr> parms;
3886 type_base_sptr return_type = env.get_void_type();
3888 for (xmlNodePtr n = xmlFirstElementChild(node);
3890 n = xmlNextElementSibling(n))
3892 if (xmlStrEqual(n->name, BAD_CAST(
"parameter")))
3895 build_function_parameter(rdr, n))
3898 else if (xmlStrEqual(n->name, BAD_CAST(
"return")))
3901 if (xml_char_sptr s =
3902 xml::build_sptr(xmlGetProp(n, BAD_CAST(
"type-id"))))
3903 type_id = CHAR_STR(s);
3904 if (!type_id.empty())
3905 return_type = rdr.build_or_get_type_decl(type_id,
true);
3910 ?
new method_type(return_type, as_method_decl,
3913 : new function_type(return_type,
3914 parms, size, align));
3918 rdr.read_hash_and_stash(node, fn_type);
3920 fn_type->set_is_artificial(
true);
3923 ?
new method_decl (name, fn_type,
3924 declared_inline, loc,
3925 mangled_name, vis, bind)
3926 : new function_decl(name, fn_type,
3927 declared_inline, loc,
3931 maybe_set_artificial_location(rdr, node, fn_decl);
3932 rdr.push_decl_to_scope(fn_decl,
3933 add_to_current_scope
3934 ? rdr.get_scope_ptr_for_node(node)
3936 RECORD_ARTIFACTS_AS_USED_IN_FN_DECL(rdr, fn_decl);
3940 fn_decl->set_symbol(sym);
3942 if (fn_decl->get_symbol() && fn_decl->get_symbol()->is_public())
3943 fn_decl->set_is_in_public_symbol_table(
true);
3945 rdr.get_translation_unit()->bind_function_type_life_time(fn_type);
3947 rdr.schedule_type_for_canonicalization(fn_type);
3949 if (add_to_exported_decls)
3950 rdr.add_fn_to_exported_or_undefined_decls(fn_decl.get());
3981build_function_decl_if_not_suppressed(reader& rdr,
3982 const xmlNodePtr node,
3983 class_or_union_sptr as_method_decl,
3984 bool add_to_current_scope,
3985 bool add_to_exported_decls)
3989 if (function_is_suppressed(rdr, node))
3995 fn = build_function_decl(rdr, node, as_method_decl,
3996 add_to_current_scope,
3997 add_to_exported_decls);
4013function_is_suppressed(
const reader& rdr, xmlNodePtr node)
4019 string flinkage_name;
4023 scope_decl* scope = rdr.get_cur_scope();
4042type_is_suppressed(
const reader& rdr, xmlNodePtr node)
4048 location type_location;
4049 read_location(rdr, node, type_location);
4051 scope_decl* scope = rdr.get_cur_scope();
4055 bool type_is_private =
false;
4074build_var_decl_if_not_suppressed(reader& rdr,
4075 const xmlNodePtr node,
4076 bool add_to_current_scope)
4079 if (!variable_is_suppressed(rdr, node))
4080 var = build_var_decl(rdr, node, add_to_current_scope);
4093variable_is_suppressed(
const reader& rdr, xmlNodePtr node)
4099 string linkage_name;
4103 scope_decl* scope = rdr.get_cur_scope();
4121variable_is_suppressed(
const reader& rdr,
4122 const scope_decl* scope,
4127 v.get_linkage_name());
4138static shared_ptr<var_decl>
4139build_var_decl(reader& rdr,
4140 const xmlNodePtr node,
4141 bool add_to_current_scope)
4143 shared_ptr<var_decl> nil;
4145 if (!xmlStrEqual(node->name, BAD_CAST(
"var-decl")))
4154 type_id = CHAR_STR(s);
4155 type_base_sptr underlying_type = rdr.build_or_get_type_decl(type_id,
4159 string mangled_name;
4164 read_visibility(node, vis);
4167 read_binding(node, bind);
4170 read_location(rdr, node, locus);
4173 locus, mangled_name,
4175 maybe_set_artificial_location(rdr, node, decl);
4179 decl->set_symbol(sym);
4181 rdr.push_decl_to_scope(decl,
4182 add_to_current_scope
4183 ? rdr.get_scope_ptr_for_node(node)
4185 if (add_to_current_scope)
4189 RECORD_ARTIFACT_AS_USED_BY(rdr, underlying_type, decl);
4192 if (decl->get_symbol() && decl->get_symbol()->is_public())
4193 decl->set_is_in_public_symbol_table(
true);
4203static decl_base_sptr
4204build_ir_node_for_void_type(reader& rdr)
4206 const environment& env = rdr.get_environment();
4208 type_base_sptr t = env.get_void_type();
4212 rdr.get_translation_unit()->get_global_scope());
4213 rdr.schedule_type_for_canonicalization(t);
4216 return type_declaration;
4230static decl_base_sptr
4231build_ir_node_for_void_pointer_type(reader& rdr)
4233 const environment& env = rdr.get_environment();
4235 type_base_sptr t = env.get_void_pointer_type();
4239 rdr.get_translation_unit()->get_global_scope());
4240 rdr.schedule_type_for_canonicalization(t);
4243 return type_declaration;
4251static decl_base_sptr
4252build_ir_node_for_variadic_parameter_type(reader& rdr)
4254 const environment& env = rdr.get_environment();
4256 type_base_sptr t = env.get_variadic_parameter_type();
4260 rdr.get_translation_unit()->get_global_scope());
4261 rdr.schedule_type_for_canonicalization(t);
4264 return type_declaration;
4279build_type_decl(reader& rdr,
4280 const xmlNodePtr node,
4281 bool add_to_current_scope)
4283 shared_ptr<type_decl> nil;
4285 if (!xmlStrEqual(node->name, BAD_CAST(
"type-decl")))
4288 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4304 size_t size_in_bits= 0;
4306 size_in_bits = atoi(CHAR_STR(s));
4308 size_t alignment_in_bits = 0;
4310 alignment_in_bits = atoi(CHAR_STR(s));
4312 bool is_decl_only =
false;
4313 read_is_declaration_only(node, is_decl_only);
4316 read_location(rdr, node, loc);
4318 bool is_anonymous =
false;
4319 read_is_anonymous(node, is_anonymous);
4321 if (type_base_sptr d = rdr.get_type_decl(
id))
4329 ABG_ASSERT(ty->get_size_in_bits() == size_in_bits);
4330 ABG_ASSERT(ty->get_alignment_in_bits() == alignment_in_bits);
4334 const environment& env = rdr.get_environment();
4336 if (name == env.get_variadic_parameter_type_name())
4337 decl =
is_type_decl(build_ir_node_for_variadic_parameter_type(rdr));
4338 else if (name ==
"void")
4341 decl.reset(
new type_decl(env, name, size_in_bits,
4342 alignment_in_bits, loc));
4343 maybe_set_artificial_location(rdr, node, decl);
4344 decl->set_is_anonymous(is_anonymous);
4345 decl->set_is_declaration_only(is_decl_only);
4347 rdr.read_hash_and_stash(node, decl);
4349 if (rdr.push_and_key_type_decl(decl, node, add_to_current_scope))
4351 rdr.map_xml_node_to_decl(node, decl);
4369static qualified_type_def_sptr
4370build_qualified_type_decl(reader& rdr,
4371 const xmlNodePtr node,
4372 bool add_to_current_scope)
4374 qualified_type_def_sptr nil;
4375 if (!xmlStrEqual(node->name, BAD_CAST(
"qualified-type-def")))
4378 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4380 qualified_type_def_sptr result =
4381 dynamic_pointer_cast<qualified_type_def>(d);
4393 read_location(rdr, node, loc);
4398 const_str = CHAR_STR(s);
4399 bool const_cv = const_str ==
"yes";
4401 string volatile_str;
4403 volatile_str = CHAR_STR(s);
4404 bool volatile_cv = volatile_str ==
"yes";
4406 string restrict_str;
4408 restrict_str = CHAR_STR(s);
4409 bool restrict_cv = restrict_str ==
"yes";
4412 cv = cv | qualified_type_def::CV_CONST;
4414 cv = cv | qualified_type_def::CV_VOLATILE;
4416 cv = cv | qualified_type_def::CV_RESTRICT;
4420 type_id = CHAR_STR(s);
4423 shared_ptr<type_base> underlying_type =
4424 rdr.build_or_get_type_decl(type_id,
true);
4427 if (type_base_sptr t = rdr.get_type_decl(
id))
4434 qualified_type_def_sptr decl;
4435 if (type_base_sptr t = rdr.get_type_decl(
id))
4442 decl.reset(
new qualified_type_def(underlying_type, cv, loc));
4443 maybe_set_artificial_location(rdr, node, decl);
4444 rdr.push_and_key_type_decl(decl, node, add_to_current_scope);
4445 RECORD_ARTIFACT_AS_USED_BY(rdr, underlying_type, decl);
4448 rdr.read_hash_and_stash(node, decl);
4450 rdr.map_xml_node_to_decl(node, decl);
4467build_pointer_type_def(reader& rdr,
4468 const xmlNodePtr node,
4469 bool add_to_current_scope)
4472 shared_ptr<pointer_type_def> nil;
4474 if (!xmlStrEqual(node->name, BAD_CAST(
"pointer-type-def")))
4477 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4480 dynamic_pointer_cast<pointer_type_def>(d);
4490 if (type_base_sptr t = rdr.get_type_decl(
id))
4499 type_id = CHAR_STR(s);
4501 size_t size_in_bits = rdr.get_translation_unit()->get_address_size();
4502 size_t alignment_in_bits = 0;
4503 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
4505 read_location(rdr, node, loc);
4507 type_base_sptr pointed_to_type =
4508 rdr.build_or_get_type_decl(type_id,
true);
4511 if (type_base_sptr t = rdr.get_type_decl(
id))
4519 if (rdr.get_environment().is_void_type(pointed_to_type))
4527 t.reset(
new pointer_type_def(pointed_to_type,
4532 maybe_set_artificial_location(rdr, node, t);
4534 rdr.push_and_key_type_decl(t, node, add_to_current_scope);
4535 rdr.map_xml_node_to_decl(node, t);
4538 rdr.read_hash_and_stash(node, t);
4540 RECORD_ARTIFACT_AS_USED_BY(rdr, pointed_to_type, t);
4556static shared_ptr<reference_type_def>
4557build_reference_type_def(reader& rdr,
4558 const xmlNodePtr node,
4559 bool add_to_current_scope)
4561 shared_ptr<reference_type_def> nil;
4563 if (!xmlStrEqual(node->name, BAD_CAST(
"reference-type-def")))
4566 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4569 dynamic_pointer_cast<reference_type_def>(d);
4579 if (type_base_sptr d = rdr.get_type_decl(
id))
4587 read_location(rdr, node, loc);
4591 bool is_lvalue = kind ==
"lvalue";
4593 size_t size_in_bits = rdr.get_translation_unit()->get_address_size();
4594 size_t alignment_in_bits = 0;
4595 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
4599 type_id = CHAR_STR(s);
4603 type_base_sptr pointed_to_type =
4604 rdr.build_or_get_type_decl(type_id,
true);
4609 if (type_base_sptr t = rdr.get_type_decl(
id))
4623 is_lvalue, size_in_bits,
4624 alignment_in_bits, loc));
4625 maybe_set_artificial_location(rdr, node, t);
4626 ABG_ASSERT(rdr.push_and_key_type_decl(t, node, add_to_current_scope));
4627 rdr.map_xml_node_to_decl(node, t);
4630 rdr.read_hash_and_stash(node, t);
4632 RECORD_ARTIFACT_AS_USED_BY(rdr, pointed_to_type, t);
4650build_ptr_to_mbr_type(reader& rdr,
4651 const xmlNodePtr node,
4652 bool add_to_current_scope)
4656 if (!xmlStrEqual(node->name, BAD_CAST(
"pointer-to-member-type")))
4659 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4673 if (type_base_sptr d = rdr.get_type_decl(
id))
4680 size_t size_in_bits = rdr.get_translation_unit()->get_address_size();
4681 size_t alignment_in_bits = 0;
4682 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
4685 read_location(rdr, node, loc);
4687 string member_type_id;
4689 member_type_id = CHAR_STR(s);
4690 if (member_type_id.empty())
4692 type_base_sptr member_type =
4693 is_type(rdr.build_or_get_type_decl(member_type_id,
true));
4697 if (type_base_sptr t = rdr.get_type_decl(
id))
4704 string containing_type_id;
4706 containing_type_id = CHAR_STR(s);
4707 if (containing_type_id.empty())
4709 type_base_sptr containing_type =
4710 rdr.build_or_get_type_decl(containing_type_id,
true);
4714 if (type_base_sptr t = rdr.get_type_decl(
id))
4721 result.reset(
new ptr_to_mbr_type(rdr.get_environment(),
4722 member_type, containing_type,
4723 size_in_bits, alignment_in_bits,
4727 rdr.read_hash_and_stash(node, result);
4729 if (rdr.push_and_key_type_decl(result, node, add_to_current_scope))
4730 rdr.map_xml_node_to_decl(node, result);
4748build_function_type(reader& rdr,
4749 const xmlNodePtr node,
4754 if (!xmlStrEqual(node->name, BAD_CAST(
"function-type")))
4762 string method_class_id;
4764 method_class_id = CHAR_STR(s);
4766 bool is_method_t = !method_class_id.empty();
4768 size_t size = rdr.get_translation_unit()->get_address_size(), align = 0;
4769 read_size_and_alignment(node, size, align);
4771 const environment& env = rdr.get_environment();
4772 std::vector<shared_ptr<function_decl::parameter> > parms;
4773 type_base_sptr return_type = env.get_void_type();
4775 class_or_union_sptr method_class_type;
4785 ?
new method_type(method_class_type,
4788 : new function_type(return_type,
4789 parms, size, align));
4792 rdr.read_hash_and_stash(node, fn_type);
4794 rdr.get_translation_unit()->bind_function_type_life_time(fn_type);
4795 rdr.key_type_decl(fn_type,
id);
4796 RECORD_ARTIFACTS_AS_USED_IN_FN_TYPE(rdr, fn_type);
4798 for (xmlNodePtr n = xmlFirstElementChild(node);
4800 n = xmlNextElementSibling(n))
4802 if (xmlStrEqual(n->name, BAD_CAST(
"parameter")))
4805 build_function_parameter(rdr, n))
4808 else if (xmlStrEqual(n->name, BAD_CAST(
"return")))
4811 if (xml_char_sptr s =
4812 xml::build_sptr(xmlGetProp(n, BAD_CAST(
"type-id"))))
4813 type_id = CHAR_STR(s);
4814 type_base_sptr ret_type;
4815 if (!type_id.empty())
4816 ret_type = rdr.build_or_get_type_decl (type_id,
true);
4818 ret_type = return_type;
4819 fn_type->set_return_type(ret_type);
4822 if (!fn_type->get_return_type())
4823 fn_type->set_return_type(return_type);
4825 fn_type->set_parameters(parms);
4841build_subrange_type(reader& rdr,
4842 const xmlNodePtr node,
4843 bool add_to_current_scope)
4847 if (!node || !xmlStrEqual(node->name, BAD_CAST(
"subrange")))
4850 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4853 dynamic_pointer_cast<array_type_def::subrange_type>(d);
4867 if (type_base_sptr d = rdr.get_type_decl(
id))
4878 uint64_t length = 0;
4880 bool is_non_finite =
false;
4883 if (
string(CHAR_STR(s)) ==
"infinite" ||
string(CHAR_STR(s)) ==
"unknown")
4884 is_non_finite =
true;
4886 length = strtoull(CHAR_STR(s), NULL, 0);
4889 uint64_t size_in_bits = 0;
4892 char *endptr =
nullptr;
4893 size_in_bits = strtoull(CHAR_STR(s), &endptr, 0);
4894 if (*endptr !=
'\0')
4896 if (!strcmp(CHAR_STR(s),
"infinite")
4897 ||!strcmp(CHAR_STR(s),
"unknown"))
4898 size_in_bits = (size_t) -1;
4904 int64_t lower_bound = 0, upper_bound = 0;
4905 bool bounds_present =
false;
4908 lower_bound = strtoll(CHAR_STR(s), NULL, 0);
4910 if (!
string(CHAR_STR(s)).empty())
4911 upper_bound = strtoll(CHAR_STR(s), NULL, 0);
4912 bounds_present =
true;
4914 || (length == (uint64_t) upper_bound - lower_bound + 1));
4917 string underlying_type_id;
4919 underlying_type_id = CHAR_STR(s);
4921 type_base_sptr underlying_type;
4922 if (!underlying_type_id.empty())
4924 underlying_type = rdr.build_or_get_type_decl(underlying_type_id,
true);
4928 if (type_base_sptr t = rdr.get_type_decl(
id))
4936 read_location(rdr, node, loc);
4941 array_type_def::subrange_type::bound_value max_bound;
4942 array_type_def::subrange_type::bound_value min_bound;
4948 max_bound.set_signed(length - 1);
4954 min_bound.set_signed(lower_bound);
4955 max_bound.set_signed(upper_bound);
4959 (
new array_type_def::subrange_type(rdr.get_environment(),
4960 name, min_bound, max_bound,
4961 underlying_type, loc));
4962 maybe_set_artificial_location(rdr, node, p);
4963 p->is_non_finite(is_non_finite);
4965 p->set_size_in_bits(size_in_bits);
4968 rdr.read_hash_and_stash(node, p);
4970 if (rdr.push_and_key_type_decl(p, node, add_to_current_scope))
4971 rdr.map_xml_node_to_decl(node, p);
4988build_array_type_def(reader& rdr,
4989 const xmlNodePtr node,
4990 bool add_to_current_scope)
4995 if (!xmlStrEqual(node->name, BAD_CAST(
"array-type-def")))
4998 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
5001 dynamic_pointer_cast<array_type_def>(d);
5011 if (type_base_sptr d = rdr.get_type_decl(
id))
5020 dimensions = atoi(CHAR_STR(s));
5024 type_id = CHAR_STR(s);
5026 size_t size_in_bits = 0, alignment_in_bits = 0;
5027 bool has_size_in_bits =
false;
5032 size_in_bits = strtoull(CHAR_STR(s), &endptr, 0);
5033 if (*endptr !=
'\0')
5035 if (!strcmp(CHAR_STR(s),
"infinite")
5036 ||!strcmp(CHAR_STR(s),
"unknown"))
5037 size_in_bits = (size_t) -1;
5041 has_size_in_bits =
true;
5046 alignment_in_bits = strtoull(CHAR_STR(s), &endptr, 0);
5047 if (*endptr !=
'\0')
5052 read_location(rdr, node, loc);
5055 for (xmlNodePtr n = xmlFirstElementChild(node);
5057 n = xmlNextElementSibling(n))
5058 if (xmlStrEqual(n->name, BAD_CAST(
"subrange")))
5061 build_subrange_type(rdr, n,
true))
5063 MAYBE_MAP_TYPE_WITH_TYPE_ID(s, n);
5064 if (add_to_current_scope)
5067 rdr.schedule_type_for_canonicalization(s);
5069 subranges.push_back(s);
5074 type_base_sptr type =
5075 rdr.build_or_get_type_decl(type_id,
true);
5080 if (type_base_sptr t = rdr.get_type_decl(
id))
5089 rdr.read_hash_and_stash(node, ar_type);
5091 maybe_set_artificial_location(rdr, node, ar_type);
5092 if (rdr.push_and_key_type_decl(ar_type, node, add_to_current_scope))
5093 rdr.map_xml_node_to_decl(node, ar_type);
5094 RECORD_ARTIFACT_AS_USED_BY(rdr, type, ar_type);
5096 if (dimensions != ar_type->get_dimension_count()
5097 || (alignment_in_bits
5098 != ar_type->get_element_type()->get_alignment_in_bits()))
5101 if (has_size_in_bits && size_in_bits != (
size_t) -1
5102 && size_in_bits != ar_type->get_size_in_bits())
5105 size_t element_size = ar_type->get_element_type()->get_size_in_bits();
5106 if (element_size && element_size != (
size_t)-1)
5109 size_t bad_count = 0;
5110 for (vector<array_type_def::subrange_sptr>::const_iterator i =
5112 i != subranges.end();
5114 bad_count += (*i)->get_length();
5115 if (size_in_bits == bad_count * element_size)
5117 static bool reported =
false;
5120 std::cerr <<
"notice: Found incorrectly calculated array "
5121 <<
"sizes in XML - this is benign.\nOlder versions "
5122 <<
"of libabigail miscalculated multidimensional "
5123 <<
"array sizes." << std::endl;
5129 std::cerr <<
"error: Found incorrectly calculated array size in "
5130 <<
"XML (id=\"" <<
id <<
"\")." << std::endl;
5154build_enum_type_decl_if_not_suppressed(reader& rdr,
5155 const xmlNodePtr node,
5156 bool add_to_current_scope)
5159 if (!type_is_suppressed(rdr, node))
5160 enum_type = build_enum_type_decl(rdr, node, add_to_current_scope);
5176build_enum_type_decl(reader& rdr,
5177 const xmlNodePtr node,
5178 bool add_to_current_scope)
5182 if (!xmlStrEqual(node->name, BAD_CAST(
"enum-decl")))
5185 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
5188 dynamic_pointer_cast<enum_type_decl>(d);
5197 string linkage_name;
5202 read_location(rdr, node, loc);
5204 bool is_decl_only =
false;
5205 read_is_declaration_only(node, is_decl_only);
5207 bool is_anonymous =
false;
5208 read_is_anonymous(node, is_anonymous);
5210 bool is_artificial =
false;
5211 read_is_artificial(node, is_artificial);
5219 if (type_base_sptr t = rdr.get_type_decl(
id))
5226 string base_type_id;
5228 for (xmlNodePtr n = xmlFirstElementChild(node);
5230 n = xmlNextElementSibling(n))
5232 if (xmlStrEqual(n->name, BAD_CAST(
"underlying-type")))
5234 xml_char_sptr a = xml::build_sptr(xmlGetProp(n, BAD_CAST(
"type-id")));
5236 base_type_id = CHAR_STR(a);
5239 else if (xmlStrEqual(n->name, BAD_CAST(
"enumerator")))
5244 xml_char_sptr a = xml::build_sptr(xmlGetProp(n, BAD_CAST(
"name")));
5248 a = xml::build_sptr(xmlGetProp(n, BAD_CAST(
"value")));
5251 value = strtoll(CHAR_STR(a), NULL, 0);
5255 if ((errno == ERANGE)
5256 && (value == LLONG_MIN || value == LLONG_MAX))
5260 enums.push_back(enum_type_decl::enumerator(name, value));
5264 type_base_sptr underlying_type =
5265 rdr.build_or_get_type_decl(base_type_id,
true);
5268 if (type_base_sptr t = rdr.get_type_decl(
id))
5277 enums, linkage_name));
5278 maybe_set_artificial_location(rdr, node, t);
5279 t->set_is_anonymous(is_anonymous);
5280 t->set_is_artificial(is_artificial);
5281 t->set_is_declaration_only(is_decl_only);
5283 rdr.read_hash_and_stash(node, t);
5285 if (rdr.push_and_key_type_decl(t, node, add_to_current_scope))
5287 maybe_set_naming_typedef(rdr, node, t);
5288 rdr.map_xml_node_to_decl(node, t);
5289 RECORD_ARTIFACT_AS_USED_BY(rdr, underlying_type, t);
5304static shared_ptr<typedef_decl>
5305build_typedef_decl(reader& rdr,
5306 const xmlNodePtr node,
5307 bool add_to_current_scope)
5309 shared_ptr<typedef_decl> nil;
5311 if (!xmlStrEqual(node->name, BAD_CAST(
"typedef-decl")))
5314 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
5326 if (type_base_sptr t = rdr.get_type_decl(
id))
5338 read_location(rdr, node, loc);
5342 type_id = CHAR_STR(s);
5345 type_base_sptr underlying_type(rdr.build_or_get_type_decl(type_id,
true));
5350 if (type_base_sptr t = rdr.get_type_decl(
id))
5358 maybe_set_artificial_location(rdr, node, t);
5361 rdr.read_hash_and_stash(node, t);
5363 rdr.push_and_key_type_decl(t, node, add_to_current_scope);
5364 rdr.map_xml_node_to_decl(node, t);
5365 RECORD_ARTIFACT_AS_USED_BY(rdr, underlying_type, t);
5382build_class_decl_if_not_suppressed(reader& rdr,
5383 const xmlNodePtr node,
5384 bool add_to_current_scope)
5387 if (!type_is_suppressed(rdr, node))
5388 class_type = build_class_decl(rdr, node, add_to_current_scope);
5404static union_decl_sptr
5405build_union_decl_if_not_suppressed(reader& rdr,
5406 const xmlNodePtr node,
5407 bool add_to_current_scope)
5409 union_decl_sptr union_type;
5410 if (!type_is_suppressed(rdr, node))
5411 union_type = build_union_decl(rdr, node, add_to_current_scope);
5428build_class_decl(reader& rdr,
5429 const xmlNodePtr node,
5430 bool add_to_current_scope)
5434 if (!xmlStrEqual(node->name, BAD_CAST(
"class-decl")))
5437 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
5448 size_t size_in_bits = 0, alignment_in_bits = 0;
5449 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
5452 read_visibility(node, vis);
5454 bool is_artificial =
false;
5455 read_is_artificial(node, is_artificial);
5462 read_location(rdr, node, loc);
5464 class_decl::member_types mbrs;
5465 class_decl::data_members data_mbrs;
5466 class_decl::member_functions mbr_functions;
5471 bool is_decl_only =
false;
5472 read_is_declaration_only(node, is_decl_only);
5474 bool is_struct =
false;
5475 read_is_struct(node, is_struct);
5477 bool is_anonymous =
false;
5478 read_is_anonymous(node, is_anonymous);
5484 if (type_base_sptr t = rdr.get_type_decl(
id))
5490 const vector<type_base_sptr> *types_ptr = 0;
5491 if (!is_anonymous && !previous_definition)
5492 types_ptr = rdr.get_all_type_decls(
id);
5498 for (vector<type_base_sptr>::const_iterator i = types_ptr->begin();
5499 i != types_ptr->end();
5504 if (klass->get_is_declaration_only()
5505 && !klass->get_definition_of_declaration())
5506 previous_declaration = klass;
5507 else if (!klass->get_is_declaration_only()
5508 && !previous_definition)
5509 previous_definition = klass;
5510 if (previous_definition && previous_declaration)
5514 if (previous_declaration)
5515 ABG_ASSERT(previous_declaration->get_name() == name);
5517 if (previous_definition)
5518 ABG_ASSERT(previous_definition->get_name() == name);
5520 if (is_decl_only && previous_declaration)
5521 return previous_declaration;
5524 const environment& env = rdr.get_environment();
5526 if (!is_decl_only && previous_definition)
5532 decl = previous_definition;
5537 decl.reset(
new class_decl(env, name, is_struct));
5539 decl->set_size_in_bits(size_in_bits);
5541 decl->set_is_anonymous(is_anonymous);
5542 decl->set_location(loc);
5545 decl.reset(
new class_decl(env, name, size_in_bits, alignment_in_bits,
5546 is_struct, loc, vis, bases, mbrs,
5547 data_mbrs, mbr_functions, is_anonymous));
5550 maybe_set_artificial_location(rdr, node, decl);
5551 decl->set_is_artificial(is_artificial);
5554 rdr.read_hash_and_stash(node, decl);
5557 bool is_def_of_decl =
false;
5559 def_id = CHAR_STR(s);
5561 if (!def_id.empty())
5563 decl_base_sptr d =
is_decl(rdr.get_type_decl(def_id));
5564 if (d && d->get_is_declaration_only())
5566 is_def_of_decl =
true;
5567 decl->set_earlier_declaration(d);
5568 d->set_definition_of_declaration(decl);
5574 && !decl->get_is_declaration_only()
5575 && previous_declaration)
5581 decl->set_earlier_declaration(
is_decl(previous_declaration));
5582 for (vector<type_base_sptr>::const_iterator i = types_ptr->begin();
5583 i != types_ptr->end();
5588 if (d->get_is_declaration_only()
5589 && !d->get_definition_of_declaration())
5591 previous_declaration->set_definition_of_declaration(decl);
5592 is_def_of_decl =
true;
5597 if (is_decl_only && previous_definition)
5602 && !decl->get_definition_of_declaration());
5603 decl->set_definition_of_declaration(previous_definition);
5606 ABG_ASSERT(!is_decl_only || !is_def_of_decl);
5608 rdr.push_decl_to_scope(decl,
5609 add_to_current_scope
5610 ? rdr.get_scope_ptr_for_node(node)
5613 rdr.map_xml_node_to_decl(node, decl);
5614 rdr.key_type_decl(decl,
id);
5617 maybe_set_naming_typedef(rdr, node, decl);
5619 for (xmlNodePtr n = xmlFirstElementChild(node);
5621 n = xmlNextElementSibling(n))
5623 if (xmlStrEqual(n->name, BAD_CAST(
"base-class")))
5629 read_access(n, access);
5633 type_id = CHAR_STR(s);
5634 shared_ptr<class_decl> b =
5635 dynamic_pointer_cast<class_decl>
5636 (rdr.build_or_get_type_decl(type_id,
true));
5639 if (decl->find_base_class(b->get_qualified_name()))
5645 size_t offset_in_bits = 0;
5646 bool offset_present = read_offset_in_bits (n, offset_in_bits);
5648 bool is_virtual =
false;
5649 read_is_virtual (n, is_virtual);
5651 shared_ptr<class_decl::base_spec> base (
new class_decl::base_spec
5654 ? (
long) offset_in_bits
5657 decl->add_base_specifier(base);
5659 else if (xmlStrEqual(n->name, BAD_CAST(
"member-type")))
5665 read_access(n, access);
5667 rdr.map_xml_node_to_decl(n, decl);
5669 for (xmlNodePtr p = xmlFirstElementChild(n);
5671 p = xmlNextElementSibling(p))
5674 string member_type_name;
5675 read_name(p, member_type_name);
5677 if (!member_type_name.empty())
5678 t = decl->find_member_type(member_type_name);
5682 if ((t = build_type(rdr, p,
true)))
5686 if (!td->get_scope())
5687 decl->add_member_type(t);
5689 rdr.schedule_type_for_canonicalization(t);
5691 string id = CHAR_STR(i);
5693 rdr.key_type_decl(t,
id);
5694 rdr.map_xml_node_to_decl(p, td);
5698 else if (xmlStrEqual(n->name, BAD_CAST(
"data-member")))
5700 rdr.map_xml_node_to_decl(n, decl);
5706 read_access(n, access);
5708 bool is_laid_out =
false;
5709 size_t offset_in_bits = 0;
5710 if (read_offset_in_bits(n, offset_in_bits))
5713 bool is_static =
false;
5714 read_static(n, is_static);
5716 for (xmlNodePtr p = xmlFirstElementChild(n);
5718 p = xmlNextElementSibling(p))
5721 build_var_decl(rdr, p,
false))
5723 if (decl->find_data_member(v))
5731 decl_base_sptr d = rdr.pop_decl();
5736 if (!variable_is_suppressed(rdr, decl.get(), *v))
5738 decl->add_data_member(v, access,
5743 rdr.add_var_to_exported_or_undefined_decls(v);
5753 RECORD_ARTIFACT_AS_USED_BY(rdr, v->get_type(), decl);
5756 RECORD_ARTIFACT_AS_USED_BY(rdr, v->get_type(), v);
5757 RECORD_ARTIFACT_AS_USED_BY(rdr, v, decl);
5763 else if (xmlStrEqual(n->name, BAD_CAST(
"member-function")))
5769 read_access(n, access);
5771 bool is_virtual =
false;
5772 ssize_t vtable_offset = -1;
5773 if (xml_char_sptr s =
5777 vtable_offset = atoi(CHAR_STR(s));
5780 bool is_static =
false;
5781 read_static(n, is_static);
5783 bool is_ctor =
false, is_dtor =
false, is_const =
false;
5784 read_cdtor_const(n, is_ctor, is_dtor, is_const);
5786 for (xmlNodePtr p = xmlFirstElementChild(n);
5788 p = xmlNextElementSibling(p))
5791 build_function_decl_if_not_suppressed(rdr, p, decl,
5804 rdr.map_xml_node_to_decl(p, m);
5805 rdr.add_fn_to_exported_or_undefined_decls(f.get());
5810 else if (xmlStrEqual(n->name, BAD_CAST(
"member-template")))
5812 rdr.map_xml_node_to_decl(n, decl);
5818 read_access(n, access);
5820 bool is_static =
false;
5821 read_static(n, is_static);
5823 bool is_ctor =
false, is_dtor =
false, is_const =
false;
5824 read_cdtor_const(n, is_ctor, is_dtor, is_const);
5826 for (xmlNodePtr p = xmlFirstElementChild(n);
5828 p = xmlNextElementSibling(p))
5830 if (shared_ptr<function_tdecl> f =
5831 build_function_tdecl(rdr, p,
5834 shared_ptr<member_function_template> m
5835 (
new member_function_template(f, access, is_static,
5836 is_ctor, is_const));
5838 decl->add_member_function_template(m);
5840 else if (shared_ptr<class_tdecl> c =
5841 build_class_tdecl(rdr, p,
5844 member_class_template_sptr m(
new member_class_template(c,
5848 decl->add_member_class_template(m);
5854 rdr.pop_scope_or_abort(decl);
5871static union_decl_sptr
5872build_union_decl(reader& rdr,
5873 const xmlNodePtr node,
5874 bool add_to_current_scope)
5876 union_decl_sptr nil;
5878 if (!xmlStrEqual(node->name, BAD_CAST(
"union-decl")))
5881 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
5883 union_decl_sptr result = dynamic_pointer_cast<union_decl>(d);
5892 size_t size_in_bits = 0, alignment_in_bits = 0;
5893 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
5896 read_visibility(node, vis);
5898 bool is_artificial =
false;
5899 read_is_artificial(node, is_artificial);
5906 read_location(rdr, node, loc);
5908 union_decl::member_types mbrs;
5909 union_decl::data_members data_mbrs;
5910 union_decl::member_functions mbr_functions;
5912 union_decl_sptr decl;
5914 bool is_decl_only =
false;
5915 read_is_declaration_only(node, is_decl_only);
5917 bool is_anonymous =
false;
5918 read_is_anonymous(node, is_anonymous);
5921 union_decl_sptr previous_definition, previous_declaration;
5922 const vector<type_base_sptr> *types_ptr = 0;
5924 types_ptr = rdr.get_all_type_decls(
id);
5930 for (vector<type_base_sptr>::const_iterator i = types_ptr->begin();
5931 i != types_ptr->end();
5936 if (onion->get_is_declaration_only()
5937 && !onion->get_definition_of_declaration())
5938 previous_declaration = onion;
5939 else if (!onion->get_is_declaration_only()
5940 && !previous_definition)
5941 previous_definition = onion;
5942 if (previous_definition && previous_declaration)
5946 if (previous_declaration)
5947 ABG_ASSERT(previous_declaration->get_name() == name);
5949 if (previous_definition)
5950 ABG_ASSERT(previous_definition->get_name() == name);
5952 if (is_decl_only && previous_declaration)
5953 return previous_declaration;
5956 const environment& env = rdr.get_environment();
5958 if (!is_decl_only && previous_definition)
5964 decl = previous_definition;
5968 decl.reset(
new union_decl(env, name));
5970 decl.reset(
new union_decl(env, name,
5979 rdr.read_hash_and_stash(node, decl);
5981 maybe_set_artificial_location(rdr, node, decl);
5982 decl->set_is_artificial(is_artificial);
5985 bool is_def_of_decl =
false;
5987 def_id = CHAR_STR(s);
5989 if (!def_id.empty())
5992 dynamic_pointer_cast<class_decl>(rdr.get_type_decl(def_id));
5993 if (d && d->get_is_declaration_only())
5995 is_def_of_decl =
true;
5996 decl->set_earlier_declaration(d);
5997 d->set_definition_of_declaration(decl);
6003 && !decl->get_is_declaration_only()
6004 && previous_declaration)
6010 decl->set_earlier_declaration(previous_declaration);
6011 for (vector<type_base_sptr>::const_iterator i = types_ptr->begin();
6012 i != types_ptr->end();
6017 if (d->get_is_declaration_only()
6018 && !d->get_definition_of_declaration())
6020 previous_declaration->set_definition_of_declaration(decl);
6021 is_def_of_decl =
true;
6026 if (is_decl_only && previous_definition)
6031 && !decl->get_definition_of_declaration());
6032 decl->set_definition_of_declaration(previous_definition);
6035 ABG_ASSERT(!is_decl_only || !is_def_of_decl);
6037 rdr.push_decl_to_scope(decl,
6038 add_to_current_scope
6039 ? rdr.get_scope_ptr_for_node(node)
6042 rdr.map_xml_node_to_decl(node, decl);
6043 rdr.key_type_decl(decl,
id);
6045 maybe_set_naming_typedef(rdr, node, decl);
6047 for (xmlNodePtr n = xmlFirstElementChild(node);
6049 n = xmlNextElementSibling(n))
6051 if (xmlStrEqual(n->name, BAD_CAST(
"member-type")))
6054 read_access(n, access);
6056 rdr.map_xml_node_to_decl(n, decl);
6058 for (xmlNodePtr p = xmlFirstElementChild(n);
6060 p = xmlNextElementSibling(p))
6062 string member_type_name;
6063 read_name(p, member_type_name);
6065 if (!member_type_name.empty())
6066 t = decl->find_member_type(member_type_name);
6069 if ((t = build_type(rdr, p,
true)))
6073 if (!td->get_scope())
6074 decl->add_member_type(t);
6076 rdr.schedule_type_for_canonicalization(t);
6079 string id = CHAR_STR(i);
6081 rdr.key_type_decl(t,
id);
6082 rdr.map_xml_node_to_decl(p, td);
6086 else if (xmlStrEqual(n->name, BAD_CAST(
"data-member")))
6088 rdr.map_xml_node_to_decl(n, decl);
6091 read_access(n, access);
6093 bool is_laid_out =
true;
6094 size_t offset_in_bits = 0;
6095 bool is_static =
false;
6096 read_static(n, is_static);
6098 for (xmlNodePtr p = xmlFirstElementChild(n);
6100 p = xmlNextElementSibling(p))
6103 build_var_decl(rdr, p,
false))
6105 if (decl->find_data_member(v))
6113 decl_base_sptr d = rdr.pop_decl();
6118 || !variable_is_suppressed(rdr, decl.get(), *v))
6120 decl->add_data_member(v, access,
6133 RECORD_ARTIFACT_AS_USED_BY(rdr, v->get_type(), decl);
6136 RECORD_ARTIFACT_AS_USED_BY(rdr, v->get_type(), v);
6137 RECORD_ARTIFACT_AS_USED_BY(rdr, v, decl);
6143 else if (xmlStrEqual(n->name, BAD_CAST(
"member-function")))
6145 rdr.map_xml_node_to_decl(n, decl);
6148 read_access(n, access);
6150 bool is_static =
false;
6151 read_static(n, is_static);
6153 bool is_ctor =
false, is_dtor =
false, is_const =
false;
6154 read_cdtor_const(n, is_ctor, is_dtor, is_const);
6156 for (xmlNodePtr p = xmlFirstElementChild(n);
6158 p = xmlNextElementSibling(p))
6161 build_function_decl_if_not_suppressed(rdr, p, decl,
6172 rdr.add_fn_to_exported_or_undefined_decls(f.get());
6177 else if (xmlStrEqual(n->name, BAD_CAST(
"member-template")))
6179 rdr.map_xml_node_to_decl(n, decl);
6182 read_access(n, access);
6184 bool is_static =
false;
6185 read_static(n, is_static);
6187 bool is_ctor =
false, is_dtor =
false, is_const =
false;
6188 read_cdtor_const(n, is_ctor, is_dtor, is_const);
6190 for (xmlNodePtr p = xmlFirstElementChild(n);
6192 p = xmlNextElementSibling(p))
6195 build_function_tdecl(rdr, p,
6198 member_function_template_sptr m
6199 (
new member_function_template(f, access, is_static,
6200 is_ctor, is_const));
6202 decl->add_member_function_template(m);
6205 build_class_tdecl(rdr, p,
6208 member_class_template_sptr m(
new member_class_template(c,
6212 decl->add_member_class_template(m);
6218 rdr.pop_scope_or_abort(decl);
6235static shared_ptr<function_tdecl>
6236build_function_tdecl(reader& rdr,
6237 const xmlNodePtr node,
6238 bool add_to_current_scope)
6240 shared_ptr<function_tdecl> nil, result;
6242 if (!xmlStrEqual(node->name, BAD_CAST(
"function-template-decl")))
6248 if (
id.empty() || rdr.get_fn_tmpl_decl(
id))
6252 read_location(rdr, node, loc);
6255 read_visibility(node, vis);
6258 read_binding(node, bind);
6260 const environment& env = rdr.get_environment();
6263 maybe_set_artificial_location(rdr, node, fn_tmpl_decl);
6265 rdr.push_decl_to_scope(fn_tmpl_decl,
6266 add_to_current_scope
6267 ? rdr.get_scope_ptr_for_node(node)
6269 rdr.key_fn_tmpl_decl(fn_tmpl_decl,
id);
6270 rdr.map_xml_node_to_decl(node, fn_tmpl_decl);
6272 unsigned parm_index = 0;
6273 for (xmlNodePtr n = xmlFirstElementChild(node);
6275 n = xmlNextElementSibling(n))
6278 build_template_parameter(rdr, n, parm_index, fn_tmpl_decl))
6280 fn_tmpl_decl->add_template_parameter(parm);
6287 fn_tmpl_decl->set_pattern(f);
6290 rdr.key_fn_tmpl_decl(fn_tmpl_decl,
id);
6292 return fn_tmpl_decl;
6308build_class_tdecl(reader& rdr,
6309 const xmlNodePtr node,
6310 bool add_to_current_scope)
6314 if (!xmlStrEqual(node->name, BAD_CAST(
"class-template-decl")))
6320 if (
id.empty() || rdr.get_class_tmpl_decl(
id))
6324 read_location(rdr, node, loc);
6327 read_visibility(node, vis);
6329 const environment& env = rdr.get_environment();
6332 maybe_set_artificial_location(rdr, node, class_tmpl);
6334 if (add_to_current_scope)
6335 rdr.push_decl_to_scope(class_tmpl, node);
6336 rdr.key_class_tmpl_decl(class_tmpl,
id);
6337 rdr.map_xml_node_to_decl(node, class_tmpl);
6339 unsigned parm_index = 0;
6340 for (xmlNodePtr n = xmlFirstElementChild(node);
6342 n = xmlNextElementSibling(n))
6345 build_template_parameter(rdr, n, parm_index, class_tmpl))
6347 class_tmpl->add_template_parameter(parm);
6351 build_class_decl_if_not_suppressed(rdr, n,
6352 add_to_current_scope))
6355 rdr.schedule_type_for_canonicalization(c);
6356 class_tmpl->set_pattern(c);
6360 rdr.key_class_tmpl_decl(class_tmpl,
id);
6381build_type_tparameter(reader& rdr,
6382 const xmlNodePtr node,
6388 if (!xmlStrEqual(node->name, BAD_CAST(
"template-type-parameter")))
6399 type_id = CHAR_STR(s);
6400 if (!type_id.empty()
6401 && !(result = dynamic_pointer_cast<type_tparameter>
6402 (rdr.build_or_get_type_decl(type_id,
true))))
6410 read_location(rdr, node,loc);
6412 result.reset(
new type_tparameter(index, tdecl, name, loc));
6413 maybe_set_artificial_location(rdr, node, result);
6416 rdr.push_decl_to_scope(
is_decl(result), node);
6418 rdr.push_and_key_type_decl(result, node,
true);
6420 rdr.schedule_type_for_canonicalization(result);
6440build_type_composition(reader& rdr,
6441 const xmlNodePtr node,
6447 if (!xmlStrEqual(node->name, BAD_CAST(
"template-parameter-type-composition")))
6450 type_base_sptr composed_type;
6451 result.reset(
new type_composition(index, tdecl, composed_type));
6452 rdr.push_decl_to_scope(
is_decl(result), node);
6454 for (xmlNodePtr n = xmlFirstElementChild(node);
6456 n = xmlNextElementSibling(n))
6458 if ((composed_type =
6459 build_pointer_type_def(rdr, n,
6462 build_reference_type_def(rdr, n,
6465 build_array_type_def(rdr, n,
6468 build_qualified_type_decl(rdr, n,
6471 rdr.schedule_type_for_canonicalization(composed_type);
6472 result->set_composed_type(composed_type);
6496build_non_type_tparameter(reader& rdr,
6497 const xmlNodePtr node,
6503 if (!xmlStrEqual(node->name, BAD_CAST(
"template-non-type-parameter")))
6508 type_id = CHAR_STR(s);
6509 type_base_sptr type;
6511 || !(type = rdr.build_or_get_type_decl(type_id,
true)))
6519 read_location(rdr, node,loc);
6521 r.reset(
new non_type_tparameter(index, tdecl, name, type, loc));
6522 maybe_set_artificial_location(rdr, node, r);
6523 rdr.push_decl_to_scope(
is_decl(r), node);
6543build_template_tparameter(reader& rdr,
6544 const xmlNodePtr node,
6550 if (!xmlStrEqual(node->name, BAD_CAST(
"template-template-parameter")))
6561 type_id = CHAR_STR(s);
6563 if (!type_id.empty()
6564 && !(dynamic_pointer_cast<template_tparameter>
6565 (rdr.build_or_get_type_decl(type_id,
true))))
6573 read_location(rdr, node, loc);
6577 maybe_set_artificial_location(rdr, node, result);
6578 rdr.push_decl_to_scope(result, node);
6582 for (xmlNodePtr n = xmlFirstElementChild(node);
6584 n = xmlNextElementSibling(n))
6585 if (shared_ptr<template_parameter> p =
6586 build_template_parameter(rdr, n, parm_index, result))
6588 result->add_template_parameter(p);
6594 rdr.key_type_decl(result,
id);
6595 rdr.schedule_type_for_canonicalization(result);
6617build_template_parameter(reader& rdr,
6618 const xmlNodePtr node,
6622 shared_ptr<template_parameter> r;
6623 ((r = build_type_tparameter(rdr, node, index, tdecl))
6624 || (r = build_non_type_tparameter(rdr, node, index, tdecl))
6625 || (r = build_template_tparameter(rdr, node, index, tdecl))
6626 || (r = build_type_composition(rdr, node, index, tdecl)));
6639static type_base_sptr
6640build_type(reader& rdr,
6641 const xmlNodePtr node,
6642 bool add_to_current_scope)
6646 ((t = build_type_decl(rdr, node, add_to_current_scope))
6647 || (t = build_qualified_type_decl(rdr, node, add_to_current_scope))
6648 || (t = build_pointer_type_def(rdr, node, add_to_current_scope))
6649 || (t = build_reference_type_def(rdr, node , add_to_current_scope))
6650 || (t = build_ptr_to_mbr_type(rdr, node , add_to_current_scope))
6651 || (t = build_function_type(rdr, node, add_to_current_scope))
6652 || (t = build_array_type_def(rdr, node, add_to_current_scope))
6653 || (t = build_subrange_type(rdr, node, add_to_current_scope))
6654 || (t = build_enum_type_decl_if_not_suppressed(rdr, node,
6655 add_to_current_scope))
6656 || (t = build_typedef_decl(rdr, node, add_to_current_scope))
6657 || (t = build_class_decl_if_not_suppressed(rdr, node,
6658 add_to_current_scope))
6659 || (t = build_union_decl_if_not_suppressed(rdr, node,
6660 add_to_current_scope)));
6662 if (rdr.tracking_non_reachable_types() && t)
6664 corpus_sptr abi = rdr.corpus();
6666 bool is_non_reachable_type =
false;
6667 read_is_non_reachable_type(node, is_non_reachable_type);
6668 if (!is_non_reachable_type)
6669 abi->record_type_as_reachable_from_public_interfaces(*t);
6672 MAYBE_MAP_TYPE_WITH_TYPE_ID(t, node);
6675 rdr.schedule_type_for_canonicalization(t);
6684static decl_base_sptr
6685handle_type_decl(reader& rdr,
6687 bool add_to_current_scope)
6689 type_decl_sptr decl = build_type_decl(rdr, node, add_to_current_scope);
6690 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6691 if (decl && decl->get_scope())
6692 rdr.schedule_type_for_canonicalization(decl);
6701static decl_base_sptr
6702handle_namespace_decl(reader& rdr,
6704 bool add_to_current_scope)
6707 add_to_current_scope);
6716static decl_base_sptr
6717handle_qualified_type_decl(reader& rdr,
6719 bool add_to_current_scope)
6721 qualified_type_def_sptr decl =
6722 build_qualified_type_decl(rdr, node,
6723 add_to_current_scope);
6724 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6725 if (decl && decl->get_scope())
6726 rdr.schedule_type_for_canonicalization(decl);
6735static decl_base_sptr
6736handle_pointer_type_def(reader& rdr,
6738 bool add_to_current_scope)
6741 add_to_current_scope);
6742 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6743 if (decl && decl->get_scope())
6744 rdr.schedule_type_for_canonicalization(decl);
6753static decl_base_sptr
6754handle_reference_type_def(reader& rdr,
6756 bool add_to_current_scope)
6759 add_to_current_scope);
6760 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6761 if (decl && decl->get_scope())
6762 rdr.schedule_type_for_canonicalization(decl);
6771static type_base_sptr
6772handle_function_type(reader& rdr,
6774 bool add_to_current_scope)
6777 add_to_current_scope);
6778 MAYBE_MAP_TYPE_WITH_TYPE_ID(type, node);
6779 rdr.schedule_type_for_canonicalization(type);
6788static decl_base_sptr
6789handle_array_type_def(reader& rdr,
6791 bool add_to_current_scope)
6794 add_to_current_scope);
6795 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6796 rdr.schedule_type_for_canonicalization(decl);
6803static decl_base_sptr
6804handle_enum_type_decl(reader& rdr,
6806 bool add_to_current_scope)
6809 build_enum_type_decl_if_not_suppressed(rdr, node,
6810 add_to_current_scope);
6811 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6812 if (decl && decl->get_scope())
6813 rdr.schedule_type_for_canonicalization(decl);
6820static decl_base_sptr
6821handle_typedef_decl(reader& rdr,
6823 bool add_to_current_scope)
6826 add_to_current_scope);
6827 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6828 if (decl && decl->get_scope())
6829 rdr.schedule_type_for_canonicalization(decl);
6841static decl_base_sptr
6842handle_var_decl(reader& rdr,
6844 bool add_to_current_scope)
6846 decl_base_sptr decl = build_var_decl_if_not_suppressed(rdr, node,
6847 add_to_current_scope);
6848 rdr.add_var_to_exported_or_undefined_decls(
is_var_decl(decl));
6858static decl_base_sptr
6859handle_function_decl(reader& rdr,
6861 bool add_to_current_scope)
6863 return build_function_decl_if_not_suppressed(rdr, node,
class_decl_sptr(),
6864 add_to_current_scope,
6874static decl_base_sptr
6875handle_class_decl(reader& rdr,
6877 bool add_to_current_scope)
6880 build_class_decl_if_not_suppressed(rdr, node, add_to_current_scope);
6881 MAYBE_MAP_TYPE_WITH_TYPE_ID(
is_type(decl), node);
6882 if (decl && decl->get_scope())
6883 rdr.schedule_type_for_canonicalization(decl);
6893static decl_base_sptr
6894handle_union_decl(reader& rdr,
6896 bool add_to_current_scope)
6898 union_decl_sptr decl =
6899 build_union_decl_if_not_suppressed(rdr, node, add_to_current_scope);
6900 MAYBE_MAP_TYPE_WITH_TYPE_ID(
is_type(decl), node);
6901 if (decl && decl->get_scope())
6902 rdr.schedule_type_for_canonicalization(decl);
6912static decl_base_sptr
6913handle_function_tdecl(reader& rdr,
6915 bool add_to_current_scope)
6918 add_to_current_scope);
6927static decl_base_sptr
6928handle_class_tdecl(reader& rdr,
6930 bool add_to_current_scope)
6933 add_to_current_scope);
6950 return read_translation_unit_from_input(read_rdr);
6975 corpus_sptr corp = result->corpus();
6976 corp->set_origin(corpus::NATIVE_XML_ORIGIN);
6977#ifdef WITH_DEBUG_SELF_COMPARISON
6978 if (env.self_comparison_debug_is_on())
6979 env.set_self_comparison_debug_input(result->corpus());
6981 result->set_path(path);
6998 corpus_sptr corp = result->corpus();
6999 corp->set_origin(corpus::NATIVE_XML_ORIGIN);
7000#ifdef WITH_DEBUG_SELF_COMPARISON
7001 if (env.self_comparison_debug_is_on())
7002 env.set_self_comparison_debug_input(result->corpus());
7025 return rdr->read_corpus(sts);
7047 corpus_sptr corp = rdr->read_corpus(sts);