56using std::unordered_map;
57using std::dynamic_pointer_cast;
67static bool read_is_declaration_only(xmlNodePtr,
bool&);
68static bool read_is_artificial(xmlNodePtr,
bool&);
69static bool read_tracking_non_reachable_types(xmlNodePtr,
bool&);
70static bool read_is_non_reachable_type(xmlNodePtr,
bool&);
71static bool read_naming_typedef_id_string(xmlNodePtr,
string&);
72static bool read_type_id_string(xmlNodePtr,
string&);
73static bool read_name(xmlNodePtr,
string&);
74#ifdef WITH_DEBUG_SELF_COMPARISON
75static bool maybe_map_type_with_type_id(
const type_base_sptr&,
77static bool maybe_map_type_with_type_id(
const type_base_sptr&,
80#define MAYBE_MAP_TYPE_WITH_TYPE_ID(type, xml_node) \
81 maybe_map_type_with_type_id(type, xml_node)
83#define MAYBE_MAP_TYPE_WITH_TYPE_ID(type, xml_node)
85static void maybe_set_naming_typedef(reader& rdr,
87 const decl_base_sptr &);
90static int advance_cursor(reader& rdr);
96walk_xml_node_to_map_type_ids(reader& rdr, xmlNodePtr node);
99read_elf_needed_from_input(reader& rdr, vector<string>& needed);
102read_symbol_db_from_input(reader& rdr,
109read_translation_unit_from_input(
fe_iface& rdr);
112build_ir_node_for_void_type(reader& rdr);
115build_ir_node_for_void_pointer_type(reader& rdr);
118build_ir_node_for_variadic_parameter_type(reader& rdr);
126read_type_hash_and_cti(xmlNodePtr, uint64_t& hash, uint64_t& cti);
139 typedef unordered_map<string, vector<type_base_sptr> >
142 typedef unordered_map<string,
143 vector<type_base_sptr> >::const_iterator
146 typedef unordered_map<string,
147 vector<type_base_sptr> >::iterator
150 typedef unordered_map<string,
151 shared_ptr<function_tdecl> >::const_iterator
152 const_fn_tmpl_map_it;
154 typedef unordered_map<string,
155 shared_ptr<class_tdecl> >::const_iterator
156 const_class_tmpl_map_it;
158 typedef unordered_map<string, xmlNodePtr> string_xml_node_map;
160 typedef unordered_map<xmlNodePtr, decl_base_sptr> xml_node_decl_base_sptr_map;
162 friend vector<type_base_sptr>* get_types_from_type_id(reader&,
165 friend unordered_map<type_or_decl_base*, vector<type_or_decl_base*>>*
166 get_artifact_used_by_relation_map(reader& rdr);
169 types_map_type m_types_map;
170 unordered_map<string, shared_ptr<function_tdecl> > m_fn_tmpl_map;
171 unordered_map<string, shared_ptr<class_tdecl> > m_class_tmpl_map;
172 vector<type_base_sptr> m_types_to_canonicalize;
173 string_xml_node_map m_id_xml_node_map;
174 xml_node_decl_base_sptr_map m_xml_node_decl_map;
176 xmlNodePtr m_corp_node;
177 deque<shared_ptr<decl_base> > m_decls_stack;
178 bool m_tracking_non_reachable_types;
179 bool m_drop_undefined_syms;
180 bool m_drop_hash_value;
181#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
183 vector<type_or_decl_base*>> m_artifact_used_by_map;
194 m_tracking_non_reachable_types(),
195 m_drop_undefined_syms(),
213 clear_types_to_canonicalize();
229 tracking_non_reachable_types()
const
230 {
return m_tracking_non_reachable_types;}
238 tracking_non_reachable_types(
bool f)
239 {m_tracking_non_reachable_types = f;}
247 drop_undefined_syms()
const
248 {
return m_drop_undefined_syms;}
255 drop_undefined_syms(
bool f)
256 {m_drop_undefined_syms = f;}
269 set_path(
const string& s)
285 get_environment()
const
286 {
return const_cast<reader*
>(
this)->get_environment();}
289 get_libxml_reader()
const
298 get_corpus_node()
const
299 {
return m_corp_node;}
307 set_corpus_node(xmlNodePtr node)
308 {m_corp_node = node;}
310 const string_xml_node_map&
311 get_id_xml_node_map()
const
312 {
return m_id_xml_node_map;}
315 get_id_xml_node_map()
316 {
return m_id_xml_node_map;}
319 clear_id_xml_node_map()
320 {get_id_xml_node_map().clear();}
322 const xml_node_decl_base_sptr_map&
323 get_xml_node_decl_map()
const
324 {
return m_xml_node_decl_map;}
326 xml_node_decl_base_sptr_map&
327 get_xml_node_decl_map()
328 {
return m_xml_node_decl_map;}
331 map_xml_node_to_decl(xmlNodePtr node,
335 get_xml_node_decl_map()[node]= decl;
339 get_decl_for_xml_node(xmlNodePtr node)
const
341 xml_node_decl_base_sptr_map::const_iterator i =
342 get_xml_node_decl_map().find(node);
344 if (i != get_xml_node_decl_map().end())
347 return decl_base_sptr();
351 clear_xml_node_decl_map()
352 {get_xml_node_decl_map().clear();}
355 map_id_and_node (
const string&
id,
361 string_xml_node_map::iterator i = get_id_xml_node_map().find(
id);
362 if (i != get_id_xml_node_map().end())
364 bool is_declaration =
false;
365 read_is_declaration_only(node, is_declaration);
370 get_id_xml_node_map()[id] = node;
374 get_xml_node_from_id(
const string&
id)
const
376 string_xml_node_map::const_iterator i = get_id_xml_node_map().find(
id);
377 if (i != get_id_xml_node_map().end())
383 get_scope_for_node(xmlNodePtr node,
387 get_scope_for_node(xmlNodePtr node);
390 get_scope_ptr_for_node(xmlNodePtr node);
395 build_or_get_type_decl(
const string&
id,
410 get_type_decl(
const string&
id)
const
412 const_types_map_it i = m_types_map.find(
id);
413 if (i == m_types_map.end())
414 return type_base_sptr();
415 type_base_sptr result = i->second[0];
431 const vector<type_base_sptr>*
432 get_all_type_decls(
const string&
id)
const
434 const_types_map_it i = m_types_map.find(
id);
435 if (i == m_types_map.end())
452 shared_ptr<function_tdecl>
453 get_fn_tmpl_decl(
const string&
id)
const
455 const_fn_tmpl_map_it i = m_fn_tmpl_map.find(
id);
456 if (i == m_fn_tmpl_map.end())
457 return shared_ptr<function_tdecl>();
471 shared_ptr<class_tdecl>
472 get_class_tmpl_decl(
const string&
id)
const
474 const_class_tmpl_map_it i = m_class_tmpl_map.find(
id);
475 if (i == m_class_tmpl_map.end())
476 return shared_ptr<class_tdecl>();
482 get_cur_scope()
const
484 shared_ptr<decl_base> cur_decl = get_cur_decl();
486 if (
dynamic_cast<scope_decl*
>(cur_decl.get()))
488 return dynamic_pointer_cast<scope_decl>(cur_decl).get();
492 return cur_decl->get_scope();
501 if (m_decls_stack.empty())
502 return shared_ptr<decl_base>(
static_cast<decl_base*
>(0));
503 return m_decls_stack.back();
507 get_translation_unit()
509 const global_scope* global = 0;
510 for (deque<shared_ptr<decl_base> >::reverse_iterator i =
511 m_decls_stack.rbegin();
512 i != m_decls_stack.rend();
514 if (decl_base_sptr d = *i)
519 return global->get_translation_unit();
530 type_is_from_translation_unit(type_base_sptr type)
542 push_decl(decl_base_sptr d)
544 m_decls_stack.push_back(d);
550 if (m_decls_stack.empty())
551 return decl_base_sptr();
553 shared_ptr<decl_base> t = get_cur_decl();
554 m_decls_stack.pop_back();
581 return dynamic_pointer_cast<scope_decl>(d) == scope;
594 {m_decls_stack.clear();}
598 {m_types_map.clear();}
603 clear_types_to_canonicalize()
604 {m_types_to_canonicalize.clear();}
620 types_equal(type_base_sptr t1, type_base_sptr t2)
622 if (t1.get() == t2.get())
641 key_type_decl(
const type_base_sptr& type,
const string&
id)
646 m_types_map[id].push_back(type);
661 key_fn_tmpl_decl(shared_ptr<function_tdecl> fn_tmpl_decl,
666 const_fn_tmpl_map_it i = m_fn_tmpl_map.find(
id);
667 if (i != m_fn_tmpl_map.end())
670 m_fn_tmpl_map[id] = fn_tmpl_decl;
684 key_class_tmpl_decl(shared_ptr<class_tdecl> class_tmpl_decl,
689 const_class_tmpl_map_it i = m_class_tmpl_map.find(
id);
690 if (i != m_class_tmpl_map.end())
693 m_class_tmpl_map[id] = class_tmpl_decl;
697#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
707 record_artifact_as_used_by(type_or_decl_base* used,
708 type_or_decl_base* user)
710 if (m_artifact_used_by_map.find(used) == m_artifact_used_by_map.end())
712 vector<type_or_decl_base*> v;
713 m_artifact_used_by_map[used] = v;
715 m_artifact_used_by_map[used].push_back(user);
727 record_artifact_as_used_by(
const type_or_decl_base_sptr& used,
728 const type_or_decl_base_sptr& user)
729 {record_artifact_as_used_by(used.get(), user.get());}
735 record_artifacts_as_used_in_fn_decl(
const function_decl *fn)
740 type_base_sptr t = fn->get_return_type();
741 record_artifact_as_used_by(t.get(),
const_cast<function_decl*
>(fn));
743 for (
auto pit : fn->get_parameters())
745 type_base_sptr t = pit->get_type();
746 record_artifact_as_used_by(t.get(),
const_cast<function_decl*
>(fn));
755 {record_artifacts_as_used_in_fn_decl(fn.get());}
761 record_artifacts_as_used_in_fn_type(
const function_type *fn_type)
766 type_base_sptr t = fn_type->get_return_type();
767 record_artifact_as_used_by(t.get(),
const_cast<function_type*
>(fn_type));
769 for (
auto pit : fn_type->get_parameters())
771 type_base_sptr t = pit->get_type();
772 record_artifact_as_used_by(t.get(),
773 const_cast<function_type*
>(fn_type));
782 {record_artifacts_as_used_in_fn_type(fn_type.get());}
794 push_decl_to_scope(
const decl_base_sptr& decl, xmlNodePtr node)
796 scope_decl* scope =
nullptr;
797 scope = get_scope_ptr_for_node(node);
798 return push_decl_to_scope(decl, scope);
807 push_decl_to_scope(
const decl_base_sptr& decl,
814 if (!decl->get_translation_unit())
815 decl->set_translation_unit(get_translation_unit());
834 push_and_key_type_decl(
const type_base_sptr& t,
841 push_decl_to_scope(decl, scope);
842 if (!t->get_translation_unit())
843 t->set_translation_unit(get_translation_unit());
845 key_type_decl(t,
id);
860 push_and_key_type_decl(
const type_base_sptr& t,
861 const xmlNodePtr node,
862 bool add_to_current_scope)
865 if (!read_type_id_string(node,
id))
868 scope_decl* scope =
nullptr;
870 scope = get_scope_ptr_for_node(node);
871 return push_and_key_type_decl(t,
id, scope);
879 corpus::exported_decls_builder*
880 get_exported_decls_builder()
881 {
return corpus()->get_exported_decls_builder().get();}
894 corpus_is_suppressed_by_soname_or_filename(
const string& soname,
895 const string& filename)
901 for (suppressions_type::const_iterator s =
suppressions().begin();
915 clear_per_translation_unit_data()
919#ifdef WITH_DEBUG_SELF_COMPARISON
939 maybe_check_abixml_canonical_type_stability(type_base_sptr& t)
941 if (!get_environment().self_comparison_debug_is_on()
942 || get_environment().get_type_id_canonical_type_map().empty())
954 get_environment().get_type_id_from_pointer(
reinterpret_cast<uintptr_t
>(t.get()));
956 if (!type_id.empty())
961 auto j = get_environment().get_type_id_canonical_type_map().find(type_id);
962 if (j == get_environment().get_type_id_canonical_type_map().end())
964 if (t->get_naked_canonical_type())
965 std::cerr <<
"error: no type with type-id: '"
967 <<
"' could be read back from the typeid file\n";
970 !=
reinterpret_cast<uintptr_t
>(t->get_canonical_type().get()))
975 std::cerr <<
"error: canonical type for type '"
976 << t->get_pretty_representation(
true,
978 <<
"' of type-id '" << type_id
979 <<
"' changed from '" << std::hex
980 << j->second <<
"' to '" << std::hex
981 <<
reinterpret_cast<uintptr_t
>(t->get_canonical_type().get())
993 schedule_type_for_canonicalization(type_base_sptr t)
996 m_types_to_canonicalize.push_back(t);
1003 perform_type_canonicalization()
1005 tools_utils::timer cn_timer;
1008 std::cerr <<
"ABIXML Reader is going to canonicalize "
1009 << m_types_to_canonicalize.size()
1011 corpus_sptr c =
corpus();
1013 std::cerr <<
" of corpus " <<
corpus()->get_path() <<
"\n";
1019 m_types_to_canonicalize.end(),
1020 [](
const vector<type_base_sptr>::const_iterator& i)
1027 std::cerr <<
"ABIXML Reader: canonicalized all types in: " << cn_timer <<
"\n";
1044 const string& fn_name)
const
1048 return suppression_matches_function_name(*s, fn_name);
1059 suppression_can_match(
const suppr::suppression_base& s)
const
1061 corpus_sptr corp =
corpus();
1063 if (!s.priv_->matches_soname(corp->get_soname()))
1064 if (s.has_soname_related_property())
1070 if (!s.priv_->matches_binary_name(corp->get_path()))
1071 if (s.has_file_name_related_property())
1092 suppression_matches_function_name(
const suppr::function_suppression& s,
1093 const string& fn_name)
const
1095 if (!s.get_drops_artifact_from_ir()
1096 || !suppression_can_match(s))
1099 return suppr::suppression_matches_function_name(s, fn_name);
1114 suppression_matches_type_name_or_location(
const suppr::type_suppression& s,
1115 const string& type_name,
1116 const location& type_location)
const
1118 if (!suppression_can_match(s))
1125 virtual ir::corpus_sptr
1128 tools_utils::timer global_timer;
1129 global_timer.start();
1139 bool call_reader_next =
false;
1141 xmlNodePtr node = get_corpus_node();
1148 status = advance_cursor (*
this);
1151 BAD_CAST(
"abi-corpus")))
1154#ifdef WITH_DEBUG_SELF_COMPARISON
1155 if (get_environment().self_comparison_debug_is_on())
1156 get_environment().set_self_comparison_debug_input(
corpus());
1159 ir::corpus& corp = *
corpus();
1161 corp.set_origin(corpus::NATIVE_XML_ORIGIN);
1163 handle_version_attribute(xml_reader, corp);
1165 maybe_drop_hash_values();
1172 path =
reinterpret_cast<char*
>(path_str.get());
1174 corp.set_path(path);
1179 if (architecture_str)
1180 corp.set_architecture_name
1181 (
reinterpret_cast<char*
>(architecture_str.get()));
1189 soname =
reinterpret_cast<char*
>(soname_str.get());
1191 corp.set_soname(soname);
1201 if ((!soname.empty() || !path.empty())
1202 && corpus_is_suppressed_by_soname_or_filename(soname, path))
1205 node = xmlTextReaderExpand(xml_reader.get());
1209 call_reader_next =
true;
1213#ifdef WITH_DEBUG_SELF_COMPARISON
1214 if (get_environment().self_comparison_debug_is_on())
1215 get_environment().set_self_comparison_debug_input(
corpus());
1218 ir::corpus& corp = *
corpus();
1219 corp.set_origin(corpus::NATIVE_XML_ORIGIN);
1223 corp.set_path(
reinterpret_cast<char*
>(path_str.get()));
1227 if (architecture_str)
1228 corp.set_architecture_name
1229 (
reinterpret_cast<char*
>(architecture_str.get()));
1234 corp.set_soname(
reinterpret_cast<char*
>(soname_str.get()));
1242 xmlNodePtr n = xmlFirstElementChild(node);
1246 ir::corpus& corp = *
corpus();
1248 tools_utils::timer t;
1252 std::cerr <<
"ABIXML Reader: mapping XML nodes to type ID "
1253 <<
"for corpus " << corp.get_path()
1258 walk_xml_node_to_map_type_ids(*
this, node);
1263 std::cerr <<
"ABIXML Reader: mapped XML nodes to type ID "
1264 <<
"for corpus " << corp.get_path()
1271 vector<string> needed;
1272 read_elf_needed_from_input(*
this, needed);
1273 if (!needed.empty())
1274 corp.set_needed(needed);
1281 std::cerr <<
"ABIXML Reader: reading symbols information "
1282 <<
"for corpus " << corp.get_path()
1289 read_symbol_db_from_input(*
this, fn_sym_db, var_sym_db,
1290 non_resolved_fn_syms_aliases,
1291 non_resolved_var_syms_aliases);
1292 resolve_symbol_aliases(fn_sym_db, var_sym_db,
1293 non_resolved_fn_syms_aliases,
1294 non_resolved_var_syms_aliases);
1303 std::cerr <<
"ABIXML Reader: read symbols information "
1304 <<
"for corpus " << corp.get_path()
1314 std::cerr <<
"ABIXML Reader: building IR "
1315 <<
"for corpus " << corp.get_path()
1321 while (read_translation_unit_from_input(*
this))
1327 std::cerr <<
"ABIXML Reader: built IR "
1328 <<
"for corpus " << corp.get_path()
1329 <<
" in: " << t <<
"\n";
1332 if (tracking_non_reachable_types())
1334 bool is_tracking_non_reachable_types =
false;
1335 read_tracking_non_reachable_types(node, is_tracking_non_reachable_types);
1338 (corp.recording_types_reachable_from_public_interface_supported()
1339 == is_tracking_non_reachable_types);
1345 std::cerr <<
"ABIXML Reader: canonicalizing types "
1346 <<
"for corpus " << corp.get_path()
1351 perform_type_canonicalization();
1356 std::cerr <<
"ABIXML Reader: canonicalized types for corpus "
1358 <<
" in :" << t <<
"\n";
1363 if (call_reader_next)
1367 xmlTextReaderNext(xml_reader.get());
1375 node = get_corpus_node();
1376 node = xmlNextElementSibling(node);
1379 node = get_corpus_node();
1381 node = xmlNextElementSibling(node->parent);
1383 set_corpus_node(node);
1388 std::cerr <<
"ABIXML Reader: sorting functions and variables for corpus "
1394 corpus()->sort_functions();
1395 corpus()->sort_variables();
1400 std::cerr <<
"ABIXML Reader: sorted functions and variables for corpus "
1408 global_timer.stop();
1409 std::cerr <<
"ABIXML Reader: Analyzed corpus " <<
corpus()->get_path()
1410 <<
" in " << global_timer <<
"\n";
1411 std::cerr <<
"======================================================\n";
1426 maybe_drop_hash_values()
1428 string current_major, current_minor;
1431 if (current_major.empty() || current_minor.empty())
1434 ir::corpus& corp = *
corpus();
1435 bool drop_hash_values_from_abixml =
false;
1436 if (current_major > corp.get_format_major_version_number()
1437 || current_minor > corp.get_format_minor_version_number())
1438 drop_hash_values_from_abixml =
true;
1440 if (drop_hash_values_from_abixml)
1441 m_drop_hash_value =
true;
1451 read_hash_and_stash(
const xmlNodePtr node,
1452 const type_or_decl_base_sptr& ir_node)
1454 uint64_t
hash = 0, cti = 0;
1455 if (!m_drop_hash_value
1456 && read_type_hash_and_cti(node, hash, cti))
1458 ir_node->priv_->force_set_hash_value(hash);
1459 type_base_sptr type;
1461 type = fn->get_type();
1467 type->type_or_decl_base::priv_->force_set_hash_value(hash);
1468 type->priv_->canonical_type_index = cti;
1474typedef shared_ptr<reader> reader_sptr;
1476static int advance_cursor(reader&);
1477static bool read_translation_unit(fe_iface&, translation_unit&, xmlNodePtr);
1480static bool read_symbol_db_from_input(reader&,
1485static bool read_location(
const reader&, xmlNodePtr, location&);
1486static bool read_artificial_location(
const reader&,
1487 xmlNodePtr, location&);
1488static bool maybe_set_artificial_location(
const reader&,
1490 type_or_decl_base_sptr);
1494static bool read_size_and_alignment(xmlNodePtr,
size_t&,
size_t&);
1495static bool read_static(xmlNodePtr,
bool&);
1496static bool read_offset_in_bits(xmlNodePtr,
size_t&);
1497static bool read_cdtor_const(xmlNodePtr,
bool&,
bool&,
bool&);
1498static bool read_is_virtual(xmlNodePtr,
bool&);
1499static bool read_is_struct(xmlNodePtr,
bool&);
1500static bool read_is_anonymous(xmlNodePtr,
bool&);
1503static bool read_elf_symbol_visibility(xmlNodePtr,
1506build_namespace_decl(reader&,
const xmlNodePtr,
bool);
1516build_elf_symbol(reader&,
const xmlNodePtr,
bool);
1519build_elf_symbol_from_reference(reader&,
const xmlNodePtr);
1522build_elf_symbol_db(reader&,
const xmlNodePtr,
bool,
1527build_function_parameter (reader&,
const xmlNodePtr);
1530build_function_decl(reader&,
const xmlNodePtr,
1531 class_or_union_sptr,
bool,
bool);
1534build_function_decl_if_not_suppressed(reader&,
const xmlNodePtr,
1535 class_or_union_sptr,
bool,
bool);
1538function_is_suppressed(
const reader& rdr,
1542build_var_decl_if_not_suppressed(reader&,
const xmlNodePtr,
bool);
1545build_var_decl(reader&,
const xmlNodePtr,
bool);
1548variable_is_suppressed(
const reader& rdr,
1551static shared_ptr<type_decl>
1552build_type_decl(reader&,
const xmlNodePtr,
bool);
1554static qualified_type_def_sptr
1555build_qualified_type_decl(reader&,
const xmlNodePtr,
bool);
1557static shared_ptr<pointer_type_def>
1558build_pointer_type_def(reader&,
const xmlNodePtr,
bool);
1560static shared_ptr<reference_type_def>
1561build_reference_type_def(reader&,
const xmlNodePtr,
bool);
1564build_ptr_to_mbr_type(reader&,
const xmlNodePtr,
bool);
1566static shared_ptr<function_type>
1567build_function_type(reader&,
const xmlNodePtr,
bool);
1570build_subrange_type(reader&,
const xmlNodePtr,
bool);
1573build_array_type_def(reader&,
const xmlNodePtr,
bool);
1576build_enum_type_decl(reader&,
const xmlNodePtr,
bool);
1578static shared_ptr<typedef_decl>
1579build_typedef_decl(reader&,
const xmlNodePtr,
bool);
1582build_class_decl(reader&,
const xmlNodePtr,
bool);
1584static union_decl_sptr
1585build_union_decl(reader&,
const xmlNodePtr,
bool);
1587static shared_ptr<function_tdecl>
1588build_function_tdecl(reader&,
const xmlNodePtr,
bool);
1590static shared_ptr<class_tdecl>
1591build_class_tdecl(reader&,
const xmlNodePtr,
bool);
1594build_type_tparameter(reader&,
const xmlNodePtr,
1598build_type_composition(reader&,
const xmlNodePtr,
1602build_non_type_tparameter(reader&,
const xmlNodePtr,
1606build_template_tparameter(reader&,
const xmlNodePtr,
1610build_template_parameter(reader&,
const xmlNodePtr,
1617static shared_ptr<type_base>
1618build_type(reader&,
const xmlNodePtr,
bool);
1621static type_or_decl_base_sptr handle_element_node(reader&, xmlNodePtr,
bool);
1622static decl_base_sptr handle_type_decl(reader&, xmlNodePtr,
bool);
1623static decl_base_sptr handle_namespace_decl(reader&, xmlNodePtr,
bool);
1624static decl_base_sptr handle_qualified_type_decl(reader&,
1626static decl_base_sptr handle_pointer_type_def(reader&,
1628static decl_base_sptr handle_reference_type_def(reader&,
1630static type_base_sptr handle_function_type(reader&,
1632static decl_base_sptr handle_array_type_def(reader&,
1634static decl_base_sptr handle_enum_type_decl(reader&, xmlNodePtr,
bool);
1635static decl_base_sptr handle_typedef_decl(reader&, xmlNodePtr,
bool);
1636static decl_base_sptr handle_var_decl(reader&, xmlNodePtr,
bool);
1637static decl_base_sptr handle_function_decl(reader&, xmlNodePtr,
bool);
1638static decl_base_sptr handle_class_decl(reader&, xmlNodePtr,
bool);
1639static decl_base_sptr handle_union_decl(reader&, xmlNodePtr,
bool);
1640static decl_base_sptr handle_function_tdecl(reader&, xmlNodePtr,
bool);
1641static decl_base_sptr handle_class_tdecl(reader&, xmlNodePtr,
bool);
1643#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
1644#define RECORD_ARTIFACT_AS_USED_BY(rdr, used, user) \
1645 rdr.record_artifact_as_used_by(used,user)
1646#define RECORD_ARTIFACTS_AS_USED_IN_FN_DECL(rdr, fn) \
1647 rdr.record_artifacts_as_used_in_fn_decl(fn)
1648#define RECORD_ARTIFACTS_AS_USED_IN_FN_TYPE(rdr, fn_type)\
1649 rdr.record_artifacts_as_used_in_fn_type(fn_type)
1651#define RECORD_ARTIFACT_AS_USED_BY(rdr, used, user)
1652#define RECORD_ARTIFACTS_AS_USED_IN_FN_DECL(rdr, fn)
1653#define RECORD_ARTIFACTS_AS_USED_IN_FN_TYPE(rdr, fn_type)
1676 xmlNodePtr parent = node->parent;
1679 && (xmlStrEqual(parent->name, BAD_CAST(
"data-member"))
1680 || xmlStrEqual(parent->name, BAD_CAST(
"member-type"))
1681 || xmlStrEqual(parent->name, BAD_CAST(
"member-function"))
1682 || xmlStrEqual(parent->name, BAD_CAST(
"member-template"))
1683 || xmlStrEqual(parent->name, BAD_CAST(
"template-parameter-type-composition"))
1684 || xmlStrEqual(parent->name, BAD_CAST(
"array-type-def"))))
1686 read_access(parent, access);
1687 parent = parent->parent;
1690 xml_node_decl_base_sptr_map::const_iterator i =
1691 get_xml_node_decl_map().find(parent);
1692 if (i == get_xml_node_decl_map().end())
1694 if (xmlStrEqual(parent->name, BAD_CAST(
"abi-instr")))
1697 get_or_read_and_add_translation_unit(*
this, parent);
1698 return tu->get_global_scope();
1703 push_decl(parent_scope);
1704 scope = dynamic_pointer_cast<scope_decl>
1705 (handle_element_node(*
this, parent,
true));
1707 pop_scope_or_abort(parent_scope);
1710 scope = dynamic_pointer_cast<scope_decl>(i->second);
1725reader::get_scope_for_node(xmlNodePtr node)
1728 return get_scope_for_node(node, access);
1741reader::get_scope_ptr_for_node(xmlNodePtr node)
1761 type_base_sptr t = get_type_decl(
id);
1765 xmlNodePtr n = get_xml_node_from_id(
id);
1772 scope = get_scope_for_node(n, access);
1780 if ((t = get_type_decl(
id)))
1798 pop_scope_or_abort(scope);
1800 schedule_type_for_canonicalization(t);
1812advance_cursor(reader& rdr)
1815 return xmlTextReaderRead(reader.get());
1827walk_xml_node_to_map_type_ids(reader& rdr,
1830 xmlNodePtr n = node;
1832 if (!n || n->type != XML_ELEMENT_NODE)
1837 string id = CHAR_STR(s);
1838 rdr.map_id_and_node(
id, n);
1841 for (n = xmlFirstElementChild(n); n; n = xmlNextElementSibling(n))
1842 walk_xml_node_to_map_type_ids(rdr, n);
1846read_translation_unit(fe_iface& iface, translation_unit& tu, xmlNodePtr node)
1848 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
1850 if (!rdr.corpus()->is_empty())
1851 tu.set_corpus(rdr.corpus().get());
1857 char address_size = atoi(
reinterpret_cast<char*
>(addrsize_str.get()));
1858 tu.set_address_size(address_size);
1863 tu.set_path(
reinterpret_cast<char*
>(path_str.get()));
1867 if (comp_dir_path_str)
1868 tu.set_compilation_dir_path(
reinterpret_cast<char*
>
1869 (comp_dir_path_str.get()));
1874 (
reinterpret_cast<char*
>(language_str.get())));
1879 rdr.push_decl(tu.get_global_scope());
1880 rdr.map_xml_node_to_decl(node, tu.get_global_scope());
1882 if (rdr.get_id_xml_node_map().empty()
1884 walk_xml_node_to_map_type_ids(rdr, node);
1886 for (xmlNodePtr n = xmlFirstElementChild(node);
1888 n = xmlNextElementSibling(n))
1889 handle_element_node(rdr, n,
true);
1891 rdr.pop_scope_or_abort(tu.get_global_scope());
1897 rdr.clear_per_translation_unit_data();
1916get_or_read_and_add_translation_unit(reader& rdr, xmlNodePtr node)
1918 corpus_sptr corp = rdr.corpus();
1924 if (corp && !corp->is_empty())
1927 tu_path =
reinterpret_cast<char*
>(path_str.get());
1928 tu = corp->find_translation_unit(tu_path);
1933 tu.reset(
new translation_unit(rdr.get_environment(), tu_path));
1934 if (corp && !corp->is_empty())
1937 if (read_translation_unit(rdr, *tu, node))
1952read_translation_unit_from_input(fe_iface& iface)
1956 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
1958 xmlNodePtr node = rdr.get_corpus_node();
1969 status = advance_cursor (rdr);
1972 BAD_CAST(
"abi-instr")))
1975 node = xmlTextReaderExpand(reader.get());
1982 for (xmlNodePtr n = rdr.get_corpus_node();
1984 n = xmlNextElementSibling(n))
1986 if (!xmlStrEqual(n->name, BAD_CAST(
"abi-instr")))
1996 tu = get_or_read_and_add_translation_unit(rdr, node);
1998 if (rdr.get_corpus_node())
2004 node = xmlNextElementSibling(node);
2005 rdr.set_corpus_node(node);
2058read_symbol_db_from_input(reader& rdr,
2068 if (!rdr.get_corpus_node())
2074 status = advance_cursor (rdr);
2079 bool has_fn_syms =
false, has_undefined_fn_syms =
false,
2080 has_var_syms =
false, has_undefined_var_syms =
false;
2082 BAD_CAST(
"elf-function-symbols")))
2085 BAD_CAST(
"elf-variable-symbols")))
2086 has_var_syms =
true;
2088 BAD_CAST(
"undefined-elf-function-symbols")))
2089 has_undefined_fn_syms =
true;
2091 BAD_CAST(
"undefined-elf-variable-symbols")))
2092 has_undefined_var_syms =
true;
2096 xmlNodePtr node = xmlTextReaderExpand(reader.get());
2101 build_elf_symbol_db(rdr, node,
true, fn_symdb,
2102 non_resolved_fn_syms_aliases);
2103 else if (has_undefined_fn_syms)
2104 build_elf_symbol_db(rdr, node,
true, fn_symdb,
2105 non_resolved_fn_syms_aliases);
2106 else if (has_var_syms)
2107 build_elf_symbol_db(rdr, node,
false, var_symdb,
2108 non_resolved_var_syms_aliases);
2109 else if (has_undefined_var_syms)
2110 build_elf_symbol_db(rdr, node,
false, var_symdb,
2111 non_resolved_var_syms_aliases);
2113 xmlTextReaderNext(reader.get());
2116 for (xmlNodePtr n = rdr.get_corpus_node(); n; n = xmlNextElementSibling(n))
2118 bool has_fn_syms =
false, has_undefined_fn_syms =
false,
2119 has_var_syms =
false, has_undefined_var_syms =
false;
2120 if (xmlStrEqual(n->name, BAD_CAST(
"elf-function-symbols")))
2122 else if (xmlStrEqual(n->name, BAD_CAST(
"undefined-elf-function-symbols")))
2123 has_undefined_fn_syms =
true;
2124 else if (xmlStrEqual(n->name, BAD_CAST(
"elf-variable-symbols")))
2125 has_var_syms =
true;
2126 else if (xmlStrEqual(n->name,
2127 BAD_CAST(
"undefined-elf-variable-symbols")))
2128 has_undefined_var_syms =
true;
2131 rdr.set_corpus_node(n);
2136 build_elf_symbol_db(rdr, n,
true, fn_symdb,
2137 non_resolved_fn_syms_aliases);
2138 else if (has_undefined_fn_syms)
2139 build_elf_symbol_db(rdr, n,
true, fn_symdb,
2140 non_resolved_fn_syms_aliases);
2141 else if (has_var_syms)
2142 build_elf_symbol_db(rdr, n,
false, var_symdb,
2143 non_resolved_var_syms_aliases);
2144 else if (has_undefined_var_syms)
2145 build_elf_symbol_db(rdr, n,
false, var_symdb,
2146 non_resolved_var_syms_aliases);
2165build_needed(xmlNode* node, vector<string>& needed)
2167 if (!node || !xmlStrEqual(node->name,BAD_CAST(
"elf-needed")))
2170 for (xmlNodePtr n = xmlFirstElementChild(node);
2172 n = xmlNextElementSibling(n))
2174 if (!xmlStrEqual(n->name, BAD_CAST(
"dependency")))
2182 needed.push_back(name);
2198read_elf_needed_from_input(reader& rdr,
2199 vector<string>& needed)
2205 xmlNodePtr node = 0;
2207 if (rdr.get_corpus_node() == 0)
2212 status = advance_cursor (rdr);
2218 BAD_CAST(
"elf-needed")))
2221 node = xmlTextReaderExpand(reader.get());
2227 for (xmlNodePtr n = rdr.get_corpus_node();
2229 n = xmlNextElementSibling(n))
2231 if (!xmlStrEqual(n->name, BAD_CAST(
"elf-needed")))
2238 bool result =
false;
2241 result = build_needed(node, needed);
2242 node = xmlNextElementSibling(node);
2243 rdr.set_corpus_node(node);
2278 for (suppr::suppressions_type::const_iterator i = supprs.begin();
2281 if ((*i)->get_drops_artifact_from_ir())
2297 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
2298 rdr.tracking_non_reachable_types(flag);
2301#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
2310vector<type_base_sptr>*
2311get_types_from_type_id(
fe_iface& iface,
const string& type_id)
2313 xml_reader::reader& rdr =
dynamic_cast<xml_reader::reader&
>(iface);
2314 auto it = rdr.m_types_map.find(type_id);
2315 if (it == rdr.m_types_map.end())
2326unordered_map<type_or_decl_base*, vector<type_or_decl_base*>>*
2327get_artifact_used_by_relation_map(fe_iface& iface)
2329 xml_reader::reader& rdr =
dynamic_cast<xml_reader::reader&
>(iface);
2330 return &rdr.m_artifact_used_by_map;
2350 string version_string;
2355 if (version_string.empty())
2362 corp.set_format_major_version_number(v[0]);
2363 corp.set_format_minor_version_number(v[1]);
2376 corpus_group_sptr nil;
2378 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
2387 status = advance_cursor (rdr);
2390 BAD_CAST(
"abi-corpus-group")))
2397 corpus_group_sptr g(
new corpus_group(rdr.get_environment(),
2399 g->set_origin(corpus::NATIVE_XML_ORIGIN);
2405 handle_version_attribute(reader, *group);
2409 group->set_path(
reinterpret_cast<char*
>(path_str.get()));
2413 std::cerr <<
"ABIXML Reader: reading corpus group : '"
2414 << group->get_path()
2419 xmlNodePtr node = xmlTextReaderExpand(reader.get());
2423 node = xmlFirstElementChild(node);
2424 rdr.set_corpus_node(node);
2428 while ((corp = rdr.read_corpus(sts)))
2431 node = xmlNextElementSibling(node);
2432 if (!node || !xmlStrEqual(node->name, BAD_CAST(
"abi-corpus")))
2435 rdr.set_corpus_node(node);
2438 xmlTextReaderNext(reader.get());
2443 std::cerr <<
"ABIXML Reader: Read corpus group : "
2444 << group->get_path()
2445 <<
" in: " << t <<
"\n";
2510 rdr.perform_type_canonicalization();
2532 rdr.perform_type_canonicalization();
2547 abixml::reader& rdr =
dynamic_cast<abixml::reader&
>(iface);
2550 rdr.perform_type_canonicalization();
2564handle_element_node(reader& rdr, xmlNodePtr node,
2565 bool add_to_current_scope)
2571 ((decl = handle_namespace_decl(rdr, node, add_to_current_scope))
2572 ||(decl = handle_type_decl(rdr, node, add_to_current_scope))
2573 ||(decl = handle_qualified_type_decl(rdr, node,
2574 add_to_current_scope))
2575 ||(decl = handle_pointer_type_def(rdr, node,
2576 add_to_current_scope))
2577 || (decl = handle_reference_type_def(rdr, node, add_to_current_scope))
2578 || (decl = handle_function_type(rdr, node, add_to_current_scope))
2579 || (decl = handle_array_type_def(rdr, node, add_to_current_scope))
2580 || (decl = handle_enum_type_decl(rdr, node,
2581 add_to_current_scope))
2582 || (decl = handle_typedef_decl(rdr, node,
2583 add_to_current_scope))
2584 || (decl = handle_var_decl(rdr, node,
2585 add_to_current_scope))
2586 || (decl = handle_function_decl(rdr, node,
2587 add_to_current_scope))
2588 || (decl = handle_class_decl(rdr, node,
2589 add_to_current_scope))
2590 || (decl = handle_union_decl(rdr, node,
2591 add_to_current_scope))
2592 || (decl = handle_function_tdecl(rdr, node,
2593 add_to_current_scope))
2594 || (decl = handle_class_tdecl(rdr, node,
2595 add_to_current_scope)));
2600 if (rdr.tracking_non_reachable_types())
2602 if (type_base_sptr t =
is_type(decl))
2604 corpus_sptr abi = rdr.corpus();
2606 bool is_non_reachable_type =
false;
2607 read_is_non_reachable_type(node, is_non_reachable_type);
2608 if (!is_non_reachable_type)
2609 abi->record_type_as_reachable_from_public_interfaces(*t);
2624read_location(
const reader& rdr,
2629 size_t line = 0, column = 0;
2631 if (
xml_char_sptr f = xml::build_sptr(xmlGetProp(node, BAD_CAST(
"filepath"))))
2632 file_path = CHAR_STR(f);
2634 if (file_path.empty())
2635 return read_artificial_location(rdr, node, loc);
2637 if (
xml_char_sptr l = xml::build_sptr(xmlGetProp(node, BAD_CAST(
"line"))))
2638 line = atoi(CHAR_STR(l));
2640 return read_artificial_location(rdr, node, loc);
2642 if (
xml_char_sptr c = xml::build_sptr(xmlGetProp(node, BAD_CAST(
"column"))))
2643 column = atoi(CHAR_STR(c));
2645 reader& c =
const_cast<reader&
>(rdr);
2646 loc = c.get_translation_unit()->get_loc_mgr().create_new_location(file_path,
2663read_artificial_location(
const reader& rdr,
2671 size_t line = 0, column = 0;
2676 file_path =
reinterpret_cast<const char*
>(node->doc->URL);
2678 reader& c =
const_cast<reader&
>(rdr);
2680 c.get_translation_unit()->get_loc_mgr().create_new_location(file_path,
2682 loc.set_is_artificial(
true);
2702maybe_set_artificial_location(
const reader& rdr,
2704 type_or_decl_base_sptr artefact)
2706 if (artefact && !artefact->has_artificial_location())
2709 if (read_artificial_location(rdr, node, l))
2711 artefact->set_artificial_location(l);
2730 string v = CHAR_STR(s);
2733 vis = decl_base::VISIBILITY_DEFAULT;
2734 else if (v ==
"hidden")
2735 vis = decl_base::VISIBILITY_HIDDEN;
2736 else if (v ==
"internal")
2737 vis = decl_base::VISIBILITY_INTERNAL;
2738 else if (v ==
"protected")
2739 vis = decl_base::VISIBILITY_PROTECTED;
2741 vis = decl_base::VISIBILITY_DEFAULT;
2759 string b = CHAR_STR(s);
2762 bind = decl_base::BINDING_GLOBAL;
2763 else if (b ==
"local")
2764 bind = decl_base::BINDING_LOCAL;
2765 else if (b ==
"weak")
2766 bind = decl_base::BINDING_WEAK;
2768 bind = decl_base::BINDING_GLOBAL;
2787 string a = CHAR_STR(s);
2790 access = private_access;
2791 else if (a ==
"protected")
2792 access = protected_access;
2793 else if (a ==
"public")
2794 access = public_access;
2822read_size_and_alignment(xmlNodePtr node,
2823 size_t& size_in_bits,
2824 size_t& align_in_bits)
2827 bool got_something =
false;
2830 size_in_bits = atoll(CHAR_STR(s));
2831 got_something =
true;
2836 align_in_bits = atoll(CHAR_STR(s));
2837 got_something =
true;
2839 return got_something;
2852read_static(xmlNodePtr node,
bool& is_static)
2856 string b = CHAR_STR(s);
2857 is_static = b ==
"yes";
2870read_offset_in_bits(xmlNodePtr node,
2871 size_t& offset_in_bits)
2875 offset_in_bits = strtoull(CHAR_STR(s), 0, 0);
2903read_cdtor_const(xmlNodePtr node,
2904 bool& is_constructor,
2905 bool& is_destructor,
2910 string b = CHAR_STR(s);
2912 is_constructor =
true;
2914 is_constructor =
false;
2921 string b = CHAR_STR(s);
2923 is_destructor =
true;
2925 is_destructor =
false;
2932 string b = CHAR_STR(s);
2953read_is_declaration_only(xmlNodePtr node,
bool& is_decl_only)
2957 string str = CHAR_STR(s);
2959 is_decl_only =
true;
2961 is_decl_only =
false;
2977read_is_artificial(xmlNodePtr node,
bool& is_artificial)
2981 string is_artificial_str = CHAR_STR(s) ? CHAR_STR(s) :
"";
2982 is_artificial = is_artificial_str ==
"yes";
3001read_tracking_non_reachable_types(xmlNodePtr node,
3002 bool& tracking_non_reachable_types)
3007 string tracking_non_reachable_types_str = CHAR_STR(s) ? CHAR_STR(s) :
"";
3008 tracking_non_reachable_types =
3009 (tracking_non_reachable_types_str ==
"yes")
3028read_is_non_reachable_type(xmlNodePtr node,
bool& is_non_reachable_type)
3033 string is_non_reachable_type_str = CHAR_STR(s) ? CHAR_STR(s) :
"";
3034 is_non_reachable_type =
3035 (is_non_reachable_type_str ==
"yes")
3053read_naming_typedef_id_string(xmlNodePtr node,
string& naming_typedef_id)
3072read_is_virtual(xmlNodePtr node,
bool& is_virtual)
3076 string str = CHAR_STR(s);
3095read_is_struct(xmlNodePtr node,
bool& is_struct)
3099 string str = CHAR_STR(s);
3118read_is_anonymous(xmlNodePtr node,
bool& is_anonymous)
3122 string str = CHAR_STR(s);
3123 is_anonymous = (str ==
"yes");
3200read_type_id_string(xmlNodePtr node,
string& type_id)
3204 type_id = CHAR_STR(s);
3220read_name(xmlNodePtr node,
string& name)
3246read_type_hash_and_cti(xmlNodePtr node, uint64_t& hash, uint64_t& cti)
3250 string str = CHAR_STR(s);
3251 vector<string> parts;
3253 if (!parts.empty() && !parts.front().empty())
3256 if (parts.size() > 1)
3257 cti = atoll(parts[1].c_str());
3264#ifdef WITH_DEBUG_SELF_COMPARISON
3279maybe_map_type_with_type_id(
const type_base_sptr& t,
3280 const string& type_id)
3285 const environment& env = t->get_environment();
3286 if (!env.self_comparison_debug_is_on()
3290 const_cast<environment&
>(env).
3291 get_pointer_type_id_map()[
reinterpret_cast<uintptr_t
>(t.get())] = type_id;
3310maybe_map_type_with_type_id(
const type_base_sptr& t,
3316 const environment&env = t->get_environment();
3317 if (!env.self_comparison_debug_is_on()
3322 if (!read_type_id_string(node, type_id) || type_id.empty())
3325 return maybe_map_type_with_type_id(t, type_id);
3339maybe_set_naming_typedef(reader& rdr,
3341 const decl_base_sptr& decl)
3343 string naming_typedef_id;
3344 read_naming_typedef_id_string(node, naming_typedef_id);
3345 if (!naming_typedef_id.empty())
3348 is_typedef(rdr.build_or_get_type_decl(naming_typedef_id,
true));
3350 decl->set_naming_typedef(naming_typedef);
3370build_namespace_decl(reader& rdr,
3371 const xmlNodePtr node,
3372 bool add_to_current_scope)
3375 if (!node || !xmlStrEqual(node->name, BAD_CAST(
"namespace-decl")))
3378 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
3390 read_location(rdr, node, loc);
3392 const environment& env = rdr.get_environment();
3394 maybe_set_artificial_location(rdr, node, decl);
3395 rdr.push_decl_to_scope(decl,
3396 add_to_current_scope
3397 ? rdr.get_scope_ptr_for_node(node)
3399 rdr.map_xml_node_to_decl(node, decl);
3401 for (xmlNodePtr n = xmlFirstElementChild(node);
3403 n = xmlNextElementSibling(n))
3404 handle_element_node(rdr, n,
true);
3406 rdr.pop_scope_or_abort(decl);
3423build_elf_symbol(reader& rdr,
const xmlNodePtr node,
3424 bool drop_if_suppressed)
3429 || node->type != XML_ELEMENT_NODE
3430 || !xmlStrEqual(node->name, BAD_CAST(
"elf-symbol")))
3439 size = strtol(CHAR_STR(s), NULL, 0);
3441 bool is_defined =
true;
3446 if (value ==
"true" || value ==
"yes")
3452 bool is_common =
false;
3457 if (value ==
"true" || value ==
"yes")
3463 string version_string;
3467 bool is_default_version =
false;
3472 if (value ==
"true" || value ==
"yes")
3473 is_default_version =
true;
3477 read_elf_symbol_type(node, type);
3480 read_elf_symbol_binding(node, binding);
3483 read_elf_symbol_visibility(node, visibility);
3485 elf_symbol::version version(version_string, is_default_version);
3488 if (drop_if_suppressed && is_suppressed)
3491 const environment& env = rdr.get_environment();
3493 size, name, type, binding,
3494 is_defined, is_common,
3495 version, visibility);
3497 e->set_is_suppressed(is_suppressed);
3500 e->set_crc(strtoull(CHAR_STR(s), NULL, 0));
3506 e->set_namespace(ns);
3526build_elf_symbol_from_reference(reader& rdr,
const xmlNodePtr node)
3545 if (rdr.corpus()->get_symtab())
3548 rdr.corpus()->get_symtab()->lookup_symbol(name);
3550 for (
const auto& symbol : symbols)
3551 if (symbol->get_id_string() == sym_id)
3584build_elf_symbol_db(reader& rdr,
3585 const xmlNodePtr node,
3596 && !xmlStrEqual(node->name, BAD_CAST(
"elf-function-symbols"))
3597 && !xmlStrEqual(node->name, BAD_CAST(
"undefined-elf-function-symbols")))
3601 && !xmlStrEqual(node->name, BAD_CAST(
"elf-variable-symbols"))
3602 && !xmlStrEqual(node->name, BAD_CAST(
"undefined-elf-variable-symbols")))
3605 rdr.set_corpus_node(node);
3607 typedef std::unordered_map<xmlNodePtr, elf_symbol_sptr>
3608 xml_node_ptr_elf_symbol_sptr_map_type;
3609 xml_node_ptr_elf_symbol_sptr_map_type xml_node_ptr_elf_symbol_map;
3612 for (xmlNodePtr n = xmlFirstElementChild(node);
3614 n = xmlNextElementSibling(n))
3615 if ((sym = build_elf_symbol(rdr, n,
false)))
3617 id_sym_map[sym->get_id_string()] = sym;
3618 xml_node_ptr_elf_symbol_map[n] = sym;
3621 if (id_sym_map.empty())
3624 string_elf_symbols_map_type::iterator it;
3625 for (string_elf_symbol_sptr_map_type::const_iterator i = id_sym_map.begin();
3626 i != id_sym_map.end();
3628 (*map)[i->second->get_name()].push_back(i->second);
3631 for (xml_node_ptr_elf_symbol_sptr_map_type::const_iterator x =
3632 xml_node_ptr_elf_symbol_map.begin();
3633 x != xml_node_ptr_elf_symbol_map.end();
3638 string alias_id = CHAR_STR(s);
3641 std::vector<std::string> elems;
3642 std::stringstream aliases(alias_id);
3644 while (std::getline(aliases, item,
','))
3645 elems.push_back(item);
3646 for (std::vector<string>::iterator alias = elems.begin();
3647 alias != elems.end(); ++alias)
3649 string_elf_symbol_sptr_map_type::const_iterator i =
3650 id_sym_map.find(*alias);
3651 if (i == id_sym_map.end())
3657 non_resolved_aliases[x->second->get_name()].push_back(*alias);
3661 x->second->get_main_symbol()->add_alias(i->second);
3699 for (
auto& entry : non_resolved_fn_sym_aliases)
3701 auto i = fn_syms->find(entry.first);
3706 sym = sym->get_main_symbol();
3708 for (
string& alias : entry.second)
3710 auto fn_a = fn_syms->find(alias);
3711 if (fn_a == fn_syms->end())
3715 auto var_a = var_syms->find(alias);
3717 alias_sym = var_a->second.front();
3722 alias_sym = fn_a->second.front();
3725 sym->add_alias(alias_sym);
3729 for (
auto& entry : non_resolved_var_sym_aliases)
3731 auto i = var_syms->find(entry.first);
3736 sym = sym->get_main_symbol();
3738 for (
string& alias : entry.second)
3740 auto var_a = var_syms->find(alias);
3741 if (var_a == var_syms->end())
3745 auto fn_a = fn_syms->find(alias);
3747 alias_sym = fn_a->second.front();
3752 alias_sym = var_a->second.front();
3755 sym->add_alias(alias_sym);
3765static shared_ptr<function_decl::parameter>
3766build_function_parameter(reader& rdr,
const xmlNodePtr node)
3768 shared_ptr<function_decl::parameter> nil;
3770 if (!node || !xmlStrEqual(node->name, BAD_CAST(
"parameter")))
3773 bool is_variadic =
false;
3774 string is_variadic_str;
3776 xml::build_sptr(xmlGetProp(node, BAD_CAST(
"is-variadic"))))
3778 is_variadic_str = CHAR_STR(s) ? CHAR_STR(s) :
"";
3779 is_variadic = is_variadic_str ==
"yes";
3782 bool is_artificial =
false;
3783 read_is_artificial(node, is_artificial);
3786 if (
xml_char_sptr a = xml::build_sptr(xmlGetProp(node, BAD_CAST(
"type-id"))))
3787 type_id = CHAR_STR(a);
3789 type_base_sptr type;
3791 type =
is_type(build_ir_node_for_variadic_parameter_type(rdr));
3795 type = rdr.build_or_get_type_decl(type_id,
true);
3800 if (
xml_char_sptr a = xml::build_sptr(xmlGetProp(node, BAD_CAST(
"name"))))
3804 read_location(rdr, node, loc);
3807 (
new function_decl::parameter(type, name, loc,
3808 is_variadic, is_artificial));
3836build_function_decl(reader& rdr,
3837 const xmlNodePtr node,
3838 class_or_union_sptr as_method_decl,
3839 bool add_to_current_scope,
3840 bool add_to_exported_decls)
3844 if (!xmlStrEqual(node->name, BAD_CAST(
"function-decl")))
3851 string mangled_name;
3856 && !mangled_name.empty()
3857 && as_method_decl->find_member_function_sptr(mangled_name))
3860 as_method_decl->find_member_function_sptr(mangled_name);
3867 inline_prop = CHAR_STR(s);
3868 bool declared_inline = inline_prop ==
"yes";
3871 read_visibility(node, vis);
3874 read_binding(node, bind);
3876 size_t size = rdr.get_translation_unit()->get_address_size(), align = 0;
3877 read_size_and_alignment(node, size, align);
3880 read_location(rdr, node, loc);
3882 const environment& env = rdr.get_environment();
3884 std::vector<function_decl::parameter_sptr> parms;
3885 type_base_sptr return_type = env.get_void_type();
3887 for (xmlNodePtr n = xmlFirstElementChild(node);
3889 n = xmlNextElementSibling(n))
3891 if (xmlStrEqual(n->name, BAD_CAST(
"parameter")))
3894 build_function_parameter(rdr, n))
3897 else if (xmlStrEqual(n->name, BAD_CAST(
"return")))
3901 xml::build_sptr(xmlGetProp(n, BAD_CAST(
"type-id"))))
3902 type_id = CHAR_STR(s);
3903 if (!type_id.empty())
3904 return_type = rdr.build_or_get_type_decl(type_id,
true);
3909 ?
new method_type(return_type, as_method_decl,
3912 :
new function_type(return_type,
3913 parms, size, align));
3917 rdr.read_hash_and_stash(node, fn_type);
3919 fn_type->set_is_artificial(
true);
3922 ?
new method_decl (name, fn_type,
3923 declared_inline, loc,
3924 mangled_name, vis, bind)
3925 :
new function_decl(name, fn_type,
3926 declared_inline, loc,
3930 maybe_set_artificial_location(rdr, node, fn_decl);
3931 rdr.push_decl_to_scope(fn_decl,
3932 add_to_current_scope
3933 ? rdr.get_scope_ptr_for_node(node)
3935 RECORD_ARTIFACTS_AS_USED_IN_FN_DECL(rdr, fn_decl);
3939 fn_decl->set_symbol(sym);
3941 if (fn_decl->get_symbol() && fn_decl->get_symbol()->is_public())
3942 fn_decl->set_is_in_public_symbol_table(
true);
3944 rdr.get_translation_unit()->bind_function_type_life_time(fn_type);
3946 rdr.schedule_type_for_canonicalization(fn_type);
3948 if (add_to_exported_decls)
3949 rdr.add_fn_to_exported_or_undefined_decls(fn_decl.get());
3980build_function_decl_if_not_suppressed(reader& rdr,
3981 const xmlNodePtr node,
3982 class_or_union_sptr as_method_decl,
3983 bool add_to_current_scope,
3984 bool add_to_exported_decls)
3988 if (function_is_suppressed(rdr, node))
3994 fn = build_function_decl(rdr, node, as_method_decl,
3995 add_to_current_scope,
3996 add_to_exported_decls);
4012function_is_suppressed(
const reader& rdr, xmlNodePtr node)
4018 string flinkage_name;
4022 scope_decl* scope = rdr.get_cur_scope();
4041type_is_suppressed(
const reader& rdr, xmlNodePtr node)
4047 location type_location;
4048 read_location(rdr, node, type_location);
4050 scope_decl* scope = rdr.get_cur_scope();
4054 bool type_is_private =
false;
4073build_var_decl_if_not_suppressed(reader& rdr,
4074 const xmlNodePtr node,
4075 bool add_to_current_scope)
4078 if (!variable_is_suppressed(rdr, node))
4079 var = build_var_decl(rdr, node, add_to_current_scope);
4092variable_is_suppressed(
const reader& rdr, xmlNodePtr node)
4098 string linkage_name;
4102 scope_decl* scope = rdr.get_cur_scope();
4120variable_is_suppressed(
const reader& rdr,
4121 const scope_decl* scope,
4126 v.get_linkage_name());
4137static shared_ptr<var_decl>
4138build_var_decl(reader& rdr,
4139 const xmlNodePtr node,
4140 bool add_to_current_scope)
4142 shared_ptr<var_decl> nil;
4144 if (!xmlStrEqual(node->name, BAD_CAST(
"var-decl")))
4153 type_id = CHAR_STR(s);
4154 type_base_sptr underlying_type = rdr.build_or_get_type_decl(type_id,
4158 string mangled_name;
4163 read_visibility(node, vis);
4166 read_binding(node, bind);
4169 read_location(rdr, node, locus);
4172 locus, mangled_name,
4174 maybe_set_artificial_location(rdr, node, decl);
4178 decl->set_symbol(sym);
4180 rdr.push_decl_to_scope(decl,
4181 add_to_current_scope
4182 ? rdr.get_scope_ptr_for_node(node)
4184 if (add_to_current_scope)
4188 RECORD_ARTIFACT_AS_USED_BY(rdr, underlying_type, decl);
4191 if (decl->get_symbol() && decl->get_symbol()->is_public())
4192 decl->set_is_in_public_symbol_table(
true);
4202static decl_base_sptr
4203build_ir_node_for_void_type(reader& rdr)
4205 const environment& env = rdr.get_environment();
4207 type_base_sptr t = env.get_void_type();
4212 rdr.schedule_type_for_canonicalization(t);
4215 return type_declaration;
4229static decl_base_sptr
4230build_ir_node_for_void_pointer_type(reader& rdr)
4232 const environment& env = rdr.get_environment();
4234 type_base_sptr t = env.get_void_pointer_type();
4239 rdr.schedule_type_for_canonicalization(t);
4242 return type_declaration;
4250static decl_base_sptr
4251build_ir_node_for_variadic_parameter_type(reader& rdr)
4253 const environment& env = rdr.get_environment();
4255 type_base_sptr t = env.get_variadic_parameter_type();
4260 rdr.schedule_type_for_canonicalization(t);
4263 return type_declaration;
4278build_type_decl(reader& rdr,
4279 const xmlNodePtr node,
4280 bool add_to_current_scope)
4282 shared_ptr<type_decl> nil;
4284 if (!xmlStrEqual(node->name, BAD_CAST(
"type-decl")))
4287 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4303 size_t size_in_bits= 0;
4305 size_in_bits = atoi(CHAR_STR(s));
4307 size_t alignment_in_bits = 0;
4309 alignment_in_bits = atoi(CHAR_STR(s));
4311 bool is_decl_only =
false;
4312 read_is_declaration_only(node, is_decl_only);
4315 read_location(rdr, node, loc);
4317 bool is_anonymous =
false;
4318 read_is_anonymous(node, is_anonymous);
4320 if (type_base_sptr d = rdr.get_type_decl(
id))
4328 ABG_ASSERT(ty->get_size_in_bits() == size_in_bits);
4329 ABG_ASSERT(ty->get_alignment_in_bits() == alignment_in_bits);
4333 const environment& env = rdr.get_environment();
4335 if (name == env.get_variadic_parameter_type_name())
4336 decl =
is_type_decl(build_ir_node_for_variadic_parameter_type(rdr));
4337 else if (name ==
"void")
4340 decl.reset(
new type_decl(env, name, size_in_bits,
4341 alignment_in_bits, loc));
4342 maybe_set_artificial_location(rdr, node, decl);
4343 decl->set_is_anonymous(is_anonymous);
4344 decl->set_is_declaration_only(is_decl_only);
4346 rdr.read_hash_and_stash(node, decl);
4348 if (rdr.push_and_key_type_decl(decl, node, add_to_current_scope))
4350 rdr.map_xml_node_to_decl(node, decl);
4368static qualified_type_def_sptr
4369build_qualified_type_decl(reader& rdr,
4370 const xmlNodePtr node,
4371 bool add_to_current_scope)
4373 qualified_type_def_sptr nil;
4374 if (!xmlStrEqual(node->name, BAD_CAST(
"qualified-type-def")))
4377 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4379 qualified_type_def_sptr result =
4380 dynamic_pointer_cast<qualified_type_def>(d);
4392 read_location(rdr, node, loc);
4397 const_str = CHAR_STR(s);
4398 bool const_cv = const_str ==
"yes";
4400 string volatile_str;
4402 volatile_str = CHAR_STR(s);
4403 bool volatile_cv = volatile_str ==
"yes";
4405 string restrict_str;
4407 restrict_str = CHAR_STR(s);
4408 bool restrict_cv = restrict_str ==
"yes";
4411 cv = cv | qualified_type_def::CV_CONST;
4413 cv = cv | qualified_type_def::CV_VOLATILE;
4415 cv = cv | qualified_type_def::CV_RESTRICT;
4419 type_id = CHAR_STR(s);
4422 shared_ptr<type_base> underlying_type =
4423 rdr.build_or_get_type_decl(type_id,
true);
4426 if (type_base_sptr t = rdr.get_type_decl(
id))
4433 qualified_type_def_sptr decl;
4434 if (type_base_sptr t = rdr.get_type_decl(
id))
4441 decl.reset(
new qualified_type_def(underlying_type, cv, loc));
4442 maybe_set_artificial_location(rdr, node, decl);
4443 rdr.push_and_key_type_decl(decl, node, add_to_current_scope);
4444 RECORD_ARTIFACT_AS_USED_BY(rdr, underlying_type, decl);
4447 rdr.read_hash_and_stash(node, decl);
4449 rdr.map_xml_node_to_decl(node, decl);
4466build_pointer_type_def(reader& rdr,
4467 const xmlNodePtr node,
4468 bool add_to_current_scope)
4471 shared_ptr<pointer_type_def> nil;
4473 if (!xmlStrEqual(node->name, BAD_CAST(
"pointer-type-def")))
4476 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4479 dynamic_pointer_cast<pointer_type_def>(d);
4489 if (type_base_sptr t = rdr.get_type_decl(
id))
4498 type_id = CHAR_STR(s);
4500 size_t size_in_bits = rdr.get_translation_unit()->get_address_size();
4501 size_t alignment_in_bits = 0;
4502 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
4504 read_location(rdr, node, loc);
4506 type_base_sptr pointed_to_type =
4507 rdr.build_or_get_type_decl(type_id,
true);
4510 if (type_base_sptr t = rdr.get_type_decl(
id))
4518 if (rdr.get_environment().is_void_type(pointed_to_type))
4526 t.reset(
new pointer_type_def(pointed_to_type,
4531 maybe_set_artificial_location(rdr, node, t);
4533 rdr.push_and_key_type_decl(t, node, add_to_current_scope);
4534 rdr.map_xml_node_to_decl(node, t);
4537 rdr.read_hash_and_stash(node, t);
4539 RECORD_ARTIFACT_AS_USED_BY(rdr, pointed_to_type, t);
4555static shared_ptr<reference_type_def>
4556build_reference_type_def(reader& rdr,
4557 const xmlNodePtr node,
4558 bool add_to_current_scope)
4560 shared_ptr<reference_type_def> nil;
4562 if (!xmlStrEqual(node->name, BAD_CAST(
"reference-type-def")))
4565 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4568 dynamic_pointer_cast<reference_type_def>(d);
4578 if (type_base_sptr d = rdr.get_type_decl(
id))
4586 read_location(rdr, node, loc);
4590 bool is_lvalue = kind ==
"lvalue";
4592 size_t size_in_bits = rdr.get_translation_unit()->get_address_size();
4593 size_t alignment_in_bits = 0;
4594 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
4598 type_id = CHAR_STR(s);
4602 type_base_sptr pointed_to_type =
4603 rdr.build_or_get_type_decl(type_id,
true);
4608 if (type_base_sptr t = rdr.get_type_decl(
id))
4622 is_lvalue, size_in_bits,
4623 alignment_in_bits, loc));
4624 maybe_set_artificial_location(rdr, node, t);
4625 ABG_ASSERT(rdr.push_and_key_type_decl(t, node, add_to_current_scope));
4626 rdr.map_xml_node_to_decl(node, t);
4629 rdr.read_hash_and_stash(node, t);
4631 RECORD_ARTIFACT_AS_USED_BY(rdr, pointed_to_type, t);
4649build_ptr_to_mbr_type(reader& rdr,
4650 const xmlNodePtr node,
4651 bool add_to_current_scope)
4655 if (!xmlStrEqual(node->name, BAD_CAST(
"pointer-to-member-type")))
4658 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4672 if (type_base_sptr d = rdr.get_type_decl(
id))
4679 size_t size_in_bits = rdr.get_translation_unit()->get_address_size();
4680 size_t alignment_in_bits = 0;
4681 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
4684 read_location(rdr, node, loc);
4686 string member_type_id;
4688 member_type_id = CHAR_STR(s);
4689 if (member_type_id.empty())
4691 type_base_sptr member_type =
4692 is_type(rdr.build_or_get_type_decl(member_type_id,
true));
4696 if (type_base_sptr t = rdr.get_type_decl(
id))
4703 string containing_type_id;
4705 containing_type_id = CHAR_STR(s);
4706 if (containing_type_id.empty())
4708 type_base_sptr containing_type =
4709 rdr.build_or_get_type_decl(containing_type_id,
true);
4713 if (type_base_sptr t = rdr.get_type_decl(
id))
4720 result.reset(
new ptr_to_mbr_type(rdr.get_environment(),
4721 member_type, containing_type,
4722 size_in_bits, alignment_in_bits,
4726 rdr.read_hash_and_stash(node, result);
4728 if (rdr.push_and_key_type_decl(result, node, add_to_current_scope))
4729 rdr.map_xml_node_to_decl(node, result);
4747build_function_type(reader& rdr,
4748 const xmlNodePtr node,
4753 if (!xmlStrEqual(node->name, BAD_CAST(
"function-type")))
4761 string method_class_id;
4763 method_class_id = CHAR_STR(s);
4765 bool is_method_t = !method_class_id.empty();
4767 size_t size = rdr.get_translation_unit()->get_address_size(), align = 0;
4768 read_size_and_alignment(node, size, align);
4770 const environment& env = rdr.get_environment();
4771 std::vector<shared_ptr<function_decl::parameter> > parms;
4772 type_base_sptr return_type = env.get_void_type();
4774 class_or_union_sptr method_class_type;
4784 ?
new method_type(method_class_type,
4787 :
new function_type(return_type,
4788 parms, size, align));
4791 rdr.read_hash_and_stash(node, fn_type);
4793 rdr.get_translation_unit()->bind_function_type_life_time(fn_type);
4794 rdr.key_type_decl(fn_type,
id);
4795 RECORD_ARTIFACTS_AS_USED_IN_FN_TYPE(rdr, fn_type);
4797 for (xmlNodePtr n = xmlFirstElementChild(node);
4799 n = xmlNextElementSibling(n))
4801 if (xmlStrEqual(n->name, BAD_CAST(
"parameter")))
4804 build_function_parameter(rdr, n))
4807 else if (xmlStrEqual(n->name, BAD_CAST(
"return")))
4811 xml::build_sptr(xmlGetProp(n, BAD_CAST(
"type-id"))))
4812 type_id = CHAR_STR(s);
4813 type_base_sptr ret_type;
4814 if (!type_id.empty())
4815 ret_type = rdr.build_or_get_type_decl (type_id,
true);
4817 ret_type = return_type;
4818 fn_type->set_return_type(ret_type);
4821 if (!fn_type->get_return_type())
4822 fn_type->set_return_type(return_type);
4824 fn_type->set_parameters(parms);
4840build_subrange_type(reader& rdr,
4841 const xmlNodePtr node,
4842 bool add_to_current_scope)
4846 if (!node || !xmlStrEqual(node->name, BAD_CAST(
"subrange")))
4849 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
4852 dynamic_pointer_cast<array_type_def::subrange_type>(d);
4866 if (type_base_sptr d = rdr.get_type_decl(
id))
4877 uint64_t length = 0;
4879 bool is_non_finite =
false;
4882 if (
string(CHAR_STR(s)) ==
"infinite" ||
string(CHAR_STR(s)) ==
"unknown")
4883 is_non_finite =
true;
4885 length = strtoull(CHAR_STR(s), NULL, 0);
4888 uint64_t size_in_bits = 0;
4891 char *endptr =
nullptr;
4892 size_in_bits = strtoull(CHAR_STR(s), &endptr, 0);
4893 if (*endptr !=
'\0')
4895 if (!strcmp(CHAR_STR(s),
"infinite")
4896 ||!strcmp(CHAR_STR(s),
"unknown"))
4897 size_in_bits = (size_t) -1;
4903 int64_t lower_bound = 0, upper_bound = 0;
4904 bool bounds_present =
false;
4907 lower_bound = strtoll(CHAR_STR(s), NULL, 0);
4909 if (!
string(CHAR_STR(s)).empty())
4910 upper_bound = strtoll(CHAR_STR(s), NULL, 0);
4911 bounds_present =
true;
4913 || (length == (uint64_t) upper_bound - lower_bound + 1));
4916 string underlying_type_id;
4918 underlying_type_id = CHAR_STR(s);
4920 type_base_sptr underlying_type;
4921 if (!underlying_type_id.empty())
4923 underlying_type = rdr.build_or_get_type_decl(underlying_type_id,
true);
4927 if (type_base_sptr t = rdr.get_type_decl(
id))
4935 read_location(rdr, node, loc);
4940 array_type_def::subrange_type::bound_value max_bound;
4941 array_type_def::subrange_type::bound_value min_bound;
4947 max_bound.set_signed(length - 1);
4953 min_bound.set_signed(lower_bound);
4954 max_bound.set_signed(upper_bound);
4958 (
new array_type_def::subrange_type(rdr.get_environment(),
4959 name, min_bound, max_bound,
4960 underlying_type, loc));
4961 maybe_set_artificial_location(rdr, node, p);
4962 p->is_non_finite(is_non_finite);
4964 p->set_size_in_bits(size_in_bits);
4967 rdr.read_hash_and_stash(node, p);
4969 if (rdr.push_and_key_type_decl(p, node, add_to_current_scope))
4970 rdr.map_xml_node_to_decl(node, p);
4987build_array_type_def(reader& rdr,
4988 const xmlNodePtr node,
4989 bool add_to_current_scope)
4994 if (!xmlStrEqual(node->name, BAD_CAST(
"array-type-def")))
4997 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
5000 dynamic_pointer_cast<array_type_def>(d);
5010 if (type_base_sptr d = rdr.get_type_decl(
id))
5019 dimensions = atoi(CHAR_STR(s));
5023 type_id = CHAR_STR(s);
5025 size_t size_in_bits = 0, alignment_in_bits = 0;
5026 bool has_size_in_bits =
false;
5031 size_in_bits = strtoull(CHAR_STR(s), &endptr, 0);
5032 if (*endptr !=
'\0')
5034 if (!strcmp(CHAR_STR(s),
"infinite")
5035 ||!strcmp(CHAR_STR(s),
"unknown"))
5036 size_in_bits = (size_t) -1;
5040 has_size_in_bits =
true;
5045 alignment_in_bits = strtoull(CHAR_STR(s), &endptr, 0);
5046 if (*endptr !=
'\0')
5051 read_location(rdr, node, loc);
5054 for (xmlNodePtr n = xmlFirstElementChild(node);
5056 n = xmlNextElementSibling(n))
5057 if (xmlStrEqual(n->name, BAD_CAST(
"subrange")))
5060 build_subrange_type(rdr, n,
true))
5062 MAYBE_MAP_TYPE_WITH_TYPE_ID(s, n);
5063 if (add_to_current_scope)
5066 rdr.schedule_type_for_canonicalization(s);
5068 subranges.push_back(s);
5073 type_base_sptr type =
5074 rdr.build_or_get_type_decl(type_id,
true);
5079 if (type_base_sptr t = rdr.get_type_decl(
id))
5088 rdr.read_hash_and_stash(node, ar_type);
5090 maybe_set_artificial_location(rdr, node, ar_type);
5091 if (rdr.push_and_key_type_decl(ar_type, node, add_to_current_scope))
5092 rdr.map_xml_node_to_decl(node, ar_type);
5093 RECORD_ARTIFACT_AS_USED_BY(rdr, type, ar_type);
5095 if (dimensions != ar_type->get_dimension_count()
5096 || (alignment_in_bits
5097 != ar_type->get_element_type()->get_alignment_in_bits()))
5100 if (has_size_in_bits && size_in_bits != (
size_t) -1
5101 && size_in_bits != ar_type->get_size_in_bits())
5104 size_t element_size = ar_type->get_element_type()->get_size_in_bits();
5105 if (element_size && element_size != (
size_t)-1)
5108 size_t bad_count = 0;
5109 for (vector<array_type_def::subrange_sptr>::const_iterator i =
5111 i != subranges.end();
5113 bad_count += (*i)->get_length();
5114 if (size_in_bits == bad_count * element_size)
5116 static bool reported =
false;
5119 std::cerr <<
"notice: Found incorrectly calculated array "
5120 <<
"sizes in XML - this is benign.\nOlder versions "
5121 <<
"of libabigail miscalculated multidimensional "
5122 <<
"array sizes." << std::endl;
5128 std::cerr <<
"error: Found incorrectly calculated array size in "
5129 <<
"XML (id=\"" <<
id <<
"\")." << std::endl;
5153build_enum_type_decl_if_not_suppressed(reader& rdr,
5154 const xmlNodePtr node,
5155 bool add_to_current_scope)
5158 if (!type_is_suppressed(rdr, node))
5159 enum_type = build_enum_type_decl(rdr, node, add_to_current_scope);
5175build_enum_type_decl(reader& rdr,
5176 const xmlNodePtr node,
5177 bool add_to_current_scope)
5181 if (!xmlStrEqual(node->name, BAD_CAST(
"enum-decl")))
5184 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
5187 dynamic_pointer_cast<enum_type_decl>(d);
5196 string linkage_name;
5201 read_location(rdr, node, loc);
5203 bool is_decl_only =
false;
5204 read_is_declaration_only(node, is_decl_only);
5206 bool is_anonymous =
false;
5207 read_is_anonymous(node, is_anonymous);
5209 bool is_artificial =
false;
5210 read_is_artificial(node, is_artificial);
5218 if (type_base_sptr t = rdr.get_type_decl(
id))
5225 string base_type_id;
5227 for (xmlNodePtr n = xmlFirstElementChild(node);
5229 n = xmlNextElementSibling(n))
5231 if (xmlStrEqual(n->name, BAD_CAST(
"underlying-type")))
5233 xml_char_sptr a = xml::build_sptr(xmlGetProp(n, BAD_CAST(
"type-id")));
5235 base_type_id = CHAR_STR(a);
5238 else if (xmlStrEqual(n->name, BAD_CAST(
"enumerator")))
5243 xml_char_sptr a = xml::build_sptr(xmlGetProp(n, BAD_CAST(
"name")));
5247 a = xml::build_sptr(xmlGetProp(n, BAD_CAST(
"value")));
5250 value = strtoll(CHAR_STR(a), NULL, 0);
5254 if ((errno == ERANGE)
5255 && (value == LLONG_MIN || value == LLONG_MAX))
5259 enums.push_back(enum_type_decl::enumerator(name, value));
5263 type_base_sptr underlying_type =
5264 rdr.build_or_get_type_decl(base_type_id,
true);
5267 if (type_base_sptr t = rdr.get_type_decl(
id))
5276 enums, linkage_name));
5277 maybe_set_artificial_location(rdr, node, t);
5278 t->set_is_anonymous(is_anonymous);
5279 t->set_is_artificial(is_artificial);
5280 t->set_is_declaration_only(is_decl_only);
5282 rdr.read_hash_and_stash(node, t);
5284 if (rdr.push_and_key_type_decl(t, node, add_to_current_scope))
5286 maybe_set_naming_typedef(rdr, node, t);
5287 rdr.map_xml_node_to_decl(node, t);
5288 RECORD_ARTIFACT_AS_USED_BY(rdr, underlying_type, t);
5303static shared_ptr<typedef_decl>
5304build_typedef_decl(reader& rdr,
5305 const xmlNodePtr node,
5306 bool add_to_current_scope)
5308 shared_ptr<typedef_decl> nil;
5310 if (!xmlStrEqual(node->name, BAD_CAST(
"typedef-decl")))
5313 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
5325 if (type_base_sptr t = rdr.get_type_decl(
id))
5337 read_location(rdr, node, loc);
5341 type_id = CHAR_STR(s);
5344 type_base_sptr underlying_type(rdr.build_or_get_type_decl(type_id,
true));
5349 if (type_base_sptr t = rdr.get_type_decl(
id))
5357 maybe_set_artificial_location(rdr, node, t);
5360 rdr.read_hash_and_stash(node, t);
5362 rdr.push_and_key_type_decl(t, node, add_to_current_scope);
5363 rdr.map_xml_node_to_decl(node, t);
5364 RECORD_ARTIFACT_AS_USED_BY(rdr, underlying_type, t);
5381build_class_decl_if_not_suppressed(reader& rdr,
5382 const xmlNodePtr node,
5383 bool add_to_current_scope)
5386 if (!type_is_suppressed(rdr, node))
5387 class_type = build_class_decl(rdr, node, add_to_current_scope);
5403static union_decl_sptr
5404build_union_decl_if_not_suppressed(reader& rdr,
5405 const xmlNodePtr node,
5406 bool add_to_current_scope)
5408 union_decl_sptr union_type;
5409 if (!type_is_suppressed(rdr, node))
5410 union_type = build_union_decl(rdr, node, add_to_current_scope);
5427build_class_decl(reader& rdr,
5428 const xmlNodePtr node,
5429 bool add_to_current_scope)
5433 if (!xmlStrEqual(node->name, BAD_CAST(
"class-decl")))
5436 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
5447 size_t size_in_bits = 0, alignment_in_bits = 0;
5448 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
5451 read_visibility(node, vis);
5453 bool is_artificial =
false;
5454 read_is_artificial(node, is_artificial);
5461 read_location(rdr, node, loc);
5463 class_decl::member_types mbrs;
5464 class_decl::data_members data_mbrs;
5465 class_decl::member_functions mbr_functions;
5470 bool is_decl_only =
false;
5471 read_is_declaration_only(node, is_decl_only);
5473 bool is_struct =
false;
5474 read_is_struct(node, is_struct);
5476 bool is_anonymous =
false;
5477 read_is_anonymous(node, is_anonymous);
5483 if (type_base_sptr t = rdr.get_type_decl(
id))
5489 const vector<type_base_sptr> *types_ptr = 0;
5490 if (!is_anonymous && !previous_definition)
5491 types_ptr = rdr.get_all_type_decls(
id);
5497 for (vector<type_base_sptr>::const_iterator i = types_ptr->begin();
5498 i != types_ptr->end();
5503 if (klass->get_is_declaration_only()
5504 && !klass->get_definition_of_declaration())
5505 previous_declaration = klass;
5506 else if (!klass->get_is_declaration_only()
5507 && !previous_definition)
5508 previous_definition = klass;
5509 if (previous_definition && previous_declaration)
5513 if (previous_declaration)
5514 ABG_ASSERT(previous_declaration->get_name() == name);
5516 if (previous_definition)
5517 ABG_ASSERT(previous_definition->get_name() == name);
5519 if (is_decl_only && previous_declaration)
5520 return previous_declaration;
5523 const environment& env = rdr.get_environment();
5525 if (!is_decl_only && previous_definition)
5531 decl = previous_definition;
5536 decl.reset(
new class_decl(env, name, is_struct));
5538 decl->set_size_in_bits(size_in_bits);
5540 decl->set_is_anonymous(is_anonymous);
5541 decl->set_location(loc);
5544 decl.reset(
new class_decl(env, name, size_in_bits, alignment_in_bits,
5545 is_struct, loc, vis, bases, mbrs,
5546 data_mbrs, mbr_functions, is_anonymous));
5549 maybe_set_artificial_location(rdr, node, decl);
5550 decl->set_is_artificial(is_artificial);
5553 rdr.read_hash_and_stash(node, decl);
5556 bool is_def_of_decl =
false;
5558 def_id = CHAR_STR(s);
5560 if (!def_id.empty())
5562 decl_base_sptr d =
is_decl(rdr.get_type_decl(def_id));
5563 if (d && d->get_is_declaration_only())
5565 is_def_of_decl =
true;
5566 decl->set_earlier_declaration(d);
5567 d->set_definition_of_declaration(decl);
5573 && !decl->get_is_declaration_only()
5574 && previous_declaration)
5580 decl->set_earlier_declaration(
is_decl(previous_declaration));
5581 for (vector<type_base_sptr>::const_iterator i = types_ptr->begin();
5582 i != types_ptr->end();
5587 if (d->get_is_declaration_only()
5588 && !d->get_definition_of_declaration())
5590 previous_declaration->set_definition_of_declaration(decl);
5591 is_def_of_decl =
true;
5596 if (is_decl_only && previous_definition)
5601 && !decl->get_definition_of_declaration());
5602 decl->set_definition_of_declaration(previous_definition);
5605 ABG_ASSERT(!is_decl_only || !is_def_of_decl);
5607 rdr.push_decl_to_scope(decl,
5608 add_to_current_scope
5609 ? rdr.get_scope_ptr_for_node(node)
5612 rdr.map_xml_node_to_decl(node, decl);
5613 rdr.key_type_decl(decl,
id);
5616 maybe_set_naming_typedef(rdr, node, decl);
5618 for (xmlNodePtr n = xmlFirstElementChild(node);
5620 n = xmlNextElementSibling(n))
5622 if (xmlStrEqual(n->name, BAD_CAST(
"base-class")))
5628 read_access(n, access);
5632 type_id = CHAR_STR(s);
5633 shared_ptr<class_decl> b =
5634 dynamic_pointer_cast<class_decl>
5635 (rdr.build_or_get_type_decl(type_id,
true));
5638 if (decl->find_base_class(b->get_qualified_name()))
5644 size_t offset_in_bits = 0;
5645 bool offset_present = read_offset_in_bits (n, offset_in_bits);
5647 bool is_virtual =
false;
5648 read_is_virtual (n, is_virtual);
5650 shared_ptr<class_decl::base_spec> base (
new class_decl::base_spec
5653 ? (
long) offset_in_bits
5656 decl->add_base_specifier(base);
5658 else if (xmlStrEqual(n->name, BAD_CAST(
"member-type")))
5664 read_access(n, access);
5666 rdr.map_xml_node_to_decl(n, decl);
5668 for (xmlNodePtr p = xmlFirstElementChild(n);
5670 p = xmlNextElementSibling(p))
5673 string member_type_name;
5674 read_name(p, member_type_name);
5676 if (!member_type_name.empty())
5677 t = decl->find_member_type(member_type_name);
5681 if ((t = build_type(rdr, p,
true)))
5685 if (!td->get_scope())
5686 decl->add_member_type(t);
5688 rdr.schedule_type_for_canonicalization(t);
5690 string id = CHAR_STR(i);
5692 rdr.key_type_decl(t,
id);
5693 rdr.map_xml_node_to_decl(p, td);
5697 else if (xmlStrEqual(n->name, BAD_CAST(
"data-member")))
5699 rdr.map_xml_node_to_decl(n, decl);
5705 read_access(n, access);
5707 bool is_laid_out =
false;
5708 size_t offset_in_bits = 0;
5709 if (read_offset_in_bits(n, offset_in_bits))
5712 bool is_static =
false;
5713 read_static(n, is_static);
5715 for (xmlNodePtr p = xmlFirstElementChild(n);
5717 p = xmlNextElementSibling(p))
5720 build_var_decl(rdr, p,
false))
5722 if (decl->find_data_member(v))
5730 decl_base_sptr d = rdr.pop_decl();
5735 if (!variable_is_suppressed(rdr, decl.get(), *v))
5737 decl->add_data_member(v, access,
5742 rdr.add_var_to_exported_or_undefined_decls(v);
5752 RECORD_ARTIFACT_AS_USED_BY(rdr, v->get_type(), decl);
5755 RECORD_ARTIFACT_AS_USED_BY(rdr, v->get_type(), v);
5756 RECORD_ARTIFACT_AS_USED_BY(rdr, v, decl);
5762 else if (xmlStrEqual(n->name, BAD_CAST(
"member-function")))
5768 read_access(n, access);
5770 bool is_virtual =
false;
5771 ssize_t vtable_offset = -1;
5776 vtable_offset = atoi(CHAR_STR(s));
5779 bool is_static =
false;
5780 read_static(n, is_static);
5782 bool is_ctor =
false, is_dtor =
false, is_const =
false;
5783 read_cdtor_const(n, is_ctor, is_dtor, is_const);
5785 for (xmlNodePtr p = xmlFirstElementChild(n);
5787 p = xmlNextElementSibling(p))
5790 build_function_decl_if_not_suppressed(rdr, p, decl,
5803 rdr.map_xml_node_to_decl(p, m);
5804 rdr.add_fn_to_exported_or_undefined_decls(f.get());
5809 else if (xmlStrEqual(n->name, BAD_CAST(
"member-template")))
5811 rdr.map_xml_node_to_decl(n, decl);
5817 read_access(n, access);
5819 bool is_static =
false;
5820 read_static(n, is_static);
5822 bool is_ctor =
false, is_dtor =
false, is_const =
false;
5823 read_cdtor_const(n, is_ctor, is_dtor, is_const);
5825 for (xmlNodePtr p = xmlFirstElementChild(n);
5827 p = xmlNextElementSibling(p))
5829 if (shared_ptr<function_tdecl> f =
5830 build_function_tdecl(rdr, p,
5833 shared_ptr<member_function_template> m
5834 (
new member_function_template(f, access, is_static,
5835 is_ctor, is_const));
5837 decl->add_member_function_template(m);
5839 else if (shared_ptr<class_tdecl> c =
5840 build_class_tdecl(rdr, p,
5843 member_class_template_sptr m(
new member_class_template(c,
5847 decl->add_member_class_template(m);
5853 rdr.pop_scope_or_abort(decl);
5870static union_decl_sptr
5871build_union_decl(reader& rdr,
5872 const xmlNodePtr node,
5873 bool add_to_current_scope)
5875 union_decl_sptr nil;
5877 if (!xmlStrEqual(node->name, BAD_CAST(
"union-decl")))
5880 if (decl_base_sptr d = rdr.get_decl_for_xml_node(node))
5882 union_decl_sptr result = dynamic_pointer_cast<union_decl>(d);
5891 size_t size_in_bits = 0, alignment_in_bits = 0;
5892 read_size_and_alignment(node, size_in_bits, alignment_in_bits);
5895 read_visibility(node, vis);
5897 bool is_artificial =
false;
5898 read_is_artificial(node, is_artificial);
5905 read_location(rdr, node, loc);
5907 union_decl::member_types mbrs;
5908 union_decl::data_members data_mbrs;
5909 union_decl::member_functions mbr_functions;
5911 union_decl_sptr decl;
5913 bool is_decl_only =
false;
5914 read_is_declaration_only(node, is_decl_only);
5916 bool is_anonymous =
false;
5917 read_is_anonymous(node, is_anonymous);
5920 union_decl_sptr previous_definition, previous_declaration;
5921 const vector<type_base_sptr> *types_ptr = 0;
5923 types_ptr = rdr.get_all_type_decls(
id);
5929 for (vector<type_base_sptr>::const_iterator i = types_ptr->begin();
5930 i != types_ptr->end();
5935 if (onion->get_is_declaration_only()
5936 && !onion->get_definition_of_declaration())
5937 previous_declaration = onion;
5938 else if (!onion->get_is_declaration_only()
5939 && !previous_definition)
5940 previous_definition = onion;
5941 if (previous_definition && previous_declaration)
5945 if (previous_declaration)
5946 ABG_ASSERT(previous_declaration->get_name() == name);
5948 if (previous_definition)
5949 ABG_ASSERT(previous_definition->get_name() == name);
5951 if (is_decl_only && previous_declaration)
5952 return previous_declaration;
5955 const environment& env = rdr.get_environment();
5957 if (!is_decl_only && previous_definition)
5963 decl = previous_definition;
5967 decl.reset(
new union_decl(env, name));
5969 decl.reset(
new union_decl(env, name,
5978 rdr.read_hash_and_stash(node, decl);
5980 maybe_set_artificial_location(rdr, node, decl);
5981 decl->set_is_artificial(is_artificial);
5984 bool is_def_of_decl =
false;
5986 def_id = CHAR_STR(s);
5988 if (!def_id.empty())
5991 dynamic_pointer_cast<class_decl>(rdr.get_type_decl(def_id));
5992 if (d && d->get_is_declaration_only())
5994 is_def_of_decl =
true;
5995 decl->set_earlier_declaration(d);
5996 d->set_definition_of_declaration(decl);
6002 && !decl->get_is_declaration_only()
6003 && previous_declaration)
6009 decl->set_earlier_declaration(previous_declaration);
6010 for (vector<type_base_sptr>::const_iterator i = types_ptr->begin();
6011 i != types_ptr->end();
6016 if (d->get_is_declaration_only()
6017 && !d->get_definition_of_declaration())
6019 previous_declaration->set_definition_of_declaration(decl);
6020 is_def_of_decl =
true;
6025 if (is_decl_only && previous_definition)
6030 && !decl->get_definition_of_declaration());
6031 decl->set_definition_of_declaration(previous_definition);
6034 ABG_ASSERT(!is_decl_only || !is_def_of_decl);
6036 rdr.push_decl_to_scope(decl,
6037 add_to_current_scope
6038 ? rdr.get_scope_ptr_for_node(node)
6041 rdr.map_xml_node_to_decl(node, decl);
6042 rdr.key_type_decl(decl,
id);
6044 maybe_set_naming_typedef(rdr, node, decl);
6046 for (xmlNodePtr n = xmlFirstElementChild(node);
6048 n = xmlNextElementSibling(n))
6050 if (xmlStrEqual(n->name, BAD_CAST(
"member-type")))
6053 read_access(n, access);
6055 rdr.map_xml_node_to_decl(n, decl);
6057 for (xmlNodePtr p = xmlFirstElementChild(n);
6059 p = xmlNextElementSibling(p))
6061 string member_type_name;
6062 read_name(p, member_type_name);
6064 if (!member_type_name.empty())
6065 t = decl->find_member_type(member_type_name);
6068 if ((t = build_type(rdr, p,
true)))
6072 if (!td->get_scope())
6073 decl->add_member_type(t);
6075 rdr.schedule_type_for_canonicalization(t);
6078 string id = CHAR_STR(i);
6080 rdr.key_type_decl(t,
id);
6081 rdr.map_xml_node_to_decl(p, td);
6085 else if (xmlStrEqual(n->name, BAD_CAST(
"data-member")))
6087 rdr.map_xml_node_to_decl(n, decl);
6090 read_access(n, access);
6092 bool is_laid_out =
true;
6093 size_t offset_in_bits = 0;
6094 bool is_static =
false;
6095 read_static(n, is_static);
6097 for (xmlNodePtr p = xmlFirstElementChild(n);
6099 p = xmlNextElementSibling(p))
6102 build_var_decl(rdr, p,
false))
6104 if (decl->find_data_member(v))
6112 decl_base_sptr d = rdr.pop_decl();
6117 || !variable_is_suppressed(rdr, decl.get(), *v))
6119 decl->add_data_member(v, access,
6132 RECORD_ARTIFACT_AS_USED_BY(rdr, v->get_type(), decl);
6135 RECORD_ARTIFACT_AS_USED_BY(rdr, v->get_type(), v);
6136 RECORD_ARTIFACT_AS_USED_BY(rdr, v, decl);
6142 else if (xmlStrEqual(n->name, BAD_CAST(
"member-function")))
6144 rdr.map_xml_node_to_decl(n, decl);
6147 read_access(n, access);
6149 bool is_static =
false;
6150 read_static(n, is_static);
6152 bool is_ctor =
false, is_dtor =
false, is_const =
false;
6153 read_cdtor_const(n, is_ctor, is_dtor, is_const);
6155 for (xmlNodePtr p = xmlFirstElementChild(n);
6157 p = xmlNextElementSibling(p))
6160 build_function_decl_if_not_suppressed(rdr, p, decl,
6171 rdr.add_fn_to_exported_or_undefined_decls(f.get());
6176 else if (xmlStrEqual(n->name, BAD_CAST(
"member-template")))
6178 rdr.map_xml_node_to_decl(n, decl);
6181 read_access(n, access);
6183 bool is_static =
false;
6184 read_static(n, is_static);
6186 bool is_ctor =
false, is_dtor =
false, is_const =
false;
6187 read_cdtor_const(n, is_ctor, is_dtor, is_const);
6189 for (xmlNodePtr p = xmlFirstElementChild(n);
6191 p = xmlNextElementSibling(p))
6194 build_function_tdecl(rdr, p,
6197 member_function_template_sptr m
6198 (
new member_function_template(f, access, is_static,
6199 is_ctor, is_const));
6201 decl->add_member_function_template(m);
6204 build_class_tdecl(rdr, p,
6207 member_class_template_sptr m(
new member_class_template(c,
6211 decl->add_member_class_template(m);
6217 rdr.pop_scope_or_abort(decl);
6234static shared_ptr<function_tdecl>
6235build_function_tdecl(reader& rdr,
6236 const xmlNodePtr node,
6237 bool add_to_current_scope)
6239 shared_ptr<function_tdecl> nil, result;
6241 if (!xmlStrEqual(node->name, BAD_CAST(
"function-template-decl")))
6247 if (
id.empty() || rdr.get_fn_tmpl_decl(
id))
6251 read_location(rdr, node, loc);
6254 read_visibility(node, vis);
6257 read_binding(node, bind);
6259 const environment& env = rdr.get_environment();
6262 maybe_set_artificial_location(rdr, node, fn_tmpl_decl);
6264 rdr.push_decl_to_scope(fn_tmpl_decl,
6265 add_to_current_scope
6266 ? rdr.get_scope_ptr_for_node(node)
6268 rdr.key_fn_tmpl_decl(fn_tmpl_decl,
id);
6269 rdr.map_xml_node_to_decl(node, fn_tmpl_decl);
6271 unsigned parm_index = 0;
6272 for (xmlNodePtr n = xmlFirstElementChild(node);
6274 n = xmlNextElementSibling(n))
6277 build_template_parameter(rdr, n, parm_index, fn_tmpl_decl))
6279 fn_tmpl_decl->add_template_parameter(parm);
6286 fn_tmpl_decl->set_pattern(f);
6289 rdr.key_fn_tmpl_decl(fn_tmpl_decl,
id);
6291 return fn_tmpl_decl;
6307build_class_tdecl(reader& rdr,
6308 const xmlNodePtr node,
6309 bool add_to_current_scope)
6313 if (!xmlStrEqual(node->name, BAD_CAST(
"class-template-decl")))
6319 if (
id.empty() || rdr.get_class_tmpl_decl(
id))
6323 read_location(rdr, node, loc);
6326 read_visibility(node, vis);
6328 const environment& env = rdr.get_environment();
6331 maybe_set_artificial_location(rdr, node, class_tmpl);
6333 if (add_to_current_scope)
6334 rdr.push_decl_to_scope(class_tmpl, node);
6335 rdr.key_class_tmpl_decl(class_tmpl,
id);
6336 rdr.map_xml_node_to_decl(node, class_tmpl);
6338 unsigned parm_index = 0;
6339 for (xmlNodePtr n = xmlFirstElementChild(node);
6341 n = xmlNextElementSibling(n))
6344 build_template_parameter(rdr, n, parm_index, class_tmpl))
6346 class_tmpl->add_template_parameter(parm);
6350 build_class_decl_if_not_suppressed(rdr, n,
6351 add_to_current_scope))
6354 rdr.schedule_type_for_canonicalization(c);
6355 class_tmpl->set_pattern(c);
6359 rdr.key_class_tmpl_decl(class_tmpl,
id);
6380build_type_tparameter(reader& rdr,
6381 const xmlNodePtr node,
6387 if (!xmlStrEqual(node->name, BAD_CAST(
"template-type-parameter")))
6398 type_id = CHAR_STR(s);
6399 if (!type_id.empty()
6400 && !(result = dynamic_pointer_cast<type_tparameter>
6401 (rdr.build_or_get_type_decl(type_id,
true))))
6409 read_location(rdr, node,loc);
6411 result.reset(
new type_tparameter(index, tdecl, name, loc));
6412 maybe_set_artificial_location(rdr, node, result);
6415 rdr.push_decl_to_scope(
is_decl(result), node);
6417 rdr.push_and_key_type_decl(result, node,
true);
6419 rdr.schedule_type_for_canonicalization(result);
6439build_type_composition(reader& rdr,
6440 const xmlNodePtr node,
6446 if (!xmlStrEqual(node->name, BAD_CAST(
"template-parameter-type-composition")))
6449 type_base_sptr composed_type;
6450 result.reset(
new type_composition(index, tdecl, composed_type));
6451 rdr.push_decl_to_scope(
is_decl(result), node);
6453 for (xmlNodePtr n = xmlFirstElementChild(node);
6455 n = xmlNextElementSibling(n))
6457 if ((composed_type =
6458 build_pointer_type_def(rdr, n,
6461 build_reference_type_def(rdr, n,
6464 build_array_type_def(rdr, n,
6467 build_qualified_type_decl(rdr, n,
6470 rdr.schedule_type_for_canonicalization(composed_type);
6471 result->set_composed_type(composed_type);
6495build_non_type_tparameter(reader& rdr,
6496 const xmlNodePtr node,
6502 if (!xmlStrEqual(node->name, BAD_CAST(
"template-non-type-parameter")))
6507 type_id = CHAR_STR(s);
6508 type_base_sptr type;
6510 || !(type = rdr.build_or_get_type_decl(type_id,
true)))
6518 read_location(rdr, node,loc);
6520 r.reset(
new non_type_tparameter(index, tdecl, name, type, loc));
6521 maybe_set_artificial_location(rdr, node, r);
6522 rdr.push_decl_to_scope(
is_decl(r), node);
6542build_template_tparameter(reader& rdr,
6543 const xmlNodePtr node,
6549 if (!xmlStrEqual(node->name, BAD_CAST(
"template-template-parameter")))
6560 type_id = CHAR_STR(s);
6562 if (!type_id.empty()
6563 && !(dynamic_pointer_cast<template_tparameter>
6564 (rdr.build_or_get_type_decl(type_id,
true))))
6572 read_location(rdr, node, loc);
6576 maybe_set_artificial_location(rdr, node, result);
6577 rdr.push_decl_to_scope(result, node);
6581 for (xmlNodePtr n = xmlFirstElementChild(node);
6583 n = xmlNextElementSibling(n))
6584 if (shared_ptr<template_parameter> p =
6585 build_template_parameter(rdr, n, parm_index, result))
6587 result->add_template_parameter(p);
6593 rdr.key_type_decl(result,
id);
6594 rdr.schedule_type_for_canonicalization(result);
6616build_template_parameter(reader& rdr,
6617 const xmlNodePtr node,
6621 shared_ptr<template_parameter> r;
6622 ((r = build_type_tparameter(rdr, node, index, tdecl))
6623 || (r = build_non_type_tparameter(rdr, node, index, tdecl))
6624 || (r = build_template_tparameter(rdr, node, index, tdecl))
6625 || (r = build_type_composition(rdr, node, index, tdecl)));
6638static type_base_sptr
6639build_type(reader& rdr,
6640 const xmlNodePtr node,
6641 bool add_to_current_scope)
6645 ((t = build_type_decl(rdr, node, add_to_current_scope))
6646 || (t = build_qualified_type_decl(rdr, node, add_to_current_scope))
6647 || (t = build_pointer_type_def(rdr, node, add_to_current_scope))
6648 || (t = build_reference_type_def(rdr, node , add_to_current_scope))
6649 || (t = build_ptr_to_mbr_type(rdr, node , add_to_current_scope))
6650 || (t = build_function_type(rdr, node, add_to_current_scope))
6651 || (t = build_array_type_def(rdr, node, add_to_current_scope))
6652 || (t = build_subrange_type(rdr, node, add_to_current_scope))
6653 || (t = build_enum_type_decl_if_not_suppressed(rdr, node,
6654 add_to_current_scope))
6655 || (t = build_typedef_decl(rdr, node, add_to_current_scope))
6656 || (t = build_class_decl_if_not_suppressed(rdr, node,
6657 add_to_current_scope))
6658 || (t = build_union_decl_if_not_suppressed(rdr, node,
6659 add_to_current_scope)));
6661 if (rdr.tracking_non_reachable_types() && t)
6663 corpus_sptr abi = rdr.corpus();
6665 bool is_non_reachable_type =
false;
6666 read_is_non_reachable_type(node, is_non_reachable_type);
6667 if (!is_non_reachable_type)
6668 abi->record_type_as_reachable_from_public_interfaces(*t);
6671 MAYBE_MAP_TYPE_WITH_TYPE_ID(t, node);
6674 rdr.schedule_type_for_canonicalization(t);
6683static decl_base_sptr
6684handle_type_decl(reader& rdr,
6686 bool add_to_current_scope)
6688 type_decl_sptr decl = build_type_decl(rdr, node, add_to_current_scope);
6689 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6690 if (decl && decl->get_scope())
6691 rdr.schedule_type_for_canonicalization(decl);
6700static decl_base_sptr
6701handle_namespace_decl(reader& rdr,
6703 bool add_to_current_scope)
6706 add_to_current_scope);
6715static decl_base_sptr
6716handle_qualified_type_decl(reader& rdr,
6718 bool add_to_current_scope)
6720 qualified_type_def_sptr decl =
6721 build_qualified_type_decl(rdr, node,
6722 add_to_current_scope);
6723 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6724 if (decl && decl->get_scope())
6725 rdr.schedule_type_for_canonicalization(decl);
6734static decl_base_sptr
6735handle_pointer_type_def(reader& rdr,
6737 bool add_to_current_scope)
6740 add_to_current_scope);
6741 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6742 if (decl && decl->get_scope())
6743 rdr.schedule_type_for_canonicalization(decl);
6752static decl_base_sptr
6753handle_reference_type_def(reader& rdr,
6755 bool add_to_current_scope)
6758 add_to_current_scope);
6759 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6760 if (decl && decl->get_scope())
6761 rdr.schedule_type_for_canonicalization(decl);
6770static type_base_sptr
6771handle_function_type(reader& rdr,
6773 bool add_to_current_scope)
6776 add_to_current_scope);
6777 MAYBE_MAP_TYPE_WITH_TYPE_ID(type, node);
6778 rdr.schedule_type_for_canonicalization(type);
6787static decl_base_sptr
6788handle_array_type_def(reader& rdr,
6790 bool add_to_current_scope)
6793 add_to_current_scope);
6794 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6795 rdr.schedule_type_for_canonicalization(decl);
6802static decl_base_sptr
6803handle_enum_type_decl(reader& rdr,
6805 bool add_to_current_scope)
6808 build_enum_type_decl_if_not_suppressed(rdr, node,
6809 add_to_current_scope);
6810 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6811 if (decl && decl->get_scope())
6812 rdr.schedule_type_for_canonicalization(decl);
6819static decl_base_sptr
6820handle_typedef_decl(reader& rdr,
6822 bool add_to_current_scope)
6825 add_to_current_scope);
6826 MAYBE_MAP_TYPE_WITH_TYPE_ID(decl, node);
6827 if (decl && decl->get_scope())
6828 rdr.schedule_type_for_canonicalization(decl);
6840static decl_base_sptr
6841handle_var_decl(reader& rdr,
6843 bool add_to_current_scope)
6845 decl_base_sptr decl = build_var_decl_if_not_suppressed(rdr, node,
6846 add_to_current_scope);
6847 rdr.add_var_to_exported_or_undefined_decls(
is_var_decl(decl));
6857static decl_base_sptr
6858handle_function_decl(reader& rdr,
6860 bool add_to_current_scope)
6862 return build_function_decl_if_not_suppressed(rdr, node,
class_decl_sptr(),
6863 add_to_current_scope,
6873static decl_base_sptr
6874handle_class_decl(reader& rdr,
6876 bool add_to_current_scope)
6879 build_class_decl_if_not_suppressed(rdr, node, add_to_current_scope);
6880 MAYBE_MAP_TYPE_WITH_TYPE_ID(
is_type(decl), node);
6881 if (decl && decl->get_scope())
6882 rdr.schedule_type_for_canonicalization(decl);
6892static decl_base_sptr
6893handle_union_decl(reader& rdr,
6895 bool add_to_current_scope)
6897 union_decl_sptr decl =
6898 build_union_decl_if_not_suppressed(rdr, node, add_to_current_scope);
6899 MAYBE_MAP_TYPE_WITH_TYPE_ID(
is_type(decl), node);
6900 if (decl && decl->get_scope())
6901 rdr.schedule_type_for_canonicalization(decl);
6911static decl_base_sptr
6912handle_function_tdecl(reader& rdr,
6914 bool add_to_current_scope)
6917 add_to_current_scope);
6926static decl_base_sptr
6927handle_class_tdecl(reader& rdr,
6929 bool add_to_current_scope)
6932 add_to_current_scope);
6949 return read_translation_unit_from_input(read_rdr);
6974 corpus_sptr corp = result->corpus();
6975 corp->set_origin(corpus::NATIVE_XML_ORIGIN);
6976#ifdef WITH_DEBUG_SELF_COMPARISON
6977 if (env.self_comparison_debug_is_on())
6978 env.set_self_comparison_debug_input(result->corpus());
6980 result->set_path(path);
6997 corpus_sptr corp = result->corpus();
6998 corp->set_origin(corpus::NATIVE_XML_ORIGIN);
6999#ifdef WITH_DEBUG_SELF_COMPARISON
7000 if (env.self_comparison_debug_is_on())
7001 env.set_self_comparison_debug_input(result->corpus());
7024 return rdr->read_corpus(sts);
7046 corpus_sptr corp = rdr->read_corpus(sts);