20#include <unordered_map>
24#include "abg-internal.h"
26ABG_BEGIN_EXPORT_DECLARATIONS
33ABG_END_EXPORT_DECLARATIONS
68using std::unordered_map;
69using std::dynamic_pointer_cast;
70using std::static_pointer_cast;
77struct interned_string_pool::priv
97{
return priv_->map.find(s) != priv_->map.end();}
108 unordered_map<string, string*>::const_iterator i =
110 if (i == priv_->map.end())
113 return i->second->c_str();
125 string*& result = priv_->map[str_value];
126 if (!result && !str_value.empty())
127 result =
new string(str_value);
134 for (pool_map_type::iterator i = priv_->map.begin();
135 i != priv_->map.end();
152{
return r.operator==(l);}
155operator!=(
const std::string& l,
const interned_string& r)
170 o << static_cast<std::string>(s);
186{
return static_cast<std::string
>(s1) + s2;}
200{
return s1 +
static_cast<std::string
>(s2);}
206hash_as_canonical_type_or_constant(
const type_base *t);
209has_generic_anonymous_internal_type_name(
const decl_base *d);
211static interned_string
212get_generic_anonymous_internal_type_name(
const decl_base *d);
215get_internal_real_type_name(
const type_base*);
218update_qualified_name(decl_base * d);
221update_qualified_name(decl_base_sptr d);
223static interned_string
224pointer_declaration_name(
const type_base* ptr,
225 const string& variable_name,
226 bool qualified,
bool internal);
228static interned_string
229pointer_declaration_name(
const type_base_sptr& ptr,
230 const string& variable_name,
231 bool qualified,
bool internal);
233static interned_string
234ptr_to_mbr_declaration_name(
const ptr_to_mbr_type* ptr,
235 const string& variable_name,
236 bool qualified,
bool internal);
238static interned_string
240 const string& variable_name,
241 bool qualified,
bool internal);
243static interned_string
244array_declaration_name(
const array_type_def* array,
245 const string& variable_name,
246 bool qualified,
bool internal);
248static interned_string
250 const string& variable_name,
251 bool qualified,
bool internal);
254stream_pretty_representation_of_fn_parms(
const function_type& fn_type,
255 ostream& o,
bool qualified,
258add_outer_pointer_to_fn_type_expr(
const type_base* pointer_to_fn,
259 const string& input,
bool qualified,
263add_outer_pointer_to_fn_type_expr(
const type_base_sptr& pointer_to_fn,
264 const string& input,
bool qualified,
268add_outer_pointer_to_array_type_expr(
const type_base* pointer_to_ar,
269 const string& input,
bool qualified,
273add_outer_pointer_to_array_type_expr(
const type_base_sptr& pointer_to_ar,
274 const string& input,
bool qualified,
278add_outer_ptr_to_mbr_type_expr(
const ptr_to_mbr_type* p,
279 const string& input,
bool qualified,
284 const string& input,
bool qualified,
288add_outer_pointer_to_ptr_to_mbr_type_expr(
const type_base* p,
290 bool qualified,
bool internal);
294 const type_base& right);
298 const type_base& right);
315 env.priv_->push_composite_type_comparison_operands(&left, &right);
336 env.priv_->pop_composite_type_comparison_operands(&left, &right);
346{
return t.priv_->canonical_type_index;}
381 if (c && t->get_corpus())
386 if (t->get_corpus()->get_group() == g.get())
391 if (t->get_corpus() == c.get())
400class expanded_location
412 expanded_location(
const string& path,
unsigned line,
unsigned column)
413 : path_(path), line_(line), column_(column)
417 operator==(
const expanded_location& l)
const
419 return (path_ == l.path_
421 && column_ && l.column_);
425 operator<(
const expanded_location& l)
const
429 else if (path_ > l.path_)
434 else if (line_ > l.line_)
437 return column_ < l.column_;
454 if (!get_location_manager())
475 unsigned line = 0, column = 0;
476 expand(path, line, column);
478 std::ostringstream o;
479 o << path <<
":" << line <<
":" << column;
483struct location_manager::priv
489 std::vector<expanded_location> locs;
492location_manager::location_manager()
496location_manager::~location_manager() =
default;
511 expanded_location l(file_path, line, col);
515 priv_->locs.push_back(l);
516 return location(priv_->locs.size(),
this);
533 unsigned& column)
const
537 expanded_location &l = priv_->locs[
location.value_ - 1];
550struct type_maps::priv
564 mutable vector<type_base_wptr> sorted_types_;
567type_maps::type_maps()
571type_maps::~type_maps() =
default;
596{
return priv_->basic_types_;}
603{
return priv_->basic_types_;}
610{
return priv_->class_types_;}
617{
return priv_->class_types_;}
624{
return priv_->union_types_;}
631{
return priv_->union_types_;}
638{
return priv_->enum_types_;}
645{
return priv_->enum_types_;}
652{
return priv_->typedef_types_;}
659{
return priv_->typedef_types_;}
665{
return priv_->qualified_types_;}
671{
return priv_->qualified_types_;}
678{
return priv_->pointer_types_;}
685{
return priv_->ptr_to_mbr_types_;}
692{
return priv_->ptr_to_mbr_types_;}
699{
return priv_->pointer_types_;}
706{
return priv_->reference_types_;}
713{
return priv_->reference_types_;}
720{
return priv_->array_types_;}
727{
return priv_->array_types_;}
734{
return priv_->subrange_types_;}
741{
return priv_->subrange_types_;}
748{
return priv_->function_types_;}
755{
return priv_->function_types_;}
774 if (l == 0 && r == 0)
779 return l_repr < r_repr;
793 operator()(
const type_base_sptr &l,
const type_base_sptr &r)
const
794 {
return operator()(l.get(), r.get());}
808 {
return operator()(type_base_sptr(l), type_base_sptr(r));}
811#ifdef WITH_DEBUG_SELF_COMPARISON
827notify_equality_failed(
const type_or_decl_base &l __attribute__((unused)),
828 const type_or_decl_base &r __attribute__((unused)))
845notify_equality_failed(
const type_or_decl_base *l __attribute__((unused)),
846 const type_or_decl_base *r __attribute__((unused)))
849#define ABG_RETURN_EQUAL(l, r) \
853 notify_equality_failed(l, r); \
859#define ABG_RETURN_FALSE \
862 notify_equality_failed(l, r); \
866#define ABG_RETURN(value) \
869 if (value == false) \
870 notify_equality_failed(l, r); \
876#define ABG_RETURN_FALSE return false
877#define ABG_RETURN(value) return (value)
878#define ABG_RETURN_EQUAL(l, r) return ((l) == (r));
898 if (
type_base* type = t->get_naked_canonical_type())
899 return dynamic_cast<T*
>(type);
916#if WITH_DEBUG_TYPE_CANONICALIZATION
936 if (env.priv_->use_canonical_type_comparison_)
938 if (
const type_base *lc = l->get_naked_canonical_type())
939 if (
const type_base *rc = r->get_naked_canonical_type())
940 ABG_RETURN_EQUAL(lc, rc);
949 if (l_hash != r_hash)
958 if (
const type_base *lc = l->get_naked_canonical_type())
959 if (
const type_base *rc = r->get_naked_canonical_type())
960 ABG_RETURN_EQUAL(lc, rc);
968 if (l_hash != r_hash)
991 bool result = l.priv_->comparison_started(l, r);
1031#define RETURN_TRUE_IF_COMPARISON_CYCLE_DETECTED(l, r) \
1034 if (is_comparison_cycle_detected(l, r)) \
1052 l.priv_->mark_as_being_compared(l, r);
1087 l.priv_->unmark_as_being_compared(l, r);
1133#define CACHE_AND_RETURN_COMPARISON_RESULT(value) \
1136 bool res = return_comparison_result(l, r, value); \
1137 l.get_environment().priv_->cache_type_comparison_result(l, r, res); \
1145#define CACHE_COMPARISON_RESULT_AND_RETURN(value) \
1148 l.get_environment().priv_->cache_type_comparison_result(l, r, value); \
1156const vector<type_base_wptr>&
1159 if (priv_->sorted_types_.empty())
1161 istring_type_base_wptrs_map_type::const_iterator i;
1162 vector<type_base_wptr>::const_iterator j;
1165 for (j = i->second.begin(); j != i->second.end(); ++j)
1166 priv_->sorted_types_.push_back(*j);
1169 for (j = i->second.begin(); j != i->second.end(); ++j)
1170 priv_->sorted_types_.push_back(*j);
1173 for (j = i->second.begin(); j != i->second.end(); ++j)
1174 priv_->sorted_types_.push_back(*j);
1177 for (j = i->second.begin(); j != i->second.end(); ++j)
1178 priv_->sorted_types_.push_back(*j);
1181 for (j = i->second.begin(); j != i->second.end(); ++j)
1182 priv_->sorted_types_.push_back(*j);
1184 type_name_comp comp;
1185 sort(priv_->sorted_types_.begin(), priv_->sorted_types_.end(), comp);
1188 return priv_->sorted_types_;
1207 const std::string& path,
1209 : priv_(new
priv(env))
1211 priv_->path_ = path;
1212 priv_->address_size_ = address_size;
1234 if (!priv_->global_scope_)
1236 priv_->global_scope_.reset
1238 priv_->global_scope_->set_translation_unit
1241 return priv_->global_scope_;
1249{
return priv_->types_;}
1256{
return priv_->types_;}
1263const vector<function_type_sptr>&
1265{
return priv_->live_fn_types_;}
1272{
return priv_->env_;}
1279{
return priv_->language_;}
1286{priv_->language_ = l;}
1299{
return priv_->path_;}
1310{priv_->path_ = a_path;}
1323{
return priv_->comp_dir_path_;}
1334{priv_->comp_dir_path_ = d;}
1343 if (priv_->abs_path_.empty())
1346 if (!priv_->path_.empty())
1348 if (!priv_->comp_dir_path_.empty())
1350 path = priv_->comp_dir_path_;
1353 path += priv_->path_;
1355 priv_->abs_path_ = path;
1358 return priv_->abs_path_;
1377{
return priv_->corp;}
1393{
return priv_->loc_mgr_;}
1401{
return priv_->loc_mgr_;}
1410 if (!priv_->global_scope_)
1420{
return priv_->address_size_;}
1427{priv_->address_size_= a;}
1443{
return priv_->is_constructed_;}
1459{priv_->is_constructed_ = f;}
1498 const_cast<translation_unit*
>(
this)->priv_->live_fn_types_.push_back(ftype);
1531translation_unit::~translation_unit()
1544 case translation_unit::LANG_UNKNOWN:
1545 return "LANG_UNKNOWN";
1546 case translation_unit::LANG_Cobol74:
1547 return "LANG_Cobol74";
1548 case translation_unit::LANG_Cobol85:
1549 return "LANG_Cobol85";
1550 case translation_unit::LANG_C89:
1552 case translation_unit::LANG_C99:
1554 case translation_unit::LANG_C11:
1556 case translation_unit::LANG_C:
1558 case translation_unit::LANG_C_plus_plus_11:
1559 return "LANG_C_plus_plus_11";
1560 case translation_unit::LANG_C_plus_plus_14:
1561 return "LANG_C_plus_plus_14";
1562 case translation_unit::LANG_C_plus_plus:
1563 return "LANG_C_plus_plus";
1564 case translation_unit::LANG_ObjC:
1566 case translation_unit::LANG_ObjC_plus_plus:
1567 return "LANG_ObjC_plus_plus";
1568 case translation_unit::LANG_Fortran77:
1569 return "LANG_Fortran77";
1570 case translation_unit::LANG_Fortran90:
1571 return "LANG_Fortran90";
1572 case translation_unit::LANG_Fortran95:
1573 return "LANG_Fortran95";
1574 case translation_unit::LANG_Ada83:
1575 return "LANG_Ada83";
1576 case translation_unit::LANG_Ada95:
1577 return "LANG_Ada95";
1578 case translation_unit::LANG_Pascal83:
1579 return "LANG_Pascal83";
1580 case translation_unit::LANG_Modula2:
1581 return "LANG_Modula2";
1582 case translation_unit::LANG_Java:
1584 case translation_unit::LANG_PLI:
1586 case translation_unit::LANG_UPC:
1588 case translation_unit::LANG_D:
1590 case translation_unit::LANG_Python:
1591 return "LANG_Python";
1592 case translation_unit::LANG_Go:
1594 case translation_unit::LANG_Mips_Assembler:
1595 return "LANG_Mips_Assembler";
1597 return "LANG_UNKNOWN";
1600 return "LANG_UNKNOWN";
1612 if (l ==
"LANG_Cobol74")
1613 return translation_unit::LANG_Cobol74;
1614 else if (l ==
"LANG_Cobol85")
1615 return translation_unit::LANG_Cobol85;
1616 else if (l ==
"LANG_C89")
1617 return translation_unit::LANG_C89;
1618 else if (l ==
"LANG_C99")
1619 return translation_unit::LANG_C99;
1620 else if (l ==
"LANG_C11")
1621 return translation_unit::LANG_C11;
1622 else if (l ==
"LANG_C")
1623 return translation_unit::LANG_C;
1624 else if (l ==
"LANG_C_plus_plus_11")
1625 return translation_unit::LANG_C_plus_plus_11;
1626 else if (l ==
"LANG_C_plus_plus_14")
1627 return translation_unit::LANG_C_plus_plus_14;
1628 else if (l ==
"LANG_C_plus_plus")
1629 return translation_unit::LANG_C_plus_plus;
1630 else if (l ==
"LANG_ObjC")
1631 return translation_unit::LANG_ObjC;
1632 else if (l ==
"LANG_ObjC_plus_plus")
1633 return translation_unit::LANG_ObjC_plus_plus;
1634 else if (l ==
"LANG_Fortran77")
1635 return translation_unit::LANG_Fortran77;
1636 else if (l ==
"LANG_Fortran90")
1637 return translation_unit::LANG_Fortran90;
1638 else if (l ==
"LANG_Fortran95")
1639 return translation_unit::LANG_Fortran95;
1640 else if (l ==
"LANG_Ada83")
1641 return translation_unit::LANG_Ada83;
1642 else if (l ==
"LANG_Ada95")
1643 return translation_unit::LANG_Ada95;
1644 else if (l ==
"LANG_Pascal83")
1645 return translation_unit::LANG_Pascal83;
1646 else if (l ==
"LANG_Modula2")
1647 return translation_unit::LANG_Modula2;
1648 else if (l ==
"LANG_Java")
1649 return translation_unit::LANG_Java;
1650 else if (l ==
"LANG_PLI")
1651 return translation_unit::LANG_PLI;
1652 else if (l ==
"LANG_UPC")
1653 return translation_unit::LANG_UPC;
1654 else if (l ==
"LANG_D")
1655 return translation_unit::LANG_D;
1656 else if (l ==
"LANG_Python")
1657 return translation_unit::LANG_Python;
1658 else if (l ==
"LANG_Go")
1659 return translation_unit::LANG_Go;
1660 else if (l ==
"LANG_Mips_Assembler")
1661 return translation_unit::LANG_Mips_Assembler;
1663 return translation_unit::LANG_UNKNOWN;
1674 return (l == translation_unit::LANG_C89
1675 || l == translation_unit::LANG_C99
1676 || l == translation_unit::LANG_C11
1677 || l == translation_unit::LANG_C);
1688 return (l == translation_unit::LANG_C_plus_plus_03
1689 || l == translation_unit::LANG_C_plus_plus_11
1690 || l == translation_unit::LANG_C_plus_plus_14
1691 || l == translation_unit::LANG_C_plus_plus);
1701{
return l == translation_unit::LANG_Java;}
1711 return (l == translation_unit::LANG_Ada83
1712 || l == translation_unit::LANG_Ada95);
1725 if (l.get() == r.get())
1748struct elf_symbol::priv
1788 bool is_in_ksymtab_;
1791 bool is_suppressed_;
1806 is_in_ksymtab_(false),
1809 is_suppressed_(false)
1812 priv(
const environment& e,
1820 const elf_symbol::version& ve,
1842 is_common_ = type_ == COMMON_TYPE;
1876elf_symbol::elf_symbol(
const environment& e,
1952 elf_symbol_sptr sym(
new elf_symbol(e, i, s, n, t, b, d, c, ve, vi,
1954 sym->priv_->main_symbol_ = sym;
1994{
return priv_->env_;}
2001{
return priv_->index_;}
2015{
return priv_->name_;}
2024 priv_->id_string_.clear();
2032{
return priv_->type_;}
2046{
return priv_->size_;}
2053{priv_->size_ = size;}
2060{
return priv_->binding_;}
2067{priv_->binding_ = b;}
2074{
return priv_->version_;}
2082 priv_->version_ = v;
2083 priv_->id_string_.clear();
2092{priv_->visibility_ = v;}
2100{
return priv_->visibility_;}
2108{
return priv_->is_defined_;}
2116{priv_->is_defined_ = d;}
2169{
return priv_->is_in_ksymtab_;}
2184{
return priv_->crc_;}
2198{
return priv_->namespace_;}
2205{priv_->namespace_ = ns;}
2214{
return priv_->is_suppressed_;}
2253{
return priv_->main_symbol_.lock();}
2260{
return priv_->main_symbol_.lock();}
2274{
return priv_->next_alias_.lock();}
2294 a = a->get_next_alias())
2317 a && !a->is_main_symbol();
2318 a = a->get_next_alias())
2320 if (a->get_next_alias()->is_main_symbol())
2328 last_alias->priv_->next_alias_ = alias;
2331 priv_->next_alias_ = alias;
2361 a = a->get_next_alias())
2362 if (a->get_name() == name)
2372 priv_->main_symbol_ = new_main;
2374 a = a->get_next_alias())
2375 a->priv_->main_symbol_ = new_main;
2385{
return priv_->is_common_;}
2416{
return priv_->next_common_instance_.lock();}
2431 ABG_ASSERT(!common->has_other_common_instances());
2440 c = c->get_next_common_instance())
2445 last_common_instance = c;
2450 last_common_instance->priv_->next_common_instance_ = common;
2453 priv_->next_common_instance_ = common;
2473 if (priv_->id_string_.empty())
2485 priv_->id_string_ = s;
2488 return priv_->id_string_;
2505 a = a->get_next_alias())
2506 if (a->get_name() == name)
2523 a && a.get() != a->get_main_symbol().get();
2524 a = a->get_next_alias())
2525 if (textually_equals(*
this, *a))
2542 bool include_symbol_itself)
const
2546 if (include_symbol_itself)
2549 vector<elf_symbol_sptr> aliases;
2550 compute_aliases_for_elf_symbol(*
this, syms, aliases);
2551 if (!aliases.empty() && include_symbol_itself)
2554 for (vector<elf_symbol_sptr>::const_iterator i = aliases.begin();
2558 if (i != aliases.begin())
2560 result += (*i)->get_id_string();
2575 vector<elf_symbol_sptr> aliases;
2576 if (include_symbol_itself)
2581 a = a->get_next_alias())
2582 aliases.push_back(a);
2585 for (vector<elf_symbol_sptr>::const_iterator i = aliases.begin();
2589 if (i != aliases.begin())
2591 result += (*i)->get_id_string();
2611 name.clear(), ver.clear();
2613 string::size_type i =
id.find(
'@');
2614 if (i == string::npos)
2620 name =
id.substr(0, i);
2626 string::size_type j =
id.find(
'@', i);
2627 if (j == string::npos)
2654 bool are_equal = textually_equals(*
this, other);
2675 a && !a->is_main_symbol();
2676 a = a->get_next_alias())
2700 return *lhs == *rhs;
2726compute_aliases_for_elf_symbol(
const elf_symbol& sym,
2728 vector<elf_symbol_sptr>& aliases)
2732 for (; a && !a->is_main_symbol(); a = a->get_next_alias())
2733 aliases.push_back(a);
2735 for (string_elf_symbols_map_type::const_iterator i = symtab.begin();
2738 for (elf_symbols::const_iterator j = i->second.begin();
2739 j != i->second.end();
2744 s && !s->is_main_symbol();
2745 s = s->get_next_alias())
2746 aliases.push_back(s);
2749 s && !s->is_main_symbol();
2750 s = s->get_next_alias())
2752 aliases.push_back(*j);
2797 case elf_symbol::NOTYPE_TYPE:
2798 repr =
"unspecified symbol type";
2800 case elf_symbol::OBJECT_TYPE:
2801 repr =
"variable symbol type";
2803 case elf_symbol::FUNC_TYPE:
2804 repr =
"function symbol type";
2806 case elf_symbol::SECTION_TYPE:
2807 repr =
"section symbol type";
2809 case elf_symbol::FILE_TYPE:
2810 repr =
"file symbol type";
2812 case elf_symbol::COMMON_TYPE:
2813 repr =
"common data object symbol type";
2815 case elf_symbol::TLS_TYPE:
2816 repr =
"thread local data object symbol type";
2818 case elf_symbol::GNU_IFUNC_TYPE:
2819 repr =
"indirect function symbol type";
2823 std::ostringstream s;
2824 s <<
"unknown symbol type (" << (char)t <<
')';
2847 case elf_symbol::LOCAL_BINDING:
2848 repr =
"local binding";
2850 case elf_symbol::GLOBAL_BINDING:
2851 repr =
"global binding";
2853 case elf_symbol::WEAK_BINDING:
2854 repr =
"weak binding";
2856 case elf_symbol::GNU_UNIQUE_BINDING:
2857 repr =
"GNU unique binding";
2861 std::ostringstream s;
2862 s <<
"unknown binding (" << (
unsigned char) b <<
")";
2885 case elf_symbol::DEFAULT_VISIBILITY:
2886 repr =
"default visibility";
2888 case elf_symbol::PROTECTED_VISIBILITY:
2889 repr =
"protected visibility";
2891 case elf_symbol::HIDDEN_VISIBILITY:
2892 repr =
"hidden visibility";
2894 case elf_symbol::INTERNAL_VISIBILITY:
2895 repr =
"internal visibility";
2899 std::ostringstream s;
2900 s <<
"unknown visibility (" << (
unsigned char) v <<
")";
2922 t = elf_symbol::NOTYPE_TYPE;
2923 else if (s ==
"object-type")
2924 t = elf_symbol::OBJECT_TYPE;
2925 else if (s ==
"func-type")
2926 t = elf_symbol::FUNC_TYPE;
2927 else if (s ==
"section-type")
2928 t = elf_symbol::SECTION_TYPE;
2929 else if (s ==
"file-type")
2930 t = elf_symbol::FILE_TYPE;
2931 else if (s ==
"common-type")
2932 t = elf_symbol::COMMON_TYPE;
2933 else if (s ==
"tls-type")
2934 t = elf_symbol::TLS_TYPE;
2935 else if (s ==
"gnu-ifunc-type")
2936 t = elf_symbol::GNU_IFUNC_TYPE;
2954 if (s ==
"local-binding")
2955 b = elf_symbol::LOCAL_BINDING;
2956 else if (s ==
"global-binding")
2957 b = elf_symbol::GLOBAL_BINDING;
2958 else if (s ==
"weak-binding")
2959 b = elf_symbol::WEAK_BINDING;
2960 else if (s ==
"gnu-unique-binding")
2961 b = elf_symbol::GNU_UNIQUE_BINDING;
2979 if (s ==
"default-visibility")
2980 v = elf_symbol::DEFAULT_VISIBILITY;
2981 else if (s ==
"protected-visibility")
2982 v = elf_symbol::PROTECTED_VISIBILITY;
2983 else if (s ==
"hidden-visibility")
2984 v = elf_symbol::HIDDEN_VISIBILITY;
2985 else if (s ==
"internal-visibility")
2986 v = elf_symbol::INTERNAL_VISIBILITY;
3001{
return t == elf_symbol::FUNC_TYPE;}
3011{
return t == elf_symbol::OBJECT_TYPE;}
3015struct elf_symbol::version::priv
3021 : is_default_(false)
3024 priv(
const string& v,
3031elf_symbol::version::version()
3038elf_symbol::version::version(
const string& v,
3040 : priv_(new priv(v, is_default))
3044 : priv_(new priv(v.str(), v.is_default()))
3048elf_symbol::version::~version() =
default;
3053elf_symbol::version::operator
const string&()
const
3054{
return priv_->version_;}
3061{
return priv_->version_;}
3068{priv_->version_ = s;}
3075{
return priv_->is_default_;}
3082{priv_->is_default_ = f;}
3085elf_symbol::version::is_empty()
const
3086{
return str().empty();}
3095{
return str() == o.
str();}
3124struct dm_context_rel::priv
3127 size_t offset_in_bits_;
3130 priv(
bool is_static =
false)
3131 : is_laid_out_(!is_static),
3133 anonymous_data_member_()
3136 priv(
bool is_laid_out,
size_t offset_in_bits)
3137 : is_laid_out_(is_laid_out),
3138 offset_in_bits_(offset_in_bits),
3139 anonymous_data_member_()
3143dm_context_rel::dm_context_rel()
3148dm_context_rel::dm_context_rel(scope_decl* s,
3150 size_t offset_in_bits,
3153 : context_rel(s, a, is_static),
3154 priv_(new priv(is_laid_out, offset_in_bits))
3157dm_context_rel::dm_context_rel(scope_decl* s)
3163dm_context_rel::get_is_laid_out()
const
3164{
return priv_->is_laid_out_;}
3167dm_context_rel::set_is_laid_out(
bool f)
3168{priv_->is_laid_out_ = f;}
3171dm_context_rel::get_offset_in_bits()
const
3172{
return priv_->offset_in_bits_;}
3175dm_context_rel::set_offset_in_bits(
size_t o)
3176{priv_->offset_in_bits_ = o;}
3179dm_context_rel::operator==(
const dm_context_rel& o)
const
3181 if (!context_rel::operator==(o))
3184 return (priv_->is_laid_out_ == o.priv_->is_laid_out_
3185 && priv_->offset_in_bits_ == o.priv_->offset_in_bits_);
3189dm_context_rel::operator!=(
const dm_context_rel& o)
const
3200{
return priv_->anonymous_data_member_;}
3210{priv_->anonymous_data_member_ = anon_dm;}
3212dm_context_rel::~dm_context_rel()
3238{
return priv_->canonical_types_;}
3282 unsigned l1 = 0, l2 = 0, c1 = 0, c2 = 0;
3304 vector<type_base_sptr>& result)
3307 result.push_back(t);
3310 std::stable_sort(result.begin(), result.end(), comp);
3322const type_base_sptr&
3325 if (!priv_->void_type_)
3326 priv_->void_type_.reset(
new type_decl(*
this,
3329 return priv_->void_type_;
3341const type_base_sptr&
3344 if (!priv_->void_pointer_type_)
3347 return priv_->void_pointer_type_;
3360const type_base_sptr&
3363 if (!priv_->variadic_marker_type_)
3364 priv_->variadic_marker_type_.
3367 return priv_->variadic_marker_type_;
3376 static string variadic_parameter_type_name =
"variadic parameter type";
3377 return variadic_parameter_type_name;
3387{
return priv_->canonicalization_is_done_;}
3402 priv_->canonicalization_is_done_ = f;
3403 if (priv_->canonicalization_is_done_)
3414{
return priv_->canonicalization_started_;}
3423{priv_->canonicalization_started_ = f;}
3447{
return priv_->decl_only_class_equals_definition_;}
3472{priv_->decl_only_class_equals_definition_ = f;}
3577{
return const_cast<environment*
>(
this)->priv_->string_pool_.create_string(s);}
3584{
return priv_->config_;}
3594{
return priv_->analyze_exported_interfaces_only_.has_value();}
3607{priv_->analyze_exported_interfaces_only_ = f;}
3620{
return priv_->analyze_exported_interfaces_only_.value_or(
false);}
3622#ifdef WITH_DEBUG_SELF_COMPARISON
3635environment::set_self_comparison_debug_input(
const corpus_sptr& c)
3637 self_comparison_debug_is_on(
true);
3638 if (priv_->first_self_comparison_corpus_.expired())
3639 priv_->first_self_comparison_corpus_ = c;
3640 else if (priv_->second_self_comparison_corpus_.expired()
3641 && c.get() != corpus_sptr(priv_->first_self_comparison_corpus_).get())
3642 priv_->second_self_comparison_corpus_ = c;
3655environment::get_self_comparison_debug_inputs(corpus_sptr& first_corpus,
3656 corpus_sptr& second_corpus)
3658 first_corpus = priv_->first_self_comparison_corpus_.lock();
3659 second_corpus = priv_->second_self_comparison_corpus_.lock();
3666environment::self_comparison_debug_is_on(
bool f)
3667{priv_->self_comparison_debug_on_ = f;}
3674environment::self_comparison_debug_is_on()
const
3675{
return priv_->self_comparison_debug_on_;}
3678#ifdef WITH_DEBUG_TYPE_CANONICALIZATION
3685environment::debug_type_canonicalization_is_on(
bool flag)
3686{priv_->debug_type_canonicalization_ = flag;}
3694environment::debug_type_canonicalization_is_on()
const
3695{
return priv_->debug_type_canonicalization_;}
3703environment::debug_die_canonicalization_is_on(
bool flag)
3704{priv_->debug_die_canonicalization_ = flag;}
3712environment::debug_die_canonicalization_is_on()
const
3713{
return priv_->debug_die_canonicalization_;}
3729const vector<type_base_sptr>*
3756 if (!types ||index >= types->size())
3758 return (*types)[index].get();
3761#ifdef WITH_DEBUG_SELF_COMPARISON
3771const unordered_map<string, uintptr_t>&
3772environment::get_type_id_canonical_type_map()
const
3773{
return priv_->get_type_id_canonical_type_map();}
3784unordered_map<string, uintptr_t>&
3785environment::get_type_id_canonical_type_map()
3786{
return priv_->get_type_id_canonical_type_map();}
3801const unordered_map<uintptr_t, string>&
3802environment::get_pointer_type_id_map()
const
3803{
return priv_->get_pointer_type_id_map();}
3818unordered_map<uintptr_t, string>&
3819environment::get_pointer_type_id_map()
3820{
return priv_->get_pointer_type_id_map();}
3838environment::get_type_id_from_pointer(uintptr_t ptr)
const
3839{
return priv_->get_type_id_from_pointer(ptr);}
3857environment::get_type_id_from_type(
const type_base *t)
const
3858{
return priv_->get_type_id_from_type(t);}
3875environment::get_canonical_type_from_type_id(
const char* type_id)
const
3876{
return priv_->get_canonical_type_from_type_id(type_id);}
3890 (
static_cast<unsigned>(l) |
static_cast<unsigned>(r));
3910 (
static_cast<unsigned>(l) &
static_cast<unsigned>(r));
3931 :priv_(new
priv(e, k))
3947{
return priv_->is_artificial_;}
3959{priv_->is_artificial_ = f;}
3970{
return priv_->kind();}
3990{
return priv_->rtti_;}
3999{
return priv_->rtti_;}
4011 priv_->type_or_decl_ptr_ = t;
4013 priv_->type_or_decl_ptr_ = d;
4036{
return priv_->type_or_decl_ptr_;}
4047{
return priv_->hash_value_;}
4050type_or_decl_base::set_hash_value(
hash_t h)
const
4051{priv_->set_hash_value(h);}
4058{
return priv_->env_;}
4076{priv_->artificial_location_ = l;}
4094{
return priv_->artificial_location_;}
4102 return (priv_->artificial_location_
4103 && priv_->artificial_location_.get_is_artificial());
4134{priv_->translation_unit_ = tu;}
4143{
return priv_->translation_unit_;}
4175 *dr =
dynamic_cast<const decl_base*
>(r);
4184 *tr =
dynamic_cast<const type_base*
>(r);
4229struct decl_base::priv
4231 bool in_pub_sym_tab_;
4258 visibility visibility_;
4259 decl_base_sptr declaration_;
4261 decl_base* naked_definition_of_declaration_;
4262 bool is_declaration_only_;
4266 : in_pub_sym_tab_(false),
4267 is_anonymous_(true),
4269 visibility_(VISIBILITY_DEFAULT),
4270 naked_definition_of_declaration_(),
4271 is_declaration_only_(false)
4274 priv(interned_string name, interned_string linkage_name, visibility vis)
4275 : in_pub_sym_tab_(false),
4278 qualified_name_(name),
4279 linkage_name_(linkage_name),
4281 naked_definition_of_declaration_(),
4282 is_declaration_only_(false)
4284 is_anonymous_ = name_.
empty();
4309 const string& linkage_name,
4312 priv_(new priv(e.intern(name), e.intern(linkage_name), vis))
4336 priv_(new priv(name, linkage_name, vis))
4363{
return priv_->qualified_name_;}
4372{priv_->qualified_name_.
clear();}
4379{priv_->qualified_name_ = n;}
4392{
return priv_->temporary_qualified_name_;}
4406{priv_->temporary_qualified_name_ = n;}
4413{
return priv_->context_;}
4420{
return priv_->context_;}
4424{priv_->context_ = c;}
4433{
return priv_->in_pub_sym_tab_;}
4441{priv_->in_pub_sym_tab_ = f;}
4461{
return priv_->location_;}
4503 priv_->location_ = l;
4513 priv_->is_anonymous_ = n.empty();
4524{
return priv_->is_anonymous_;}
4534{priv_->is_anonymous_ = f;}
4571{
return priv_->naming_typedef_;}
4599 &&
is_type(
this)->get_naked_canonical_type() ==
nullptr);
4601 priv_->naming_typedef_ = t;
4608 update_qualified_name(
this);
4616{
return priv_->linkage_name_;}
4625 priv_->linkage_name_ = env.
intern(m);
4633{
return priv_->visibility_;}
4640{priv_->visibility_ = v;}
4649 if (priv_->context_)
4650 return priv_->context_->get_scope();
4660{
return priv_->qualified_parent_name_;}
4667{
return priv_->name_;}
4702 bool qualified_name)
const
4706 && has_generic_anonymous_internal_type_name(
this))
4717 string name = get_generic_anonymous_internal_type_name(
this);
4753 if (priv_->internal_cached_repr_.
empty())
4758 return priv_->internal_cached_repr_;
4761 if (priv_->cached_repr_.
empty())
4767 return priv_->cached_repr_;
4787{
return priv_->qualified_name_;}
4801{
return priv_->scoped_name_;}
4809{
return priv_->declaration_;}
4818 if (d && d->get_is_declaration_only())
4819 priv_->declaration_ = d;
4829{
return priv_->definition_of_declaration_.lock();}
4845{
return priv_->naked_definition_of_declaration_;}
4852{
return priv_->is_declaration_only_;}
4862 bool update_types_lookup_map = !f && priv_->is_declaration_only_;
4864 priv_->is_declaration_only_ = f;
4866 if (update_types_lookup_map)
4869 scope_decl::declarations::iterator i;
4870 if (s->find_iterator_for_member(
this, i))
4880 return static_cast<change_kind>(
static_cast<unsigned>(l)
4881 |
static_cast<unsigned>(r));
4887 return static_cast<change_kind>(
static_cast<unsigned>(l)
4888 &
static_cast<unsigned>(r));
4935 bool member_types_or_functions =
4939 if (member_types_or_functions)
4948 la = r1->get_access_specifier();
4949 ra = r2->get_access_specifier();
4950 r1->set_access_specifier(no_access);
4951 r2->set_access_specifier(no_access);
4954 bool rels_are_different = *r1 != *r2;
4956 if (member_types_or_functions)
4959 r1->set_access_specifier(la);
4960 r2->set_access_specifier(ra);
4963 if (rels_are_different)
4998 if (!l_linkage_name.
empty() && !r_linkage_name.
empty())
5000 if (l_linkage_name != r_linkage_name)
5040 bool decls_are_same = (ln == rn);
5042 if (!decls_are_same)
5065{
return equals(*
this, other, 0);}
5104 if (!priv_->context_)
5107 priv_->context_->set_scope(scope);
5125 case decl_base::VISIBILITY_NONE:
5128 case decl_base::VISIBILITY_DEFAULT:
5131 case decl_base::VISIBILITY_PROTECTED:
5134 case decl_base::VISIBILITY_HIDDEN:
5137 case decl_base::VISIBILITY_INTERNAL:
5157 case decl_base::BINDING_NONE:
5160 case decl_base::BINDING_LOCAL:
5163 case decl_base::BINDING_GLOBAL:
5166 case decl_base::BINDING_WEAK:
5189 if (l.get() == r.get())
5225 if (l.get() == r.get())
5311{
return dynamic_pointer_cast<scope_decl>(d);}
5377 return c->get_access_specifier();
5407 c->set_access_specifier(a);
5437 return c->get_is_static();
5579 var_decl_sptr first = *klass->get_non_static_data_members().begin();
5600 if (!klass ||!data_member)
5603 for (class_or_union::data_members::const_iterator it =
5607 if (**it == *data_member)
5676 bool result =
false;
5694 dms[member->get_name()] = member;