20#include <unordered_map>
24#include "abg-internal.h"
26ABG_BEGIN_EXPORT_DECLARATIONS
33ABG_END_EXPORT_DECLARATIONS
50 do_update(abigail::ir::decl_base* d);
53 visit_begin(abigail::ir::decl_base* d);
56 visit_begin(abigail::ir::type_base* d);
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())
464 get_location_manager()->expand_location(*
this, path, line, column);
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
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
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;
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
1237 (
new global_scope(
const_cast<translation_unit*
>(
this)));
1238 priv_->global_scope_->set_translation_unit
1239 (
const_cast<translation_unit*
>(
this));
1241 return priv_->global_scope_;
1249{
return priv_->types_;}
1256{
return priv_->types_;}
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;}
1385{
return const_cast<translation_unit*
>(
this)->
get_corpus();}
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);
1511 if (
const translation_unit* existing_tu = ftype->get_translation_unit())
1514 ftype->set_translation_unit(
const_cast<translation_unit*
>(
this));
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_C17:
1558 case translation_unit::LANG_C23:
1560 case translation_unit::LANG_C:
1562 case translation_unit::LANG_C_plus_plus_03:
1563 return "LANG_C_plus_plus_03";
1564 case translation_unit::LANG_C_plus_plus_11:
1565 return "LANG_C_plus_plus_11";
1566 case translation_unit::LANG_C_plus_plus_14:
1567 return "LANG_C_plus_plus_14";
1568 case translation_unit::LANG_C_plus_plus_17:
1569 return "LANG_C_plus_plus_17";
1570 case translation_unit::LANG_C_plus_plus_20:
1571 return "LANG_C_plus_plus_20";
1572 case translation_unit::LANG_C_plus_plus_23:
1573 return "LANG_C_plus_plus_23";
1574 case translation_unit::LANG_C_plus_plus:
1575 return "LANG_C_plus_plus";
1576 case translation_unit::LANG_OCaml:
1577 return "LANG_OCaml";
1578 case translation_unit::LANG_Zig:
1580 case translation_unit::LANG_ObjC:
1582 case translation_unit::LANG_ObjC_plus_plus:
1583 return "LANG_ObjC_plus_plus";
1584 case translation_unit::LANG_D:
1586 case translation_unit::LANG_Go:
1588 case translation_unit::LANG_Rust:
1590 case translation_unit::LANG_Fortran77:
1591 return "LANG_Fortran77";
1592 case translation_unit::LANG_Fortran90:
1593 return "LANG_Fortran90";
1594 case translation_unit::LANG_Fortran95:
1595 return "LANG_Fortran95";
1596 case translation_unit::LANG_Fortran18:
1597 return "LANG_Fortran18";
1598 case translation_unit::LANG_Fortran23:
1599 return "LANG_Fortran23";
1600 case translation_unit::LANG_Ada83:
1601 return "LANG_Ada83";
1602 case translation_unit::LANG_Ada95:
1603 return "LANG_Ada95";
1604 case translation_unit::LANG_Ada2005:
1605 return "LANG_Ada2005";
1606 case translation_unit::LANG_Ada2012:
1607 return "LANG_Ada2012";
1608 case translation_unit::LANG_Pascal83:
1609 return "LANG_Pascal83";
1610 case translation_unit::LANG_Modula2:
1611 return "LANG_Modula2";
1612 case translation_unit::LANG_Java:
1614 case translation_unit::LANG_Kotlin:
1615 return "LANG_Kotlin";
1616 case translation_unit::LANG_C_sharp:
1617 return "LANG_C_sharp";
1618 case translation_unit::LANG_Python:
1619 return "LANG_Python";
1620 case translation_unit::LANG_Ruby:
1622 case translation_unit::LANG_PLI:
1624 case translation_unit::LANG_UPC:
1626 case translation_unit::LANG_Mips_Assembler:
1627 return "LANG_Mips_Assembler";
1628 case translation_unit::LANG_Assembly:
1629 return "LANG_Assembly";
1630 case translation_unit::LANG_Crystal:
1631 return "LANG_Crystal";
1632 case translation_unit::LANG_HIP:
1634 case translation_unit::LANG_Mojo:
1636 case translation_unit::LANG_GLSL:
1638 case translation_unit::LANG_GLSL_ES:
1639 return "LANG_GLSL_ES";
1640 case translation_unit::LANG_HLSL:
1642 case translation_unit::LANG_OpenCL_CPP:
1643 return "LANG_OpenCL_CPP";
1644 case translation_unit::LANG_CPP_for_OpenCL:
1645 return "LANG_CPP_for_OpenCL";
1646 case translation_unit::LANG_SYCL:
1648 case translation_unit::LANG_Odin:
1650 case translation_unit::LANG_P4:
1652 case translation_unit::LANG_Metal:
1653 return "LANG_Metal";
1654 case translation_unit::LANG_Move:
1656 case translation_unit::LANG_Hylo:
1660 return "LANG_UNKNOWN";
1672 if (l ==
"LANG_Cobol74")
1673 return translation_unit::LANG_Cobol74;
1674 else if (l ==
"LANG_Cobol85")
1675 return translation_unit::LANG_Cobol85;
1676 else if (l ==
"LANG_C89")
1677 return translation_unit::LANG_C89;
1678 else if (l ==
"LANG_C99")
1679 return translation_unit::LANG_C99;
1680 else if (l ==
"LANG_C11")
1681 return translation_unit::LANG_C11;
1682 else if (l ==
"LANG_C17")
1683 return translation_unit::LANG_C17;
1684 else if (l ==
"LANG_C23")
1685 return translation_unit::LANG_C23;
1686 else if (l ==
"LANG_C")
1687 return translation_unit::LANG_C;
1688 else if (l ==
"LANG_C_plus_plus_03")
1689 return translation_unit::LANG_C_plus_plus_03;
1690 else if (l ==
"LANG_C_plus_plus_11")
1691 return translation_unit::LANG_C_plus_plus_11;
1692 else if (l ==
"LANG_C_plus_plus_14")
1693 return translation_unit::LANG_C_plus_plus_14;
1694 else if (l ==
"LANG_C_plus_plus_17")
1695 return translation_unit::LANG_C_plus_plus_17;
1696 else if (l ==
"LANG_C_plus_plus_20")
1697 return translation_unit::LANG_C_plus_plus_20;
1698 else if (l ==
"LANG_C_plus_plus_23")
1699 return translation_unit::LANG_C_plus_plus_23;
1700 else if (l ==
"LANG_C_plus_plus")
1701 return translation_unit::LANG_C_plus_plus;
1702 else if (l ==
"LANG_OCaml")
1703 return translation_unit::LANG_OCaml;
1704 else if (l ==
"LANG_ObjC")
1705 return translation_unit::LANG_ObjC;
1706 else if (l ==
"LANG_ObjC_plus_plus")
1707 return translation_unit::LANG_ObjC_plus_plus;
1708 else if (l ==
"LANG_Zig")
1709 return translation_unit::LANG_Zig;
1710 else if (l ==
"LANG_Metal")
1711 return translation_unit::LANG_Metal;
1712 else if (l ==
"LANG_Fortran77")
1713 return translation_unit::LANG_Fortran77;
1714 else if (l ==
"LANG_Fortran90")
1715 return translation_unit::LANG_Fortran90;
1716 else if (l ==
"LANG_Fortran95")
1717 return translation_unit::LANG_Fortran95;
1718 else if (l ==
"LANG_Fortran18")
1719 return translation_unit::LANG_Fortran23;
1720 else if (l ==
"LANG_Ada83")
1721 return translation_unit::LANG_Ada83;
1722 else if (l ==
"LANG_Ada95")
1723 return translation_unit::LANG_Ada95;
1724 else if (l ==
"LANG_Ada2005")
1725 return translation_unit::LANG_Ada2005;
1726 else if (l ==
"LANG_Ada2012")
1727 return translation_unit::LANG_Ada2012;
1728 else if (l ==
"LANG_Pascal83")
1729 return translation_unit::LANG_Pascal83;
1730 else if (l ==
"LANG_Modula2")
1731 return translation_unit::LANG_Modula2;
1732 else if (l ==
"LANG_Java")
1733 return translation_unit::LANG_Java;
1734 else if (l ==
"LANG_Kotlin")
1735 return translation_unit::LANG_Kotlin;
1736 else if (l ==
"LANG_PLI")
1737 return translation_unit::LANG_PLI;
1738 else if (l ==
"LANG_UPC")
1739 return translation_unit::LANG_UPC;
1740 else if (l ==
"LANG_D")
1741 return translation_unit::LANG_D;
1742 else if (l ==
"LANG_Go")
1743 return translation_unit::LANG_Go;
1744 else if (l ==
"LANG_Rust")
1745 return translation_unit::LANG_Rust;
1746 else if (l ==
"LANG_Python")
1747 return translation_unit::LANG_Python;
1748 else if (l ==
"LANG_Ruby")
1749 return translation_unit::LANG_Ruby;
1750 else if (l ==
"LANG_Mips_Assembler")
1751 return translation_unit::LANG_Mips_Assembler;
1752 else if (l ==
"LANG_Assembly")
1753 return translation_unit::LANG_Assembly;
1754 else if (l ==
"LANG_Crystal")
1755 return translation_unit::LANG_Crystal;
1756 else if (l ==
"LANG_HIP")
1757 return translation_unit::LANG_HIP;
1758 else if (l ==
"LANG_C_sharp")
1759 return translation_unit::LANG_C_sharp;
1760 else if (l ==
"LANG_Mojo")
1761 return translation_unit::LANG_Mojo;
1762 else if (l ==
"LANG_GLSL")
1763 return translation_unit::LANG_GLSL;
1764 else if (l ==
"LANG_GLSL_ES")
1765 return translation_unit::LANG_GLSL_ES;
1766 else if (l ==
"LANG_HLSL")
1767 return translation_unit::LANG_HLSL;
1768 else if (l ==
"LANG_OpenCL_CPP")
1769 return translation_unit::LANG_OpenCL_CPP;
1770 else if (l ==
"LANG_CPP_for_OpenCL")
1771 return translation_unit::LANG_CPP_for_OpenCL;
1772 else if (l ==
"LANG_SYCL")
1773 return translation_unit::LANG_SYCL;
1774 else if (l ==
"LANG_Odin")
1775 return translation_unit::LANG_Odin;
1776 else if (l ==
"LANG_P4")
1777 return translation_unit::LANG_P4;
1778 else if (l ==
"LANG_Move")
1779 return translation_unit::LANG_Move;
1780 else if (l ==
"LANG_Hylo")
1781 return translation_unit::LANG_Hylo;
1783 return translation_unit::LANG_UNKNOWN;
1794 return (l == translation_unit::LANG_C89
1795 || l == translation_unit::LANG_C99
1796 || l == translation_unit::LANG_C11
1797 || l == translation_unit::LANG_C17
1798 || l == translation_unit::LANG_C23
1799 || l == translation_unit::LANG_C);
1810 return (l == translation_unit::LANG_C_plus_plus_03
1811 || l == translation_unit::LANG_C_plus_plus_11
1812 || l == translation_unit::LANG_C_plus_plus_14
1813 || l == translation_unit::LANG_C_plus_plus_20
1814 || l == translation_unit::LANG_C_plus_plus_23
1815 || l == translation_unit::LANG_C_plus_plus);
1825{
return l == translation_unit::LANG_Java;}
1835 return (l == translation_unit::LANG_Ada83
1836 || l == translation_unit::LANG_Ada95
1837 || l == translation_unit::LANG_Ada2005
1838 || l == translation_unit::LANG_Ada2012);
1851 if (l.get() == r.get())
1874struct elf_symbol::priv
1914 bool is_in_ksymtab_;
1917 bool is_suppressed_;
1932 is_in_ksymtab_(false),
1935 is_suppressed_(false)
1938 priv(
const environment& e,
1946 const elf_symbol::version& ve,
1968 is_common_ = type_ == COMMON_TYPE;
2013 const abg_compat::optional<uint32_t>& crc,
2014 const abg_compat::optional<std::string>& ns,
2078 elf_symbol_sptr sym(
new elf_symbol(e, i, s, n, t, b, d, c, ve, vi,
2080 sym->priv_->main_symbol_ = sym;
2139{
return priv_->env_;}
2146{
return priv_->index_;}
2160{
return priv_->name_;}
2169 priv_->id_string_.clear();
2177{
return priv_->type_;}
2191{
return priv_->size_;}
2198{priv_->size_ = size;}
2205{
return priv_->binding_;}
2212{priv_->binding_ = b;}
2219{
return priv_->version_;}
2227 priv_->version_ = v;
2228 priv_->id_string_.clear();
2237{priv_->visibility_ = v;}
2245{
return priv_->visibility_;}
2253{
return priv_->is_defined_;}
2261{priv_->is_defined_ = d;}
2314{
return priv_->is_in_ksymtab_;}
2329{
return priv_->crc_;}
2343{
return priv_->namespace_;}
2350{priv_->namespace_ = ns;}
2359{
return priv_->is_suppressed_;}
2398{
return priv_->main_symbol_.lock();}
2405{
return priv_->main_symbol_.lock();}
2419{
return priv_->next_alias_.lock();}
2439 a = a->get_next_alias())
2462 a && !a->is_main_symbol();
2463 a = a->get_next_alias())
2465 if (a->get_next_alias()->is_main_symbol())
2473 last_alias->priv_->next_alias_ = alias;
2476 priv_->next_alias_ = alias;
2506 a = a->get_next_alias())
2507 if (a->get_name() == name)
2517 priv_->main_symbol_ = new_main;
2519 a = a->get_next_alias())
2520 a->priv_->main_symbol_ = new_main;
2530{
return priv_->is_common_;}
2561{
return priv_->next_common_instance_.lock();}
2576 ABG_ASSERT(!common->has_other_common_instances());
2585 c = c->get_next_common_instance())
2590 last_common_instance = c;
2595 last_common_instance->priv_->next_common_instance_ = common;
2598 priv_->next_common_instance_ = common;
2618 if (priv_->id_string_.empty())
2630 priv_->id_string_ = s;
2633 return priv_->id_string_;
2650 a = a->get_next_alias())
2651 if (a->get_name() == name)
2668 a && a.get() != a->get_main_symbol().get();
2669 a = a->get_next_alias())
2670 if (textually_equals(*
this, *a))
2687 bool include_symbol_itself)
const
2691 if (include_symbol_itself)
2695 compute_aliases_for_elf_symbol(*
this, syms, aliases);
2696 if (!aliases.empty() && include_symbol_itself)
2703 if (i != aliases.begin())
2705 result += (*i)->get_id_string();
2721 if (include_symbol_itself)
2726 a = a->get_next_alias())
2727 aliases.push_back(a);
2734 if (i != aliases.begin())
2736 result += (*i)->get_id_string();
2756 name.clear(), ver.clear();
2758 string::size_type i =
id.find(
'@');
2759 if (i == string::npos)
2765 name =
id.substr(0, i);
2771 string::size_type j =
id.find(
'@', i);
2772 if (j == string::npos)
2799 bool are_equal = textually_equals(*
this, other);
2820 a && !a->is_main_symbol();
2821 a = a->get_next_alias())
2845 return *lhs == *rhs;
2871compute_aliases_for_elf_symbol(
const elf_symbol& sym,
2877 for (; a && !a->is_main_symbol(); a = a->get_next_alias())
2878 aliases.push_back(a);
2880 for (string_elf_symbols_map_type::const_iterator i = symtab.begin();
2883 for (elf_symbols::const_iterator j = i->second.begin();
2884 j != i->second.end();
2889 s && !s->is_main_symbol();
2890 s = s->get_next_alias())
2891 aliases.push_back(s);
2894 s && !s->is_main_symbol();
2895 s = s->get_next_alias())
2897 aliases.push_back(*j);
2942 case elf_symbol::NOTYPE_TYPE:
2943 repr =
"unspecified symbol type";
2945 case elf_symbol::OBJECT_TYPE:
2946 repr =
"variable symbol type";
2948 case elf_symbol::FUNC_TYPE:
2949 repr =
"function symbol type";
2951 case elf_symbol::SECTION_TYPE:
2952 repr =
"section symbol type";
2954 case elf_symbol::FILE_TYPE:
2955 repr =
"file symbol type";
2957 case elf_symbol::COMMON_TYPE:
2958 repr =
"common data object symbol type";
2960 case elf_symbol::TLS_TYPE:
2961 repr =
"thread local data object symbol type";
2963 case elf_symbol::GNU_IFUNC_TYPE:
2964 repr =
"indirect function symbol type";
2968 std::ostringstream s;
2969 s <<
"unknown symbol type (" << (char)t <<
')';
2992 case elf_symbol::LOCAL_BINDING:
2993 repr =
"local binding";
2995 case elf_symbol::GLOBAL_BINDING:
2996 repr =
"global binding";
2998 case elf_symbol::WEAK_BINDING:
2999 repr =
"weak binding";
3001 case elf_symbol::GNU_UNIQUE_BINDING:
3002 repr =
"GNU unique binding";
3006 std::ostringstream s;
3007 s <<
"unknown binding (" << (
unsigned char) b <<
")";
3030 case elf_symbol::DEFAULT_VISIBILITY:
3031 repr =
"default visibility";
3033 case elf_symbol::PROTECTED_VISIBILITY:
3034 repr =
"protected visibility";
3036 case elf_symbol::HIDDEN_VISIBILITY:
3037 repr =
"hidden visibility";
3039 case elf_symbol::INTERNAL_VISIBILITY:
3040 repr =
"internal visibility";
3044 std::ostringstream s;
3045 s <<
"unknown visibility (" << (
unsigned char) v <<
")";
3067 t = elf_symbol::NOTYPE_TYPE;
3068 else if (s ==
"object-type")
3069 t = elf_symbol::OBJECT_TYPE;
3070 else if (s ==
"func-type")
3071 t = elf_symbol::FUNC_TYPE;
3072 else if (s ==
"section-type")
3073 t = elf_symbol::SECTION_TYPE;
3074 else if (s ==
"file-type")
3075 t = elf_symbol::FILE_TYPE;
3076 else if (s ==
"common-type")
3077 t = elf_symbol::COMMON_TYPE;
3078 else if (s ==
"tls-type")
3079 t = elf_symbol::TLS_TYPE;
3080 else if (s ==
"gnu-ifunc-type")
3081 t = elf_symbol::GNU_IFUNC_TYPE;
3099 if (s ==
"local-binding")
3100 b = elf_symbol::LOCAL_BINDING;
3101 else if (s ==
"global-binding")
3102 b = elf_symbol::GLOBAL_BINDING;
3103 else if (s ==
"weak-binding")
3104 b = elf_symbol::WEAK_BINDING;
3105 else if (s ==
"gnu-unique-binding")
3106 b = elf_symbol::GNU_UNIQUE_BINDING;
3124 if (s ==
"default-visibility")
3125 v = elf_symbol::DEFAULT_VISIBILITY;
3126 else if (s ==
"protected-visibility")
3127 v = elf_symbol::PROTECTED_VISIBILITY;
3128 else if (s ==
"hidden-visibility")
3129 v = elf_symbol::HIDDEN_VISIBILITY;
3130 else if (s ==
"internal-visibility")
3131 v = elf_symbol::INTERNAL_VISIBILITY;
3146{
return t == elf_symbol::FUNC_TYPE;}
3156{
return t == elf_symbol::OBJECT_TYPE;}
3160struct elf_symbol::version::priv
3166 : is_default_(false)
3169 priv(
const string& v,
3176elf_symbol::version::version()
3183elf_symbol::version::version(
const string& v,
3189 : priv_(new priv(v.str(), v.is_default()))
3193elf_symbol::version::~version() =
default;
3198elf_symbol::version::operator
const string&()
const
3199{
return priv_->version_;}
3206{
return priv_->version_;}
3213{priv_->version_ = s;}
3220{
return priv_->is_default_;}
3227{priv_->is_default_ = f;}
3230elf_symbol::version::is_empty()
const
3231{
return str().empty();}
3240{
return str() == o.
str();}
3269struct dm_context_rel::priv
3272 size_t offset_in_bits_;
3275 priv(
bool is_static =
false)
3276 : is_laid_out_(!is_static),
3278 anonymous_data_member_()
3281 priv(
bool is_laid_out,
size_t offset_in_bits)
3282 : is_laid_out_(is_laid_out),
3283 offset_in_bits_(offset_in_bits),
3284 anonymous_data_member_()
3288dm_context_rel::dm_context_rel()
3293dm_context_rel::dm_context_rel(scope_decl* s,
3295 size_t offset_in_bits,
3298 : context_rel(s, a, is_static),
3299 priv_(new priv(is_laid_out, offset_in_bits))
3302dm_context_rel::dm_context_rel(scope_decl* s)
3308dm_context_rel::get_is_laid_out()
const
3309{
return priv_->is_laid_out_;}
3312dm_context_rel::set_is_laid_out(
bool f)
3313{priv_->is_laid_out_ = f;}
3316dm_context_rel::get_offset_in_bits()
const
3317{
return priv_->offset_in_bits_;}
3320dm_context_rel::set_offset_in_bits(
size_t o)
3321{priv_->offset_in_bits_ = o;}
3324dm_context_rel::operator==(
const dm_context_rel& o)
const
3326 if (!context_rel::operator==(o))
3329 return (priv_->is_laid_out_ == o.priv_->is_laid_out_
3330 && priv_->offset_in_bits_ == o.priv_->offset_in_bits_);
3334dm_context_rel::operator!=(
const dm_context_rel& o)
const
3345{
return priv_->anonymous_data_member_;}
3355{priv_->anonymous_data_member_ = anon_dm;}
3357dm_context_rel::~dm_context_rel()
3383{
return priv_->canonical_types_;}
3427 unsigned l1 = 0, l2 = 0, c1 = 0, c2 = 0;
3452 result.push_back(t);
3455 std::stable_sort(result.begin(), result.end(), comp);
3467const type_base_sptr&
3470 if (!priv_->void_type_)
3471 priv_->void_type_.reset(
new type_decl(*
this,
3474 return priv_->void_type_;
3486const type_base_sptr&
3489 if (!priv_->void_pointer_type_)
3492 return priv_->void_pointer_type_;
3505const type_base_sptr&
3508 if (!priv_->variadic_marker_type_)
3509 priv_->variadic_marker_type_.
3512 return priv_->variadic_marker_type_;
3521 static string variadic_parameter_type_name =
"variadic parameter type";
3522 return variadic_parameter_type_name;
3532{
return priv_->canonicalization_is_done_;}
3547 priv_->canonicalization_is_done_ = f;
3548 if (priv_->canonicalization_is_done_)
3559{
return priv_->canonicalization_started_;}
3568{priv_->canonicalization_started_ = f;}
3592{
return priv_->decl_only_class_equals_definition_;}
3617{priv_->decl_only_class_equals_definition_ = f;}
3722{
return const_cast<environment*
>(
this)->priv_->string_pool_.create_string(s);}
3729{
return priv_->config_;}
3739{
return priv_->analyze_exported_interfaces_only_.has_value();}
3752{priv_->analyze_exported_interfaces_only_ = f;}
3765{
return priv_->analyze_exported_interfaces_only_.value_or(
false);}
3767#ifdef WITH_DEBUG_SELF_COMPARISON
3780environment::set_self_comparison_debug_input(
const corpus_sptr& c)
3782 self_comparison_debug_is_on(
true);
3783 if (priv_->first_self_comparison_corpus_.expired())
3784 priv_->first_self_comparison_corpus_ = c;
3785 else if (priv_->second_self_comparison_corpus_.expired()
3786 && c.get() != corpus_sptr(priv_->first_self_comparison_corpus_).get())
3787 priv_->second_self_comparison_corpus_ = c;
3800environment::get_self_comparison_debug_inputs(corpus_sptr& first_corpus,
3801 corpus_sptr& second_corpus)
3803 first_corpus = priv_->first_self_comparison_corpus_.lock();
3804 second_corpus = priv_->second_self_comparison_corpus_.lock();
3811environment::self_comparison_debug_is_on(
bool f)
3812{priv_->self_comparison_debug_on_ = f;}
3819environment::self_comparison_debug_is_on()
const
3820{
return priv_->self_comparison_debug_on_;}
3823#ifdef WITH_DEBUG_TYPE_CANONICALIZATION
3830environment::debug_type_canonicalization_is_on(
bool flag)
3831{priv_->debug_type_canonicalization_ = flag;}
3839environment::debug_type_canonicalization_is_on()
const
3840{
return priv_->debug_type_canonicalization_;}
3848environment::debug_die_canonicalization_is_on(
bool flag)
3849{priv_->debug_die_canonicalization_ = flag;}
3857environment::debug_die_canonicalization_is_on()
const
3858{
return priv_->debug_die_canonicalization_;}
3901 if (!types ||index >= types->size())
3903 return (*types)[index].get();
3906#ifdef WITH_DEBUG_SELF_COMPARISON
3916const unordered_map<string, uintptr_t>&
3917environment::get_type_id_canonical_type_map()
const
3918{
return priv_->get_type_id_canonical_type_map();}
3929unordered_map<string, uintptr_t>&
3930environment::get_type_id_canonical_type_map()
3931{
return priv_->get_type_id_canonical_type_map();}
3946const unordered_map<uintptr_t, string>&
3947environment::get_pointer_type_id_map()
const
3948{
return priv_->get_pointer_type_id_map();}
3963unordered_map<uintptr_t, string>&
3964environment::get_pointer_type_id_map()
3965{
return priv_->get_pointer_type_id_map();}
3983environment::get_type_id_from_pointer(uintptr_t ptr)
const
3984{
return priv_->get_type_id_from_pointer(ptr);}
4002environment::get_type_id_from_type(
const type_base *t)
const
4003{
return priv_->get_type_id_from_type(t);}
4020environment::get_canonical_type_from_type_id(
const char* type_id)
const
4021{
return priv_->get_canonical_type_from_type_id(type_id);}
4035 (
static_cast<unsigned>(l) |
static_cast<unsigned>(r));
4055 (
static_cast<unsigned>(l) &
static_cast<unsigned>(r));
4076 :priv_(new
priv(e, k))
4092{
return priv_->is_artificial_;}
4104{priv_->is_artificial_ = f;}
4115{
return priv_->kind();}
4135{
return priv_->rtti_;}
4144{
return priv_->rtti_;}
4156 priv_->type_or_decl_ptr_ = t;
4158 priv_->type_or_decl_ptr_ = d;
4181{
return priv_->type_or_decl_ptr_;}
4192{
return priv_->hash_value_;}
4195type_or_decl_base::set_hash_value(
hash_t h)
const
4196{priv_->set_hash_value(h);}
4203{
return priv_->env_;}
4221{priv_->artificial_location_ = l;}
4239{
return priv_->artificial_location_;}
4247 return (priv_->artificial_location_
4248 && priv_->artificial_location_.get_is_artificial());
4271{
return const_cast<type_or_decl_base*
>(
this)->
get_corpus();}
4279{priv_->translation_unit_ = tu;}
4288{
return priv_->translation_unit_;}
4320 *dr =
dynamic_cast<const decl_base*
>(r);
4329 *tr =
dynamic_cast<const type_base*
>(r);
4374struct decl_base::priv
4376 bool in_pub_sym_tab_;
4403 visibility visibility_;
4404 decl_base_sptr declaration_;
4406 decl_base* naked_definition_of_declaration_;
4407 bool is_declaration_only_;
4411 : in_pub_sym_tab_(false),
4412 is_anonymous_(true),
4414 visibility_(VISIBILITY_DEFAULT),
4415 naked_definition_of_declaration_(),
4416 is_declaration_only_(false)
4419 priv(interned_string name, interned_string linkage_name, visibility vis)
4420 : in_pub_sym_tab_(false),
4423 qualified_name_(name),
4424 linkage_name_(linkage_name),
4426 naked_definition_of_declaration_(),
4427 is_declaration_only_(false)
4429 is_anonymous_ = name_.
empty();
4454 const string& linkage_name,
4456 : type_or_decl_base(e, ABSTRACT_DECL_BASE),
4457 priv_(new priv(e.intern(name), e.intern(linkage_name), vis))
4480 : type_or_decl_base(e, ABSTRACT_DECL_BASE),
4481 priv_(new priv(name, linkage_name, vis))
4494 : type_or_decl_base(e, ABSTRACT_DECL_BASE),
4508{
return priv_->qualified_name_;}
4517{priv_->qualified_name_.
clear();}
4524{priv_->qualified_name_ = n;}
4537{
return priv_->temporary_qualified_name_;}
4551{priv_->temporary_qualified_name_ = n;}
4558{
return priv_->context_;}
4565{
return priv_->context_;}
4569{priv_->context_ = c;}
4578{
return priv_->in_pub_sym_tab_;}
4586{priv_->in_pub_sym_tab_ = f;}
4606{
return priv_->location_;}
4648 priv_->location_ = l;
4658 priv_->is_anonymous_ = n.empty();
4669{
return priv_->is_anonymous_;}
4679{priv_->is_anonymous_ = f;}
4716{
return priv_->naming_typedef_;}
4744 &&
is_type(
this)->get_naked_canonical_type() ==
nullptr);
4746 priv_->naming_typedef_ = t;
4753 update_qualified_name(
this);
4761{
return priv_->linkage_name_;}
4770 priv_->linkage_name_ = env.
intern(m);
4778{
return priv_->visibility_;}
4785{priv_->visibility_ = v;}
4794 if (priv_->context_)
4805{
return priv_->qualified_parent_name_;}
4812{
return priv_->name_;}
4847 bool qualified_name)
const
4851 && has_generic_anonymous_internal_type_name(
this))
4862 string name = get_generic_anonymous_internal_type_name(
this);
4898 if (priv_->internal_cached_repr_.empty())
4903 return priv_->internal_cached_repr_;
4906 if (priv_->cached_repr_.empty())
4912 return priv_->cached_repr_;
4932{
return priv_->qualified_name_;}
4946{
return priv_->scoped_name_;}
4954{
return priv_->declaration_;}
4963 if (d && d->get_is_declaration_only())
4964 priv_->declaration_ = d;
4974{
return priv_->definition_of_declaration_.lock();}
4990{
return priv_->naked_definition_of_declaration_;}
4997{
return priv_->is_declaration_only_;}
5007 bool update_types_lookup_map = !f && priv_->is_declaration_only_;
5009 priv_->is_declaration_only_ = f;
5011 if (update_types_lookup_map)
5014 scope_decl::declarations::iterator i;
5015 if (s->find_iterator_for_member(
this, i))
5025 return static_cast<change_kind>(
static_cast<unsigned>(l)
5026 |
static_cast<unsigned>(r));
5032 return static_cast<change_kind>(
static_cast<unsigned>(l)
5033 &
static_cast<unsigned>(r));
5080 bool member_types_or_functions =
5084 if (member_types_or_functions)
5093 la = r1->get_access_specifier();
5094 ra = r2->get_access_specifier();
5095 r1->set_access_specifier(no_access);
5096 r2->set_access_specifier(no_access);
5099 bool rels_are_different = *r1 != *r2;
5101 if (member_types_or_functions)
5104 r1->set_access_specifier(la);
5105 r2->set_access_specifier(ra);
5108 if (rels_are_different)
5143 if (!l_linkage_name.
empty() && !r_linkage_name.
empty())
5145 if (l_linkage_name != r_linkage_name)
5185 bool decls_are_same = (ln == rn);
5187 if (!decls_are_same)
5210{
return equals(*
this, other, 0);}
5249 if (!priv_->context_)
5252 priv_->context_->set_scope(scope);
5270 case decl_base::VISIBILITY_NONE:
5273 case decl_base::VISIBILITY_DEFAULT:
5276 case decl_base::VISIBILITY_PROTECTED:
5279 case decl_base::VISIBILITY_HIDDEN:
5282 case decl_base::VISIBILITY_INTERNAL:
5302 case decl_base::BINDING_NONE:
5305 case decl_base::BINDING_LOCAL:
5308 case decl_base::BINDING_GLOBAL:
5311 case decl_base::BINDING_WEAK:
5334 if (l.get() == r.get())
5370 if (l.get() == r.get())
5456{
return dynamic_pointer_cast<scope_decl>(d);}
5522 return c->get_access_specifier();
5552 c->set_access_specifier(a);
5582 return c->get_is_static();
5724 var_decl_sptr first = *klass->get_non_static_data_members().begin();
5745 if (!klass ||!data_member)
5748 for (class_or_union::data_members::const_iterator it =
5752 if (**it == *data_member)
5821 bool result =
false;
5839 dms[member->get_name()] = member;
6048 return class_or_union_sptr();
6057const class_or_union_sptr
6062 if (cou->get_is_anonymous())
6065 return class_or_union_sptr();
6074const class_or_union_sptr
6079 return class_or_union_sptr();
6088const class_or_union_sptr
6103 return class_or_union_sptr();
6128 for (
auto anon_dm_m : cl->get_non_static_data_members())
6175 ctxt_rel->set_offset_in_bits(o);
6190 return ctxt_rel->get_offset_in_bits();
6280 const var_decl *containing_anonymous_data_member =
6283 uint64_t containing_anonymous_data_member_offset = 0;
6284 if (containing_anonymous_data_member)
6285 containing_anonymous_data_member_offset =
6288 return (ctxt_rel->get_offset_in_bits()
6290 containing_anonymous_data_member_offset);
6318 type_base_sptr t = v->get_type();
6321 return t->get_size_in_bits();
6335 ctxt_rel->set_is_laid_out(l);
6350 return ctxt_rel->get_is_laid_out();
6582 const method_decl* m =
6583 dynamic_cast<const method_decl*
>(&f);
6611set_member_function_vtable_offset(
function_decl& f, ssize_t s)
6633{
return set_member_function_vtable_offset(*f, s);}
6652 return ctxt->is_virtual();
6679set_member_function_is_virtual(
function_decl& f,
bool is_virtual)
6689 ctxt->is_virtual(is_virtual);
6702 set_member_function_is_virtual(*fn, is_virtual);
6721 set_member_function_vtable_offset(fn, voffset);
6722 set_member_function_is_virtual(fn, is_virtual);
6753 set_member_function_vtable_offset(fn, voffset);
6754 set_member_function_is_virtual(fn, is_virtual);
6791 if (!cl->get_canonical_type())
6797 type_base_sptr t = type;
6808 ty->get_size_in_bits(),
6809 ty->get_alignment_in_bits(),
6810 ty->get_location()));
6818 ty->get_size_in_bits(),
6819 ty->get_alignment_in_bits(),
6820 ty->get_location()));
6829 ty->get_location()));
6835 t.reset(
new array_type_def(p, ty->get_subranges(), ty->get_location()));
6840 for (function_decl::parameters::const_iterator i =
6841 ty->get_parameters().begin();
6842 i != ty->get_parameters().end();
6853 p->get_variadic_marker(),
6854 p->get_is_artificial()));
6855 parm.push_back(stripped);
6860 parm, ty->get_is_const(),
6861 ty->get_size_in_bits(),
6862 ty->get_alignment_in_bits()));
6867 for (function_decl::parameters::const_iterator i =
6868 ty->get_parameters().begin();
6869 i != ty->get_parameters().end();
6880 p->get_variadic_marker(),
6881 p->get_is_artificial()));
6882 parm.push_back(stripped);
6887 ty->get_size_in_bits(),
6888 ty->get_alignment_in_bits()));
6891 if (!t->get_translation_unit())
6892 t->set_translation_unit(type->get_translation_unit());
6897 return t->get_canonical_type() ? t->get_canonical_type() : t;
6920 decl_base_sptr result = t;
6921 type_base_sptr u = t->get_underlying_type();
6924 if ((t->get_cv_quals() & qualified_type_def::CV_CONST
6926 || (t->get_cv_quals() & qualified_type_def::CV_CONST
6928 || t->get_cv_quals() == qualified_type_def::CV_NONE)
6974static qualified_type_def_sptr
6975strip_redundant_quals_from_underyling_types(
const qualified_type_def_sptr& t,
6984 qualified_type_def_sptr underlying_qualified_type =
6992 currated_quals &= ~redundant_quals;
6993 t->set_cv_quals(currated_quals);
6997 redundant_quals |= currated_quals;
6999 qualified_type_def_sptr result = t;
7000 if (underlying_qualified_type)
7004 strip_redundant_quals_from_underyling_types(underlying_qualified_type,
7038strip_redundant_quals_from_underyling_types(
const qualified_type_def_sptr& t)
7044 strip_redundant_quals_from_underyling_types(t, redundant_quals);
7071 return t->get_underlying_type();
7125 return t->get_pointed_to_type();
7181 return t->get_pointed_to_type();
7306 if (t->get_cv_quals() == qualified_type_def::CV_CONST)
7339 return q->get_underlying_type();
7388 type_base_sptr type = t;
7411 type_base_sptr typ = type;
7473 bool peel_qual_type)
7512 bool peel_qual_type)
7553 array->get_subranges().begin();
7554 i != array->get_subranges().end();
7560 (*i)->get_lower_bound(),
7561 (*i)->get_upper_bound(),
7562 (*i)->get_underlying_type(),
7563 (*i)->get_location(),
7564 (*i)->get_language()));
7565 subrange->is_non_finite((*i)->is_non_finite());
7568 subranges.push_back(subrange);
7573 subranges, array->get_location()));
7596 (
new typedef_decl(t->get_name(), t->get_underlying_type(),
7597 t->get_location(), t->get_linkage_name(),
7598 t->get_visibility()));
7614qualified_type_def_sptr
7620 qualified_type_def_sptr result
7622 t->get_cv_quals(), t->get_location()));
7634static type_base_sptr
7635clone_typedef_array_qualified_type(type_base_sptr type)
7641 type_base_sptr result;
7650 return type_base_sptr();
7673 type_base_sptr result = clone_typedef_array_qualified_type(t);
7676 type_base_sptr subtree;
7680 clone_typedef_array_qualified_type(type->get_underlying_type());
7684 type->set_underlying_type(subtree);
7690 clone_typedef_array_qualified_type(type->get_element_type());
7694 type->set_element_type(subtree);
7704 clone_typedef_array_qualified_type(t->get_underlying_type());
7711 t->set_underlying_type (s);
7720 clone_typedef_array_qualified_type(t->get_underlying_type());
7727 t->set_underlying_type(s);
7735 type_base_sptr e = t->get_element_type();
7739 clone_typedef_array_qualified_type(e);
7745 t->set_element_type(s);
7764 ::qualified_name_setter setter;
7772update_qualified_name(decl_base_sptr d)
7773{
return update_qualified_name(d.get());}
7793{
return reinterpret_cast<size_t>(l);}
7795struct scope_decl::priv
7804 bool clear_sorted_member_types_cache_ =
false;
7821 decl_base(env, name, locus, name, vis),
7834 decl_base(env,
"", l),
7841{
return priv_->canonical_types_;}
7859 if (priv_->sorted_canonical_types_.empty())
7861 for (canonical_type_sptr_set_type::const_iterator e =
7865 priv_->sorted_canonical_types_.push_back(*e);
7868 std::stable_sort(priv_->sorted_canonical_types_.begin(),
7869 priv_->sorted_canonical_types_.end(),
7872 return priv_->sorted_canonical_types_;
7882{
return priv_->members_;}
7891{
return priv_->members_;}
7902 if (priv_->sorted_members_.empty())
7907 priv_->sorted_members_.push_back(*i);
7909 std::stable_sort(priv_->sorted_members_.begin(),
7910 priv_->sorted_members_.end(),
7913 return priv_->sorted_members_;
7928 if (t->get_is_anonymous())
7946 if (t->get_is_anonymous())
7964 if (t->get_is_anonymous())
7975{
return priv_->member_scopes_;}
7982{
return priv_->member_scopes_;}
8004maybe_set_translation_unit(
const decl_base_sptr& decl,
8021 decl->set_translation_unit(tu);
8038 member->set_scope(
this);
8039 priv_->members_.push_back(member);
8042 priv_->member_types_.push_back(
is_type(member));
8043 priv_->clear_sorted_member_types_cache_ =
true;
8047 priv_->member_scopes_.push_back(m);
8049 update_qualified_name(member);
8052 maybe_set_translation_unit(member, tu);
8064{
return priv_->member_types_;}
8079 return type_base_sptr();
8089 declarations::iterator before)
8095 priv_->member_types_.push_back(t);
8096 priv_->clear_sorted_member_types_cache_=
true;
8132 for (
auto i = priv_->member_types_.begin();
8133 i != priv_->member_types_.end();
8138 priv_->member_types_.erase(i);
8151 if (priv_->clear_sorted_member_types_cache_)
8153 priv_->sorted_member_types_.clear();
8154 priv_->clear_sorted_member_types_cache_ =
false;
8157 if (priv_->sorted_member_types_.empty())
8159 unordered_set<type_base_sptr> canonical_pointer_types;
8163 priv_->sorted_member_types_.push_back(t);
8164 else if (
auto c = t->get_canonical_type())
8165 canonical_pointer_types.insert(c);
8167 canonical_pointer_types.insert(t);
8170 for (
auto t : canonical_pointer_types)
8171 priv_->sorted_member_types_.push_back(t);
8174 std::stable_sort(priv_->sorted_member_types_.begin(),
8175 priv_->sorted_member_types_.end(),
8181 priv_->clear_sorted_member_types_cache_ =
true;
8183 return priv_->sorted_member_types_;
8199 declarations::iterator before)
8203 member->set_scope(
this);
8204 priv_->members_.insert(before, member);
8207 priv_-> member_scopes_.push_back(m);
8209 update_qualified_name(member);
8212 maybe_set_translation_unit(member, tu);
8225 for (declarations::iterator i = priv_->members_.begin();
8226 i != priv_->members_.end();
8231 priv_->members_.erase(i);
8241 for (scopes::iterator i = priv_->member_scopes_.begin();
8242 i != priv_->member_scopes_.end();
8247 priv_->member_scopes_.erase(i);
8253 member->set_scope(
nullptr);
8254 member->set_translation_unit(
nullptr);
8281 if (!l.decl_base::operator==(r))
8290 scope_decl::declarations::const_iterator i, j;
8328 const scope_decl* other =
dynamic_cast<const scope_decl*
>(&o);
8332 return equals(*
this, *other, 0);
8347 if (l.get() == r.get())
8373 declarations::iterator& i)
8388 if ((*it).get() == decl)
8408 declarations::iterator& i)
8425 if (v.visit_begin(
this))
8428 for (scope_decl::declarations::const_iterator i =
8432 if (!(*i)->traverse(v))
8436 return v.visit_end(
this);
8439scope_decl::~scope_decl()
8455 if (scope && decl && !decl->get_scope())
8480 scope_decl* scope = decl->get_scope();
8495 scope_decl::declarations::iterator before,
8498 if (scope && decl && !decl->get_scope())
8517 scope_decl::declarations::iterator before,
8527 | ABSTRACT_DECL_BASE
8528 | ABSTRACT_SCOPE_DECL),
8531 translation_unit_(tu)
8533 runtime_type_instance(
this);
8552 return scope ?
dynamic_cast<global_scope*
> (scope) : 0;
8659 if (cv_quals & qualified_type_def::CV_RESTRICT)
8661 if (cv_quals & qualified_type_def::CV_CONST)
8667 if (cv_quals & qualified_type_def::CV_VOLATILE)
8719{
return get_name(tod.get(), qualified);}
8737 string qualified_name;
8741 if (qualified_name.empty())
8742 qualified_name = name;
8744 qualified_name = qualified_name +
"::" + name;
8746 return qualified_name;
8781 location loc = decl->get_location();
8785 if (c->get_is_declaration_only() && c->get_definition_of_declaration())
8788 loc = c->get_location();
8846has_generic_anonymous_internal_type_name(
const decl_base *d)
8863static interned_string
8864get_generic_anonymous_internal_type_name(
const decl_base *d)
8866 ABG_ASSERT(has_generic_anonymous_internal_type_name(d));
8868 const environment&env = d->get_environment();
8870 interned_string result;
8903get_internal_real_type_name(
const type_base* t)
8913 name = int_type.to_string(
true);
8938 return empty_string;
8945 return empty_string;
8962 r += get_generic_anonymous_internal_type_name(d);
8972 return env.
intern(get_internal_real_type_name(t));
8981 internal, qualified));
9020 bool qualified,
bool internal)
9023 string tn =
get_type_name(pointed_to_type, qualified, internal);
9042 bool lvalue_reference,
9043 bool qualified,
bool internal)
9047 string name =
get_type_name(pointed_to_type, qualified, internal);
9048 if (lvalue_reference)
9073 bool qualified,
bool internal)
9075 const environment& env = underlying_type->get_environment();
9078 string name =
get_type_name(underlying_type, qualified, internal);
9080 if (quals_repr.empty() && internal)
9092 if (!quals_repr.empty())
9101 name = quals_repr +
" " + name;
9158 std::ostringstream o;
9167 stream_pretty_representation_of_fn_parms(fn_type, o,
9170 return env.
intern(o.str());
9189 c->get_exported_decls_builder();
9190 if (b->fn_id_maps_to_several_fns(fn))
9246 std::ostringstream o;
9265 o <<
" (" << class_type->get_qualified_name(internal) <<
"::*) ";
9266 stream_pretty_representation_of_fn_parms(fn_type, o,
9270 return env.
intern(o.str());
9436 std::ostringstream o;
9454 std::ostringstream o;
9509 const string& indent,
9512 bool qualified_names)
9515 string local_indent =
" ";
9520 if (!internal && clazz->is_struct())
9526 repr = indent +
"union";
9559 for (class_or_union::data_members::const_iterator dm = dmems.begin();
9563 if (dm != dmems.begin())
9568 real_indent =
"\n" + indent + local_indent;
9575 real_indent, one_line, internal, qualified_names);
9580 if (dm != dmems.begin())
9581 repr += real_indent;
9582 repr += (*dm)->get_pretty_representation(internal,
9587 real_indent+ (*dm)->get_pretty_representation(internal,
9596 repr += indent +
"}";
9624 const string& indent,
9627 bool qualified_names)
9631 internal, qualified_names);
9653 const string& indent,
9656 bool qualified_names)
9685 const string& indent,
bool one_line,
9686 bool qualified_names)
9689 std::ostringstream o;
9690 string local_indent =
" ";
9692 repr = indent +
"enum ";
9695 o << (qualified_names
9709 o << enumerator.get_name() +
"=" << enumerator.get_value() <<
", ";
9713 o <<
"\n" + indent <<
"}";
9744 const string& indent,
bool one_line,
9745 bool qualified_names)
9751 one_line, qualified_names);
9776 const string& indent,
bool one_line,
9777 bool qualified_names)
9806 const string& indent,
9809 bool qualified_name)
9815 internal, qualified_name);
9844 std::ostringstream o;
9859 o <<
" :" << std::endl;
9863 if (b->get_is_virtual())
9865 o << b->get_base_class()->get_qualified_name()
9869 o << std::hex << *h << std::dec;
9880 <<
" // translation unit: "
9885 <<
" // @: " << std::hex <<
is_type(c)
9891 o << std::hex << *h << std::dec;
9901 << member_type->get_pretty_representation(
false,
9904 if (member_type->get_canonical_type())
9906 o <<
" // uses canonical type: '@"
9907 << std::hex << member_type->get_canonical_type().get() <<
"'";
9910 o << std::hex << *h << std::dec;
9930 if (t && t->get_canonical_type())
9931 o <<
" // uses canonical type '@"
9932 << std::hex << t->get_canonical_type().get() <<
"'";
9937 o << std::hex << *h << std::dec;
9948 o <<
" // virtual member functions\n\n";
9957 o << std::hex << *h << std::dec;
9960 o <<
";" << std::endl;
9964 o <<
"};" << std::endl;
9970 string name = e->get_qualified_name();
9971 std::ostringstream o;
9972 o <<
"enum " << name
9974 << e->get_underlying_type()->get_pretty_representation(
false,
9978 <<
" // size in bits: " << e->get_size_in_bits() <<
"\n"
9979 <<
" // is-declaration-only: " << e->get_is_declaration_only() <<
"\n"
9981 <<
" // translation unit: "
9982 << e->get_translation_unit()->get_absolute_path() <<
"\n"
9983 <<
" // @: " << std::hex <<
is_type(e)
9984 <<
", @canonical: " << e->get_canonical_type().get() << std::dec <<
"\n"
9989 o << std::hex << *h << std::dec;
9995 for (
const auto &enom : e->get_enumerators())
9996 o <<
" " << enom.get_name() <<
" = " << enom.get_value() <<
",\n";
10004 std::ostringstream o;
10005 o << t->get_pretty_representation(
true,
10012 return artifact->get_pretty_representation(
true,
10111 return const_cast<type_base*
>(artifact);
10128 return const_cast<decl_base*
>(artifact);
10160 for (
auto t : vect)
10162 o <<
"|" << t->get_pretty_representation()
10163 <<
"@" << std::hex << t << std::dec;
10177 std::ostringstream o;
10178 o <<
"left-operands: ";
10179 debug_comp_vec(env.priv_->left_type_comp_operands_, o);
10180 o <<
"\n" <<
"right-operands: ";
10181 debug_comp_vec(env.priv_->right_type_comp_operands_, o);
10194 std::cerr << print_comp_stack(env);
10195 std::cerr << std::endl;
10230{
return dynamic_cast<const decl_base*
>(t);}
10248{
return dynamic_pointer_cast<decl_base>(t);}
10269 || (fc->get_qualified_name() != sc->get_qualified_name())
10270 || (fc->get_size_in_bits() != sc->get_size_in_bits())
10271 || (fc->get_data_members().size() != sc->get_data_members().size()))
10278 for (
auto f_decl_it = fc->get_data_members().begin(),
10279 s_decl_it = sc->get_data_members().begin();
10280 (f_decl_it != fc->get_data_members().end()
10281 && s_decl_it != sc->get_data_members().end());
10282 ++f_decl_it, ++s_decl_it)
10285 type_base_sptr dm1_type = dm1->get_type(), dm2_type = dm2->get_type();
10287 if (*dm1_type != *dm2_type
10293 for (
auto f_bs_it = fc->get_base_specifiers().begin(),
10294 s_bs_it = sc->get_base_specifiers().end();
10295 (f_bs_it != fc->get_base_specifiers().end()
10296 && s_bs_it != sc->get_base_specifiers().end());
10297 ++f_bs_it, ++s_bs_it)
10300 if ((f_bs->get_is_virtual() != s_bs->get_is_virtual())
10301 || (f_bs->get_offset_in_bits() != s_bs->get_offset_in_bits()))
10304 class_decl_sptr fb = f_bs->get_base_class(), sb = s_bs->get_base_class();
10309 if (fc->has_vtable() != sc->has_vtable())
10313 if (fc->has_vtable())
10315 if (fc->get_virtual_mem_fns().size() > sc->get_virtual_mem_fns().size())
10319 for (
auto it1 = fc->get_virtual_mem_fns().begin(),
10320 it2 = sc->get_virtual_mem_fns().begin();
10321 (it1 != fc->get_virtual_mem_fns().end()
10322 && it2 != sc->get_virtual_mem_fns().end());
10325 method_decl_sptr method1 = *it1;
10326 method_decl_sptr method2 = *it2;
10331 method2->get_type()))
10359 if (!type1 || !type2)
10362 if (type1 == type2 || *type1 == *type2)
10368 if (t1 && t2 && *t1 == *t2)
10392 type_base_sptr e1 = a1->get_element_type();
10393 type_base_sptr e2 = a2->get_element_type();
10397 if ((a1->get_size_in_bits() != a2->get_size_in_bits())
10398 || (a1->get_dimension_count() != a2->get_dimension_count())
10410 fn_type2->get_return_type()))
10417 if (fn_type1->get_parameters().size()
10418 != fn_type2->get_parameters().size())
10421 for (
auto p1 = fn_type1->get_first_non_implicit_parm(),
10422 p2 = fn_type2->get_first_non_implicit_parm();
10423 (p1 != fn_type1->get_parameters().end()
10424 && p2 != fn_type2->get_parameters().end());
10427 (*p2)->get_type()))
10451 const decl_base_sptr d2)
10609 const string& name)
10614 if (!containing_class_or_union)
10631{
return (decl &&
dynamic_cast<template_decl*
>(decl->get_scope()));}
10641 return (decl && (dynamic_pointer_cast<type_tparameter>(decl)
10642 || dynamic_pointer_cast<non_type_tparameter>(decl)
10643 || dynamic_pointer_cast<template_tparameter>(decl)));
10673{
return dynamic_pointer_cast<function_decl>(d);}
10696{
return dynamic_pointer_cast<function_decl::parameter>(tod);}
10707 if (d && (d->
kind() & type_or_decl_base::ABSTRACT_DECL_BASE))
10709 if (!(d->
kind() & type_or_decl_base::ABSTRACT_TYPE_BASE))
10716 (
const_cast<type_or_decl_base*
>(d)->type_or_decl_base_pointer());
10722 return dynamic_cast<decl_base*
>(
const_cast<type_or_decl_base*
>(d));
10735{
return dynamic_pointer_cast<decl_base>(d);}
10757{
return dynamic_pointer_cast<decl_base>(t);}
10767 if (
dynamic_cast<const type_base*
>(&tod))
10780 if (t && (t->
kind() & type_or_decl_base::ABSTRACT_TYPE_BASE))
10782 (
const_cast<type_or_decl_base*
>(t)->type_or_decl_base_pointer());
10794{
return dynamic_pointer_cast<type_base>(tod);}
10826 if (!cou->get_naming_typedef())
10868{
return dynamic_cast<const type_decl*
>(t);}
10876{
return dynamic_pointer_cast<type_decl>(t);}
10970{
return dynamic_pointer_cast<typedef_decl>(t);}
11051{
return dynamic_pointer_cast<enum_type_decl>(d);}
11105 if (t->
kind() & type_or_decl_base::CLASS_TYPE)
11107 (
const_cast<type_or_decl_base*
>(t)->runtime_type_instance());
11119{
return dynamic_pointer_cast<class_decl>(d);}
11141 if (array->is_non_finite())
11211 if (array->get_subranges().size() == 1
11212 && array->get_subranges()[0]->get_length() == 1)
11282 return klass->get_is_declaration_only();
11331shared_ptr<class_or_union>
11333{
return dynamic_pointer_cast<class_or_union>(t);}
11362 const class_or_union_sptr& second)
11392{
return dynamic_pointer_cast<union_decl>(t);}
11406 bool look_through_qualifiers)
11412 if (look_through_qualifiers)
11430 bool look_through_qualifiers)
11432 type_base_sptr type =
is_type(t);
11433 if (look_through_qualifiers)
11435 return dynamic_pointer_cast<pointer_type_def>(type);
11578 bool look_through_qualifiers)
11584 if (look_through_qualifiers)
11601 bool look_through_qualifiers)
11605 if (look_through_qualifiers)
11622 bool look_through_qualifiers)
11624 type_base_sptr type =
is_type(t);
11625 if (look_through_qualifiers)
11627 return dynamic_pointer_cast<reference_type_def>(type);
11638 bool look_through_qualifiers)
11641 if (look_through_qualifiers)
11658 bool look_through_qualifiers)
11660 type_base_sptr type =
is_type(t);
11661 if (look_through_qualifiers)
11663 return dynamic_pointer_cast<ptr_to_mbr_type>(type);
11737const type_base_sptr
11740 type_base_sptr nil;
11744 if (t->get_environment().get_void_pointer_type().get() == t.get())
11773qualified_type_def_sptr
11775{
return dynamic_pointer_cast<qualified_type_def>(t);}
11785{
return dynamic_pointer_cast<function_type>(t);}
11815{
return dynamic_pointer_cast<method_type>(t);}
11895 decl_base_sptr decl;
11902 while (decl->get_is_declaration_only()
11903 && decl->get_definition_of_declaration())
11904 decl = decl->get_definition_of_declaration();
11971 decl_base_sptr d =
is_decl(t);
11996{
return dynamic_pointer_cast<var_decl>(decl);}
12005{
return dynamic_pointer_cast<namespace_decl>(d);}
12039 && dynamic_pointer_cast<function_decl>(decl)
12050 bool look_through_qualifiers)
12054 if (look_through_qualifiers)
12066 bool look_through_qualifiers)
12068 type_base_sptr t =
is_type(type);
12070 if (look_through_qualifiers)
12072 return dynamic_pointer_cast<array_type_def>(t);
12081qualified_type_def_sptr
12085 return qualified_type_def_sptr();
12155{
return dynamic_pointer_cast<array_type_def::subrange_type>(type);}
12165{
return decl && dynamic_pointer_cast<template_decl>(decl);}
12171 LOOKUP_ENTITY_TYPE,
12203find_next_delim_in_cplus_type(
const string& fqn,
12207 int angle_count = 0;
12208 bool found =
false;
12210 for (; i < fqn.size(); ++i)
12214 else if (fqn[i] ==
'>')
12216 else if (i + 1 < fqn.size()
12219 && fqn[i+1] ==
':')
12236 list<string>& comps)
12238 string::size_type fqn_size = fqn.size(), comp_begin = 0, comp_end = fqn_size;
12241 if (!find_next_delim_in_cplus_type(fqn, comp_begin, comp_end))
12242 comp_end = fqn_size;
12244 string comp = fqn.substr(comp_begin, comp_end - comp_begin);
12245 comps.push_back(comp);
12247 comp_begin = comp_end + 2;
12248 if (comp_begin >= fqn_size)
12264 for (list<string>::const_iterator c = comps.begin();
12267 if (c == comps.begin())
12270 result +=
"::" + *c;
12285template<
typename T>
12287iterator_is_last(T& container,
12288 typename T::const_iterator i)
12290 typename T::const_iterator next = i;
12292 return (next == container.end());
12309lookup_types_in_map(
const interned_string& type_name,
12312 istring_type_base_wptrs_map_type::const_iterator i = type_map.find(type_name);
12313 if (i != type_map.end())
12334template <
class TypeKind>
12335static shared_ptr<TypeKind>
12339 istring_type_base_wptrs_map_type::const_iterator i = type_map.find(type_name);
12340 if (i != type_map.end())
12344 for (
auto j : i->second)
12346 type_base_sptr t(j);
12347 decl_base_sptr d =
is_decl(t);
12348 if (d && !d->get_is_declaration_only())
12349 return dynamic_pointer_cast<TypeKind>(type_base_sptr(j));
12354 return dynamic_pointer_cast<TypeKind>(type_base_sptr(i->second.back()));
12356 return shared_ptr<TypeKind>();
12373 return lookup_type_in_map<type_decl>(type_name,
12432 return lookup_type_in_map<class_decl>(type_name,
12450 return lookup_type_in_map<union_decl>(type_name,
12485 union_decl_sptr result = lookup_type_in_map<union_decl>(loc, m);
12518 return lookup_type_in_map<enum_type_decl>(type_name,
12557 return lookup_type_in_map<typedef_decl>(type_name,
12593qualified_type_def_sptr
12598 return lookup_type_in_map<qualified_type_def>(type_name,
12617qualified_type_def_sptr
12644 return lookup_type_in_map<pointer_type_def>(type_name,
12706 return lookup_type_in_map<reference_type_def>(type_name,
12725 bool lvalue_reference,
12750 return lookup_type_in_map<array_type_def>(type_name,
12770 return lookup_type_in_map<function_type>(type_name,
12816const type_base_sptr
12820 type_base_sptr result;
12859const type_base_sptr
12883const type_base_sptr
12887 list<string> comps;
12900const decl_base_sptr
12904 list<string> comps;
12920template<
typename NodeKind>
12922get_node_name(shared_ptr<NodeKind> node);
12932{
return node->get_name();}
12941get_node_name(type_base_sptr node)
12952{
return node->get_name();}
12961template<
typename NodeKind>
12962static decl_base_sptr
12963convert_node_to_decl(shared_ptr<NodeKind> node);
12976template<
typename NodeKind>
12978lookup_node_in_scope(
const list<string>& fqn,
12982 shared_ptr<NodeKind> node;
12983 bool it_is_last =
false;
12986 for (list<string>::const_iterator c = fqn.begin(); c != fqn.end(); ++c)
12989 it_is_last = iterator_is_last(fqn, c);
12990 for (scope_decl::declarations::const_iterator m =
12991 cur_scope->get_member_decls().begin();
12992 m != cur_scope->get_member_decls().end();
12998 scope = dynamic_pointer_cast<scope_decl>(*m);
12999 if (scope && scope->get_name() == *c)
13008 node = dynamic_pointer_cast<NodeKind>(*m);
13009 if (node && get_node_name(node) == *c)
13012 dynamic_pointer_cast<class_decl>(node))
13013 if (cl->get_is_declaration_only()
13014 && !cl->get_definition_of_declaration())
13016 resulting_decl = node;
13021 if (!new_scope && !resulting_decl)
13022 return decl_base_sptr();
13023 cur_scope = new_scope;
13026 return resulting_decl;
13047const type_base_sptr
13050{
return is_type(lookup_node_in_scope<type_base>(comps, scope));}
13074static const type_base_sptr
13080 type_base_sptr result;
13085 first_scope = a.back();
13093 for (scope_decl::declarations::const_iterator i =
13097 if (
is_type(*i) && (*i)->get_name() == n)
13105 first_scope = a.back();
13107 for (scope_decl::scopes::const_iterator i =
13112 scope_name = (*i)->get_name();
13113 if (scope_name == cur_scope_name)
13139static const type_base_sptr
13144 return type_base_sptr();
13151 access_path.push_back(s);
13177const type_base_sptr
13192const decl_base_sptr
13195{
return is_var_decl(lookup_node_in_scope<var_decl>(comps, skope));}
13208template<
typename NodeKind>
13210lookup_node_in_translation_unit(
const list<string>& fqn,
13228{
return is_type(lookup_node_in_translation_unit<type_base>(fqn, tu));}
13248{
return is_class_type(lookup_node_in_translation_unit<class_decl>(fqn, tu));}
13261lookup_basic_type_through_translation_units(
const interned_string& type_name,
13262 const corpus& abi_corpus)
13266 for (translation_units::const_iterator tu =
13286static union_decl_sptr
13287lookup_union_type_through_translation_units(
const interned_string& type_name,
13288 const corpus & abi_corpus)
13290 union_decl_sptr result;
13292 for (translation_units::const_iterator tu =
13293 abi_corpus.get_translation_units().begin();
13294 tu != abi_corpus.get_translation_units().end();
13313lookup_enum_type_through_translation_units(
const interned_string& type_name,
13314 const corpus & abi_corpus)
13318 for (translation_units::const_iterator tu =
13319 abi_corpus.get_translation_units().begin();
13320 tu != abi_corpus.get_translation_units().end();
13337lookup_typedef_type_through_translation_units(
const interned_string& type_name,
13338 const corpus & abi_corpus)
13342 for (translation_units::const_iterator tu =
13343 abi_corpus.get_translation_units().begin();
13344 tu != abi_corpus.get_translation_units().end();
13361static qualified_type_def_sptr
13362lookup_qualified_type_through_translation_units(
const interned_string& t_name,
13363 const corpus & abi_corpus)
13365 qualified_type_def_sptr result;
13367 for (translation_units::const_iterator tu =
13368 abi_corpus.get_translation_units().begin();
13369 tu != abi_corpus.get_translation_units().end();
13387lookup_pointer_type_through_translation_units(
const interned_string& type_name,
13388 const corpus & abi_corpus)
13392 for (translation_units::const_iterator tu =
13393 abi_corpus.get_translation_units().begin();
13394 tu != abi_corpus.get_translation_units().end();
13412lookup_reference_type_through_translation_units(
const interned_string& t_name,
13413 const corpus & abi_corpus)
13417 for (translation_units::const_iterator tu =
13418 abi_corpus.get_translation_units().begin();
13419 tu != abi_corpus.get_translation_units().end();
13437lookup_array_type_through_translation_units(
const interned_string& type_name,
13438 const corpus & abi_corpus)
13442 for (translation_units::const_iterator tu =
13443 abi_corpus.get_translation_units().begin();
13444 tu != abi_corpus.get_translation_units().end();
13462lookup_function_type_through_translation_units(
const interned_string& type_name,
13463 const corpus & abi_corpus)
13467 for (translation_units::const_iterator tu =
13468 abi_corpus.get_translation_units().begin();
13469 tu != abi_corpus.get_translation_units().end();
13487 const corpus& abi_corpus)
13489 type_base_sptr result;
13491 for (translation_units::const_iterator tu =
13512 const string& tu_path,
13515 string_tu_map_type::const_iterator i = corp.priv_->path_tu_map.find(tu_path);
13516 if (i == corp.priv_->path_tu_map.end())
13517 return type_base_sptr();
13546 for (translation_units::const_iterator i =
13592 result = lookup_type_in_map<type_decl>(qualified_name, m);
13594 result = lookup_basic_type_through_translation_units(qualified_name, corp);
13614 result = lookup_type_in_map<type_decl>(loc, m);
13705 class_decl_sptr result = lookup_type_in_map<class_decl>(qualified_name, m);
13723 return lookup_types_in_map(qualified_name, m);
13749 for (
auto type : *v)
13751 type_base_sptr t(type);
13753 if (c->get_is_declaration_only()
13754 && !c->get_definition_of_declaration())
13755 result.push_back(type);
13758 return !result.empty();
13774 return lookup_types_in_map(qualified_name, m);
13855 union_decl_sptr result = lookup_type_in_map<union_decl>(type_name, m);
13857 result = lookup_union_type_through_translation_units(type_name, corp);
13936 lookup_type_in_map<enum_type_decl>(qualified_name, m);
13938 result = lookup_enum_type_through_translation_units(qualified_name, corp);
13956 return lookup_types_in_map(qualified_name, m);
14061 lookup_type_in_map<typedef_decl>(qualified_name, m);
14063 result = lookup_typedef_type_through_translation_units(qualified_name,
14158qualified_type_def_sptr
14173qualified_type_def_sptr
14179 qualified_type_def_sptr result =
14180 lookup_type_in_map<qualified_type_def>(qualified_name, m);
14183 result = lookup_qualified_type_through_translation_units(qualified_name,
14225 lookup_type_in_map<pointer_type_def>(qualified_name, m);
14227 result = lookup_pointer_type_through_translation_units(qualified_name,
14275 lookup_type_in_map<reference_type_def>(qualified_name, m);
14277 result = lookup_reference_type_through_translation_units(qualified_name,
14324 lookup_type_in_map<array_type_def>(qualified_name, m);
14326 result = lookup_array_type_through_translation_units(qualified_name, corp);
14395 lookup_type_in_map<function_type>(qualified_name, m);
14397 result = lookup_function_type_through_translation_units(qualified_name,
14420 type_base_sptr result;
14453 type_base_sptr result;
14501 return type_base_sptr();
14518template<
typename TypeKind>
14522 bool use_type_name_as_key =
true)
14526 if (use_type_name_as_key)
14528 else if (
location l = type->get_location())
14530 string str = l.expand();
14531 s = type->get_environment().intern(str);
14534 istring_type_base_wptrs_map_type::iterator i = types_map.find(s);
14535 bool result =
false;
14537 if (i == types_map.end())
14539 types_map[s].push_back(type);
14543 i->second.push_back(type);
14564 bool use_type_name_as_key)
14568 bool update_qname_map =
true;
14569 if (type->get_is_declaration_only())
14575 is_class_type(class_type->get_definition_of_declaration()))
14579 if (!update_qname_map)
14583 if (use_type_name_as_key)
14585 string qname = type->get_qualified_name();
14586 s = type->get_environment().intern(qname);
14588 else if (
location l = type->get_location())
14590 string str = l.expand();
14591 s = type->get_environment().intern(str);
14594 bool result =
false;
14595 istring_type_base_wptrs_map_type::iterator i = map.find(s);
14596 if (i == map.end())
14598 map[s].push_back(type);
14602 i->second.push_back(type);
14628 bool result =
false;
14630 istring_type_base_wptrs_map_type::iterator i = types_map.find(s);
14631 if (i == types_map.end())
14633 types_map[s].push_back(type);
14637 i->second.push_back(type);
14660 if (
corpus *type_corpus = basic_type->get_corpus())
14664 type_corpus->priv_->get_types().basic_types());
14668 type_corpus->get_type_per_loc_map().basic_types(),
14675 group->priv_->get_types().basic_types());
14679 group->get_type_per_loc_map().basic_types(),
14704 if (
corpus *type_corpus = class_type->get_corpus())
14708 type_corpus->priv_->get_types().class_types());
14712 type_corpus->get_type_per_loc_map().class_types(),
14719 group->priv_->get_types().class_types());
14723 group->get_type_per_loc_map().class_types(),
14747 if (
corpus *type_corpus = union_type->get_corpus())
14751 type_corpus->priv_->get_types().union_types());
14755 type_corpus->get_type_per_loc_map().union_types(),
14762 group->priv_->get_types().union_types());
14766 group->get_type_per_loc_map().union_types(),
14790 if (
corpus *type_corpus = enum_type->get_corpus())
14794 type_corpus->priv_->get_types().enum_types());
14798 type_corpus->get_type_per_loc_map().enum_types(),
14805 group->priv_->get_types().enum_types());
14809 group->get_type_per_loc_map().enum_types(),
14834 if (
corpus *type_corpus = typedef_type->get_corpus())
14838 type_corpus->priv_->get_types().typedef_types());
14842 type_corpus->get_type_per_loc_map().typedef_types(),
14849 group->priv_->get_types().typedef_types());
14853 group->get_type_per_loc_map().typedef_types(),
14877 if (
corpus *type_corpus = qualified_type->get_corpus())
14881 type_corpus->priv_->get_types().qualified_types());
14887 group->priv_->get_types().qualified_types());
14910 if (
corpus *type_corpus = pointer_type->get_corpus())
14914 type_corpus->priv_->get_types().pointer_types());
14920 group->priv_->get_types().pointer_types());
14943 if (
corpus *type_corpus = ptr_to_member->get_corpus())
14947 type_corpus->priv_->get_types().ptr_to_mbr_types());
14953 group->priv_->get_types().ptr_to_mbr_types());
14976 if (
corpus *type_corpus = reference_type->get_corpus())
14980 type_corpus->priv_->get_types().reference_types());
14986 group->priv_->get_types().reference_types());
15009 if (
corpus *type_corpus = array_type->get_corpus())
15013 type_corpus->priv_->get_types().array_types());
15017 type_corpus->get_type_per_loc_map().array_types(),
15024 group->priv_->get_types().array_types());
15028 group->get_type_per_loc_map().array_types(),
15053 if (
corpus *type_corpus = subrange_type->get_corpus())
15057 type_corpus->priv_->get_types().subrange_types());
15061 type_corpus->get_type_per_loc_map().subrange_types(),
15064 if (
corpus *group = subrange_type->get_corpus())
15068 group->priv_->get_types().subrange_types());
15072 group->get_type_per_loc_map().subrange_types(),
15097 if (
corpus *type_corpus = fn_type->get_corpus())
15101 type_corpus->priv_->get_types().function_types());
15103 if (
corpus *group = fn_type->get_corpus())
15107 group->priv_->get_types().function_types());
15198 translation_unit& tu)
15200 type_base_sptr result;
15208 type_base_sptr underlying_type =
15211 if (underlying_type)
15214 qual->get_cv_quals(),
15215 qual->get_location()));
15220 type_base_sptr pointed_to_type =
15223 if (pointed_to_type)
15226 p->get_size_in_bits(),
15227 p->get_alignment_in_bits(),
15228 p->get_location()));
15233 type_base_sptr pointed_to_type =
15235 if (pointed_to_type)
15239 r->get_size_in_bits(),
15240 r->get_alignment_in_bits(),
15241 r->get_location()));
15255 tu.priv_->synthesized_types_.push_back(result);
15281 translation_unit& tu)
15288 type_base_sptr result_return_type;
15293 if (!result_return_type)
15297 type_base_sptr parm_type;
15299 for (function_type::parameters::const_iterator i =
15304 type_base_sptr t = (*i)->get_type();
15311 (*i)->get_location(),
15312 (*i)->get_variadic_marker(),
15313 (*i)->get_is_artificial()));
15314 parms.push_back(parm);
15317 class_or_union_sptr class_type;
15329 result_fn_type.reset(
new method_type(result_return_type,
15341 tu.priv_->synthesized_types_.push_back(result_fn_type);
15345 return result_fn_type;
15356 if (mangled_name.empty())
15361 char * str = abi::__cxa_demangle(mangled_name.c_str(),
15362 NULL, &l, &status);
15363 string demangled_name = mangled_name;
15367 demangled_name = str;
15371 return demangled_name;
15396global_scope::~global_scope()
15417types_defined_same_linux_kernel_corpus_public(
const type_base& t1,
15418 const type_base& t2)
15420 const corpus *t1_corpus = t1.get_corpus(), *t2_corpus = t2.get_corpus();
15421 string t1_file_path, t2_file_path;
15425 if (!(t1_corpus && t2_corpus
15426 && t1_corpus == t2_corpus
15427 && (t1_corpus->get_origin() & corpus::LINUX_KERNEL_BINARY_ORIGIN)
15432 class_or_union *c1 = 0, *c2 = 0;
15438 if ((c1 && c1->get_is_anonymous() && !c1->get_naming_typedef())
15439 || (c2 && c2->get_is_anonymous() && !c2->get_naming_typedef()))
15446 && c1->get_is_anonymous() && c1->get_naming_typedef()
15447 && c2->get_is_anonymous() && c2->get_naming_typedef())
15448 if (c1->get_naming_typedef()->get_name()
15449 != c2->get_naming_typedef()->get_name())
15455 if (e1->get_is_anonymous() || e2->get_is_anonymous())
15465 if (c1->get_is_declaration_only() != c2->get_is_declaration_only())
15467 if (c1->get_environment().decl_only_class_equals_definition())
15477 if (t1.get_size_in_bits() != t2.get_size_in_bits())
15486 l = c1->get_location();
15490 unsigned line = 0, col = 0;
15492 l.
expand(t1_file_path, line, col);
15494 l = c2->get_location();
15498 l.
expand(t2_file_path, line, col);
15501 if (t1_file_path.empty() || t2_file_path.empty())
15504 if (t1_file_path == t2_file_path)
15540compare_types_during_canonicalization(
const type_base& canonical_type,
15543#ifdef WITH_DEBUG_TYPE_CANONICALIZATION
15544 const environment& env = canonical_type.get_environment();
15545 if (env.debug_type_canonicalization_is_on())
15547 bool canonical_equality =
false, structural_equality =
false;
15548 env.priv_->allow_type_comparison_results_caching(
false);
15549 env.priv_->use_canonical_type_comparison_ =
false;
15550 structural_equality = canonical_type == candidate_type;
15551 env.priv_->use_canonical_type_comparison_ =
true;
15552 canonical_equality = canonical_type == candidate_type;
15553 env.priv_->allow_type_comparison_results_caching(
true);
15554 if (canonical_equality != structural_equality)
15556 std::cerr <<
"structural & canonical equality different for type: "
15557 << canonical_type.get_pretty_representation(
true,
true)
15561 return structural_equality;
15564 return canonical_type == candidate_type;
15588compare_canonical_type_against_candidate(
const type_base& canonical_type,
15609 bool saved_decl_only_class_equals_definition =
15614 env.decl_only_class_equals_definition(
false);
15615 env.priv_->allow_type_comparison_results_caching(
true);
15616 bool equal = (types_defined_same_linux_kernel_corpus_public(canonical_type,
15618 || compare_types_during_canonicalization(canonical_type,
15623 env.priv_->clear_type_comparison_results_cache();
15624 env.priv_->allow_type_comparison_results_caching(
false);
15625 env.decl_only_class_equals_definition
15626 (saved_decl_only_class_equals_definition);
15651compare_canonical_type_against_candidate(
const type_base* canonical_type,
15654 return compare_canonical_type_against_candidate(*canonical_type,
15679compare_canonical_type_against_candidate(
const type_base_sptr& canonical_type,
15680 const type_base_sptr& candidate_type)
15682 return compare_canonical_type_against_candidate(canonical_type.get(),
15683 candidate_type.get());
15703static type_base_sptr
15707 if (type.get_corpus()
15708 && type.get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN
15717 for (
const auto& c : cncls)
15723 if (compare_canonical_type_against_candidate(*c, type))
15727 for (
const auto& c : cncls)
15732 if (compare_canonical_type_against_candidate(*c, type))
15782type_base::get_canonical_type_for(type_base_sptr t)
15791 return type_base_sptr();
15797 bool decl_only_class_equals_definition =
15810 if (decl_only_class_equals_definition)
15813 return type_base_sptr();
15816 if (t->get_canonical_type())
15817 return t->get_canonical_type();
15838 string repr = t->get_cached_pretty_representation(
true);
15843 type_base_sptr canonical_type_present_in_corpus;
15847 type_base_sptr result;
15848 environment::canonical_types_map_type::iterator i = types.find(repr);
15850 if (i == types.end())
15859 vector<type_base_sptr> &v = i->second;
15864 result = candidate_matches_a_canonical_type_hash(v, *t);
15872 for (vector<type_base_sptr>::const_reverse_iterator it = v.rbegin();
15873 !result && it != v.rend();
15876 bool equal = compare_canonical_type_against_candidate(*it, t);
15883#ifdef WITH_DEBUG_SELF_COMPARISON
15884 if (env.self_comparison_debug_is_on())
15888 corpus_sptr corp1, corp2;
15889 env.get_self_comparison_debug_inputs(corp1, corp2);
15891 && corp1->get_origin() != corp2->get_origin()
15892 && corp2->get_origin() & corpus::NATIVE_XML_ORIGIN)
15903 check_canonical_type_from_abixml_during_self_comp(t,
15909 uintptr_t should_have_canonical_type = 0;
15910 string type_id = env.get_type_id_from_type(t.get());
15911 if (type_id.empty())
15912 type_id =
"type-id-<not-found>";
15914 should_have_canonical_type =
15915 env.get_canonical_type_from_type_id(type_id.c_str());
15916 std::cerr <<
"error: wrong canonical type for '"
15925 <<
"'. Should have had canonical type: "
15927 << should_have_canonical_type
15934 uintptr_t ptr_val =
reinterpret_cast<uintptr_t
>(t.get());
15935 string type_id = env.get_type_id_from_pointer(ptr_val);
15936 if (type_id.empty())
15937 type_id =
"type-id-<not-found>";
15954 std::cerr <<
"error: wrong induced canonical type for '"
15956 <<
"' from second corpus"
15957 <<
", ptr: " << std::hex << t.get()
15958 <<
" type-id: " << type_id
15960 << *t->hash_value()
15970 if (t_hash != result_hash)
15972 std::cerr <<
"error: type hash mismatch"
15973 <<
" between type: '"
15979 << *t->hash_value()
15980 <<
" and its computed canonical type @"
15985 << *result->hash_value()
16000 t->priv_->canonical_type_index = v.size();
16029maybe_adjust_canonical_type(
const type_base_sptr& canonical,
16030 const type_base_sptr& type)
16032 if (type->get_naked_canonical_type())
16040 if (canonical_class
16041 && canonical_class.get() != cl.get())
16045 for (class_decl::member_functions::const_iterator i =
16046 cl->get_member_functions().begin();
16047 i != cl->get_member_functions().end();
16049 if ((*i)->get_symbol())
16052 find_member_function((*i)->get_linkage_name()))
16062 if (canonical_class->get_corpus()
16063 && cl->get_corpus()
16064 && (cl->get_corpus() == canonical_class->get_corpus()))
16078 for (
const auto& data_member : cl->get_data_members())
16085 const auto& canonical_data_member =
16086 canonical_class->find_data_member(data_member->get_name());
16087 if (!canonical_data_member)
16096 if (!canonical_data_member->get_symbol())
16097 canonical_data_member->set_symbol(sym);
16113 canonical_class = cl;
16116 if (canonical_class)
16118 if (
auto abi_corpus = canonical_class->get_corpus())
16120 for (
auto& fn : canonical_class->get_member_functions())
16124 if (sym->is_defined() && sym->is_public())
16126 fn->set_is_in_public_symbol_table(
true);
16127 auto b = abi_corpus->get_exported_decls_builder();
16128 b->maybe_add_fn_to_exported_fns(fn.get());
16130 else if (!sym->is_defined())
16131 abi_corpus->get_undefined_functions().insert(fn.get());
16143 if (type->get_is_artificial() != canonical->get_is_artificial())
16144 canonical->set_is_artificial(
false);
16174 if (t->get_canonical_type())
16175 return t->get_canonical_type();
16177 if (do_log && show_stats)
16178 std::cerr <<
"Canonicalization of type '"
16179 << t->get_pretty_representation(
true,
true)
16180 <<
"/@#" << std::hex << t.get() <<
": ";
16184 if (do_log && show_stats)
16186 type_base_sptr canonical = type_base::get_canonical_type_for(t);
16188 if (do_log && show_stats)
16191 if (do_log && show_stats)
16192 std::cerr << tmr <<
"\n";
16194 maybe_adjust_canonical_type(canonical, t);
16196 t->priv_->canonical_type = canonical;
16197 t->priv_->naked_canonical_type = canonical.get();
16200 if (!t->priv_->canonical_type_index)
16201 t->priv_->canonical_type_index = canonical->priv_->canonical_type_index;
16204 if (type_base_sptr d =
is_type(cl->get_earlier_declaration()))
16205 if ((canonical = d->get_canonical_type()))
16207 d->priv_->canonical_type = canonical;
16208 d->priv_->naked_canonical_type = canonical.get();
16240 t->on_canonical_type_set();
16251 priv_->definition_of_declaration_ = d;
16253 if (type_base_sptr canonical_type =
is_type(d)->get_canonical_type())
16254 t->priv_->canonical_type = canonical_type;
16256 priv_->naked_definition_of_declaration_ =
const_cast<decl_base*
>(d.get());
16265 : type_or_decl_base(e, ABSTRACT_TYPE_BASE|ABSTRACT_TYPE_BASE),
16266 priv_(new
priv(s, a))
16280 return do_hash(
this);
16292{
return priv_->canonical_type.lock();}
16308{
return priv_->naked_canonical_type;}
16335 if (priv_->internal_cached_repr_.empty())
16340 return priv_->internal_cached_repr_;
16343 if (priv_->cached_repr_.empty())
16349 return priv_->cached_repr_;
16387{
return equals(*
this, other, 0);}
16404{priv_->size_in_bits = s;}
16411{
return priv_->size_in_bits;}
16418{priv_->alignment_in_bits = a;}
16425{
return priv_->alignment_in_bits;}
16441 v.visit_begin(
this);
16442 bool result = v.visit_end(
this);
16448type_base::~type_base()
16467 static_cast<unsigned>(r));
16482 static_cast<unsigned>(r));
16539parse_real_type_modifier(
const string& word,
16542 if (word ==
"signed")
16544 else if (word ==
"unsigned")
16546 else if (word ==
"short")
16548 else if (word ==
"long")
16550 else if (word ==
"long long")
16568parse_base_real_type(
const string& type_name,
16571 if (type_name ==
"int")
16573 else if (type_name ==
"char")
16575 else if (type_name ==
"bool" || type_name ==
"_Bool")
16577 else if (type_name ==
"double")
16579 else if (type_name ==
"float")
16581 else if (type_name ==
"char16_t")
16583 else if (type_name ==
"char32_t")
16585 else if (type_name ==
"wchar_t")
16587 else if (type_name ==
"__ARRAY_SIZE_TYPE__")
16589 else if (type_name ==
"sizetype")
16590 base = real_type::SIZE_BASE_TYPE;
16591 else if (type_name ==
"ssizetype")
16592 base = real_type::SSIZE_BASE_TYPE;
16593 else if (type_name ==
"bitsizetype")
16594 base = real_type::BIT_SIZE_BASE_TYPE;
16595 else if (type_name ==
"sbitsizetype")
16596 base = real_type::SBIT_SIZE_BASE_TYPE;
16620 string input = type_name;
16621 string::size_type len = input.length();
16622 string::size_type cur_pos = 0, prev_pos = 0;
16623 string cur_word, prev_word;
16626 while (cur_pos < len)
16628 if (cur_pos < len && isspace(input[cur_pos]))
16631 while (cur_pos < len && isspace(input[cur_pos]));
16633 prev_pos = cur_pos;
16634 cur_pos = input.find(
' ', prev_pos);
16635 prev_word = cur_word;
16636 cur_word = input.substr(prev_pos, cur_pos - prev_pos);
16639 && cur_word ==
"long"
16640 && prev_word !=
"long")
16642 if (cur_pos < len && isspace(input[cur_pos]))
16645 while (cur_pos < len && isspace(input[cur_pos]));
16646 prev_pos = cur_pos;
16648 cur_pos = input.find(
' ', prev_pos);
16649 string saved_prev_word = prev_word;
16650 prev_word = cur_word;
16651 cur_word = input.substr(prev_pos, cur_pos - prev_pos);
16652 if (cur_word ==
"long")
16653 cur_word =
"long long";
16656 cur_pos = prev_pos;
16657 cur_word = prev_word;
16658 prev_word = saved_prev_word;
16662 if (!parse_real_type_modifier(cur_word, modifiers))
16664 if (!parse_base_real_type(cur_word, base))
16695 real_type int_type(base_type, modifiers);
16703 modifiers_(NO_MODIFIER)
16712 : base_(b), modifiers_(m)
16721 modifiers_(NO_MODIFIER)
16739{
return modifiers_;}
16756{
return base_ == other.base_ && modifiers_ == other.modifiers_;}
16774 result +=
"signed ";
16776 result +=
"unsigned ";
16787 result +=
"short ";
16791 result +=
"long long ";
16802 result +=
"double";
16806 result +=
"char16_t";
16808 result +=
"char32_t";
16810 result +=
"wchar_t";
16812 result +=
"__ARRAY_SIZE_TYPE__";
16813 else if (base_ == SIZE_BASE_TYPE)
16814 result +=
"sizetype";
16815 else if (base_ == SSIZE_BASE_TYPE)
16816 result +=
"ssizetype";
16817 else if (base_ == BIT_SIZE_BASE_TYPE)
16818 result +=
"bitsizetype";
16819 else if (base_ == SBIT_SIZE_BASE_TYPE)
16820 result +=
"sbitsizetype";
16829real_type::operator string()
const
16853 const string& name,
16854 size_t size_in_bits,
16855 size_t alignment_in_bits,
16857 const string& linkage_name,
16862 | ABSTRACT_TYPE_BASE
16863 | ABSTRACT_DECL_BASE),
16864 decl_base(env, name, locus, linkage_name, vis),
16865 type_base(env, size_in_bits, alignment_in_bits)
16871 real_type int_type(base_type, modifiers);
16876 string real_type_name = int_type;
16924 bool result =
false;
16952 const decl_base* other =
dynamic_cast<const decl_base*
>(&o);
16955 return *
this == *other;
16966 const type_decl* other =
dynamic_cast<const type_decl*
>(&o);
16982 const decl_base& other = o;
16983 return *
this == other;
17029 if (l.get() == r.get())
17057 bool internal)
const
17081 if (decl_base::priv_->internal_qualified_name_.
empty())
17082 decl_base::priv_->internal_qualified_name_ =
17083 env.
intern(get_internal_real_type_name(
this));
17084 return decl_base::priv_->internal_qualified_name_;
17088 decl_base::priv_->temporary_internal_qualified_name_ =
17089 env.
intern(get_internal_real_type_name(
this));
17090 return decl_base::priv_->temporary_internal_qualified_name_;
17116 bool qualified_name)
const
17120 return get_internal_real_type_name(
this);
17122 if (qualified_name)
17140 v.visit_begin(
this);
17141 bool result = v.visit_end(
this);
17147type_decl::~type_decl()
17167 const string& name,
17168 size_t size_in_bits,
17169 size_t alignment_in_bits,
17173 ABSTRACT_SCOPE_TYPE_DECL
17174 | ABSTRACT_TYPE_BASE
17175 | ABSTRACT_DECL_BASE),
17177 type_base(env, size_in_bits, alignment_in_bits),
17178 scope_decl(env, name, locus)
17226 const scope_type_decl* other =
dynamic_cast<const scope_type_decl*
>(&o);
17246 return *
this == *other;
17270 if (v.visit_begin(
this))
17273 for (scope_decl::declarations::const_iterator i =
17277 if (!(*i)->traverse(v))
17282 bool result = v.visit_end(
this);
17288scope_type_decl::~scope_type_decl()
17304 const string& name,
17315 | ABSTRACT_DECL_BASE
17316 | ABSTRACT_SCOPE_DECL),
17318 scope_decl(env, name, locus)
17342 bool qualified_name)
const
17345 "namespace " + scope_decl::get_pretty_representation(internal,
17384 if (!ns->is_empty_or_has_empty_sub_namespaces())
17405 if (v.visit_begin(
this))
17408 scope_decl::declarations::const_iterator i;
17414 dynamic_pointer_cast<ir_traversable_base>(*i);
17416 if (!t->traverse (v))
17421 return v.visit_end(
this);
17424namespace_decl::~namespace_decl()
17433class qualified_type_def::priv
17444 weak_ptr<type_base> underlying_type_;
17447 : cv_quals_(CV_NONE)
17452 : cv_quals_(quals),
17453 underlying_type_(t)
17505qualified_type_def::qualified_type_def(type_base_sptr type,
17510 | ABSTRACT_TYPE_BASE
17511 | ABSTRACT_DECL_BASE),
17516 priv_(new priv(quals, type))
17535 | ABSTRACT_TYPE_BASE
17536 | ABSTRACT_DECL_BASE),
17539 decl_base(env,
"", locus,
""),
17540 priv_(new priv(quals))
17577 s = ut->get_size_in_bits();
17606 bool result =
true;
17651 const qualified_type_def* other =
17652 dynamic_cast<const qualified_type_def*
>(&o);
17670 const decl_base* other =
dynamic_cast<const decl_base*
>(&o);
17673 return *
this == *other;
17688 const decl_base* other =
dynamic_cast<const decl_base*
>(&o);
17691 return *
this == *other;
17706 bool internal)
const
17734 if (priv_->temporary_internal_name_.empty())
17735 priv_->temporary_internal_name_ =
17737 return priv_->temporary_internal_name_;
17753 if (priv_->internal_name_.empty())
17754 priv_->internal_name_ =
17757 return priv_->internal_name_;
17786 if (v.visit_begin(
this))
17793 bool result = v.visit_end(
this);
17798qualified_type_def::~qualified_type_def()
17805{
return priv_->cv_quals_;}
17810{priv_->cv_quals_ = cv_quals;}
17824{
return priv_->underlying_type_.lock();}
17833 priv_->underlying_type_ = t;
17843 scope_decl::declarations::iterator i;
17844 if (s->find_iterator_for_member(
this, i))
17859operator==(
const qualified_type_def_sptr& l,
const qualified_type_def_sptr& r)
17861 if (l.get() == r.get())
17877operator!=(
const qualified_type_def_sptr& l,
const qualified_type_def_sptr& r)
17885 (
static_cast<unsigned>(lhs) |
static_cast<unsigned>(rhs));
17909 (
static_cast<unsigned>(lhs) &
static_cast<unsigned>(rhs));
17931 case qualified_type_def::CV_NONE:
17934 case qualified_type_def::CV_CONST:
17937 case qualified_type_def::CV_VOLATILE:
17940 case qualified_type_def::CV_RESTRICT:
17954struct pointer_type_def::priv
17961 priv(
const type_base_sptr& t)
17963 naked_pointed_to_type_(t.get())
17967 : naked_pointed_to_type_()
17992pointer_type_def::pointer_type_def(
const type_base_sptr& pointed_to,
17993 size_t size_in_bits,
17994 size_t align_in_bits,
17998 | ABSTRACT_TYPE_BASE
17999 | ABSTRACT_DECL_BASE),
18000 type_base(pointed_to->
get_environment(), size_in_bits, align_in_bits),
18002 priv_(new priv(pointed_to))
18008 const environment& env = pointed_to->get_environment();
18009 decl_base_sptr pto = dynamic_pointer_cast<decl_base>(pointed_to);
18010 string name = (pto ? pto->get_name() :
string(
"void")) +
"*";
18028pointer_type_def::pointer_type_def(
const environment& env,
size_t size_in_bits,
18029 size_t alignment_in_bits,
18033 | ABSTRACT_TYPE_BASE
18034 | ABSTRACT_DECL_BASE),
18035 type_base(env, size_in_bits, alignment_in_bits),
18036 decl_base(env,
"", locus,
""),
18040 string name = string(
"void") +
"*";
18065 priv_->pointed_to_type_ = t;
18066 priv_->naked_pointed_to_type_ = t.get();
18071 decl_base_sptr pto = dynamic_pointer_cast<decl_base>(t);
18072 string name = (pto ? pto->get_name() :
string(
"void")) +
"*";
18104 bool result = p1 == p2;
18143 const decl_base* o =
is_decl(&other);
18146 return *
this == *o;
18160 const decl_base& o = other;
18167const type_base_sptr
18169{
return priv_->pointed_to_type_.lock();}
18176{
return priv_->naked_pointed_to_type_;}
18214 if (priv_->internal_qualified_name_.empty())
18215 if (pointed_to_type)
18216 priv_->internal_qualified_name_ =
18217 pointer_declaration_name(
this,
18224 return priv_->internal_qualified_name_;
18232 if (pointed_to_type)
18233 if (priv_->temp_internal_qualified_name_.empty())
18234 priv_->temp_internal_qualified_name_ =
18235 pointer_declaration_name(
this,
18242 return priv_->temp_internal_qualified_name_;
18251 (pointer_declaration_name(
this,
18263 if (pointed_to_type)
18265 (pointer_declaration_name(
this,
18290 if (v.visit_begin(
this))
18298 bool result = v.visit_end(
this);
18303pointer_type_def::~pointer_type_def()
18320 if (l.get() == r.get())
18348struct reference_type_def::priv
18356 priv(
const type_base_sptr& t,
bool is_lvalue)
18358 is_lvalue_(is_lvalue)
18361 priv(
bool is_lvalue)
18362 : is_lvalue_(is_lvalue)
18391reference_type_def::reference_type_def(
const type_base_sptr pointed_to,
18393 size_t size_in_bits,
18394 size_t align_in_bits,
18398 | ABSTRACT_TYPE_BASE
18399 | ABSTRACT_DECL_BASE),
18400 type_base(pointed_to->
get_environment(), size_in_bits, align_in_bits),
18402 priv_(new priv(pointed_to, lvalue))
18408 decl_base_sptr pto = dynamic_pointer_cast<decl_base>(pointed_to);
18413 name = string(pto->get_name()) +
"&";
18421 const environment& env = pointed_to->get_environment();
18445reference_type_def::reference_type_def(
const environment& env,
bool lvalue,
18446 size_t size_in_bits,
18447 size_t alignment_in_bits,
18451 | ABSTRACT_TYPE_BASE
18452 | ABSTRACT_DECL_BASE),
18453 type_base(env, size_in_bits, alignment_in_bits),
18454 decl_base(env,
"", locus,
""),
18455 priv_(new priv(lvalue))
18458 string name =
"void&";
18487 priv_->pointed_to_type_ = pointed_to_type;
18489 decl_base_sptr pto;
18491 {pto = dynamic_pointer_cast<decl_base>(pointed_to_type);}
18498 string name = string(pto->get_name()) +
"&";
18528 if (l.is_lvalue() != r.is_lvalue())
18534 type_base_sptr p1 = l.get_pointed_to_type(), p2 = r.get_pointed_to_type();
18535 bool result = p1 == p2;
18555 const reference_type_def* other =
18556 dynamic_cast<const reference_type_def*
>(&o);
18571 const decl_base* other =
dynamic_cast<const decl_base*
>(&o);
18574 return *
this == *other;
18586 const decl_base* other =
dynamic_cast<const decl_base*
>(&o);
18589 return *
this == *other;
18593reference_type_def::get_pointed_to_type()
const
18594{
return priv_->pointed_to_type_.lock();}
18597reference_type_def::is_lvalue()
const
18598{
return priv_->is_lvalue_;}
18628 type_base_sptr pointed_to_type = get_pointed_to_type();
18635 if (priv_->internal_qualified_name_.empty())
18636 if (pointed_to_type)
18637 priv_->internal_qualified_name_ =
18645 return priv_->internal_qualified_name_;
18653 if (pointed_to_type)
18654 if (priv_->temp_internal_qualified_name_.empty())
18655 priv_->temp_internal_qualified_name_ =
18663 return priv_->temp_internal_qualified_name_;
18683 if (pointed_to_type)
18713 bool qualified_name)
const
18717 (get_pointed_to_type()),
18741 if (v.visit_begin(
this))
18744 if (type_base_sptr t = get_pointed_to_type())
18749 bool result = v.visit_end(
this);
18754reference_type_def::~reference_type_def()
18771 if (l.get() == r.get())
18799struct ptr_to_mbr_type::priv
18803 type_base_sptr dm_type_;
18806 type_base_sptr containing_type_;
18813 priv(
const type_base_sptr& dm_type,
const type_base_sptr& containing_type)
18814 : dm_type_(dm_type),
18815 containing_type_(containing_type)
18837 const type_base_sptr& member_type,
18838 const type_base_sptr& containing_type,
18839 size_t size_in_bits,
18840 size_t alignment_in_bits,
18843 POINTER_TO_MEMBER_TYPE
18844 | ABSTRACT_TYPE_BASE
18845 | ABSTRACT_DECL_BASE),
18846 type_base(env, size_in_bits, alignment_in_bits),
18847 decl_base(env,
"", locus,
""),
18848 priv_(new priv(member_type, containing_type))
18885const type_base_sptr&
18887{
return priv_->dm_type_;}
18894const type_base_sptr&
18896{
return priv_->containing_type_;}
18907 const ptr_to_mbr_type* other =
18908 dynamic_cast<const ptr_to_mbr_type*
>(&o);
18923 const decl_base* other =
dynamic_cast<const decl_base*
>(&o);
18926 return *
this == *other;
18938 const decl_base* other =
dynamic_cast<const decl_base*
>(&o);
18941 return *
this == *other;
18953 bool internal)
const
18972 if (priv_->internal_qualified_name_.empty())
18973 priv_->internal_qualified_name_ =
18974 ptr_to_mbr_declaration_name(
this,
"",
18977 return priv_->internal_qualified_name_;
18981 priv_->temp_internal_qualified_name_ =
18982 ptr_to_mbr_declaration_name(
this,
"",
true, internal);
18983 return priv_->temp_internal_qualified_name_;
18989 (ptr_to_mbr_declaration_name(
this,
"",
true,
19011 if (v.visit_begin(
this))
19022 bool result = v.visit_end(
this);
19054 bool result =
true;
19056 if (!(l.decl_base::operator==(r)))
19095array_type_def::subrange_type::~subrange_type() =
default;
19104 : s_(UNSIGNED_SIGNEDNESS)
19113 : s_(UNSIGNED_SIGNEDNESS)
19122 : s_(SIGNED_SIGNEDNESS)
19130enum array_type_def::subrange_type::bound_value::signedness
19154{
return v_.unsigned_;}
19162 s_ = UNSIGNED_SIGNEDNESS;
19172 s_ = SIGNED_SIGNEDNESS;
19184 return s_ == v.s_ && v_.unsigned_ == v.v_.unsigned_;
19189struct array_type_def::subrange_type::priv
19199 : upper_bound_(ub), language_(l), infinite_(false)
19202 priv(bound_value lb, bound_value ub,
19204 : lower_bound_(lb), upper_bound_(ub),
19205 language_(l), infinite_(false)
19208 priv(bound_value lb, bound_value ub,
const type_base_sptr &u,
19210 : lower_bound_(lb), upper_bound_(ub), underlying_type_(u),
19211 language_(l), infinite_(false)
19230 const string& name,
19233 const type_base_sptr& utype,
19236 : type_or_decl_base(env, SUBRANGE_TYPE | ABSTRACT_TYPE_BASE | ABSTRACT_DECL_BASE),
19242 decl_base(env, name, loc,
""),
19243 priv_(new priv(lower_bound, upper_bound, utype, l))
19263 const string& name,
19268 : type_or_decl_base(env, SUBRANGE_TYPE | ABSTRACT_TYPE_BASE | ABSTRACT_DECL_BASE),
19269 type_base(env, 0, 0),
19270 decl_base(env, name, loc,
""),
19271 priv_(new priv(lower_bound, upper_bound, l))
19289 const string& name,
19293 : type_or_decl_base(env, SUBRANGE_TYPE | ABSTRACT_TYPE_BASE | ABSTRACT_DECL_BASE),
19294 type_base(env, upper_bound.get_unsigned_value(), 0),
19295 decl_base(env, name, loc,
""),
19296 priv_(new priv(upper_bound, l))
19321{
return priv_->underlying_type_.lock();}
19330 ABG_ASSERT(priv_->underlying_type_.expired());
19331 priv_->underlying_type_ = u;
19341{
return priv_->upper_bound_.get_signed_value();}
19348{
return priv_->lower_bound_.get_signed_value();}
19355{priv_->upper_bound_ = ub;}
19362{priv_->lower_bound_ = lb;}
19389{
return priv_->infinite_;}
19397{priv_->infinite_ = f;}
19404{
return priv_->language_;}
19412 std::ostringstream o;
19417 if (underlying_type)
19442 r += (*i)->as_string();
19471 bool result =
true;
19507 const subrange_type* other =
19508 dynamic_cast<const subrange_type*
>(&o);
19523 const decl_base* other =
dynamic_cast<const decl_base*
>(&o);
19526 return *
this == *other;
19538 const type_base &t = o;
19594 repr +=
"<anonymous range>";
19596 repr +=
"<range " +
get_name() +
">";
19615 if (v.visit_begin(
this))
19623 bool result = v.visit_end(
this);
19630struct array_type_def::priv
19637 priv(type_base_sptr t)
19641 priv(type_base_sptr t, subranges_type subs)
19642 : element_type_(t), subranges_(subs)
19662array_type_def::array_type_def(
const type_base_sptr e_type,
19663 const std::vector<subrange_sptr>& subs,
19667 | ABSTRACT_TYPE_BASE
19668 | ABSTRACT_DECL_BASE),
19671 priv_(new priv(e_type))
19695 const std::vector<subrange_sptr>& subs,
19699 | ABSTRACT_TYPE_BASE
19700 | ABSTRACT_DECL_BASE),
19701 type_base(env, 0, 0),
19702 decl_base(env, locus),
19728array_type_def::update_size()
19730 type_base_sptr e = priv_->element_type_.lock();
19733 size_t s = e->get_size_in_bits();
19737 s *= sub->get_length();
19745array_type_def::get_subrange_representation()
const
19771 bool qualified_name)
const
19773 return array_declaration_name(
this,
"",
19774 qualified_name, internal);
19799 std::vector<array_type_def::subrange_sptr > this_subs = l.
get_subranges();
19800 std::vector<array_type_def::subrange_sptr > other_subs = r.
get_subranges();
19802 bool result =
true;
19803 if (this_subs.size() != other_subs.size())
19812 std::vector<array_type_def::subrange_sptr >::const_iterator i,j;
19813 for (i = this_subs.begin(), j = other_subs.begin();
19814 i != this_subs.end() && j != other_subs.end();
19861 std::vector<array_type_def::subrange_sptr > this_subs = l->
get_subranges();
19862 std::vector<array_type_def::subrange_sptr > other_subs = r->
get_subranges();
19864 if (this_subs.size() != other_subs.size())
19867 std::vector<array_type_def::subrange_sptr >::const_iterator i,j;
19868 for (i = this_subs.begin(), j = other_subs.begin();
19869 i != this_subs.end() && j != other_subs.end();
19879 if (*first_element_type != *second_element_type)
19935 return *l_ptt == *r_ptt;
19957 const std::vector<subrange_sptr>& subranges =
19960 if (subranges.empty())
19961 return translation_unit::LANG_C11;
19962 return subranges.front()->get_language();
19968 const array_type_def* other =
19969 dynamic_cast<const array_type_def*
>(&o);
19978 const decl_base* other =
dynamic_cast<const decl_base*
>(&o);
19981 return *
this == *other;
19987const type_base_sptr
19989{
return priv_->element_type_.lock();}
20005 priv_->element_type_ = element_type;
20016 for (
const auto &sub : subs)
20017 priv_->subranges_.push_back(sub);
20029 if (priv_->subranges_.empty())
20032 for (std::vector<shared_ptr<subrange_type> >::const_iterator i =
20033 priv_->subranges_.begin();
20034 i != priv_->subranges_.end();
20036 if ((*i)->is_non_finite())
20043array_type_def::get_dimension_count()
const
20044{
return priv_->subranges_.size();}
20075 if (priv_->internal_qualified_name_.empty())
20076 priv_->internal_qualified_name_ =
20077 array_declaration_name(
this,
"",
20080 return priv_->internal_qualified_name_;
20084 priv_->temp_internal_qualified_name_ =
20085 array_declaration_name(
this,
"",
20087 return priv_->temp_internal_qualified_name_;
20104 (array_declaration_name(
this,
"",
20128 if (v.visit_begin(
this))
20136 bool result = v.visit_end(
this);
20142array_type_def::get_location()
const
20146const std::vector<array_type_def::subrange_sptr>&
20148{
return priv_->subranges_;}
20150array_type_def::~array_type_def()
20157class enum_type_decl::priv
20159 type_base_sptr underlying_type_;
20168 priv(type_base_sptr underlying_type,
20170 : underlying_type_(underlying_type),
20188enum_type_decl::enum_type_decl(
const string& name,
20190 type_base_sptr underlying_type,
20192 const string& linkage_name,
20196 | ABSTRACT_TYPE_BASE
20197 | ABSTRACT_DECL_BASE),
20202 name, locus, linkage_name, vis),
20203 priv_(new priv(underlying_type, enums))
20209 e->set_enum_type(
this);
20229{
return priv_->underlying_type_;}
20234{
return priv_->enumerators_;}
20239{
return priv_->enumerators_;}
20247 if (priv_->sorted_enumerators_.empty())
20252 priv_->sorted_enumerators_.push_back(*e);
20254 std::sort(priv_->sorted_enumerators_.begin(),
20255 priv_->sorted_enumerators_.end(),
20259 if (l.get_name() == r.get_name())
20260 return l.get_value() < r.get_value();
20261 return (l.get_name() < r.get_name());
20265 return priv_->sorted_enumerators_;
20280 enum_type_decl:: enumerator& result)
20283 if (e.get_value() == value)
20307 if (e.get_name() == name)
20335 bool qualified_name)
const
20337 string r =
"enum ";
20367 if (v.visit_begin(
this))
20375 bool result = v.visit_end(
this);
20394 const enum_type_decl& r,
20397 bool result =
false;
20407 enum_type_decl::enumerators::const_iterator i, j;
20432 enum_type_decl &local_r =
const_cast<enum_type_decl&
>(r);
20440 if (!(l.decl_base::operator==(r) && l.type_base::operator==(r)))
20445 if (!l.decl_base::operator==(r))
20447 if (!l.type_base::operator==(r))
20519is_enumerator_value_present_in_enum(
const enum_type_decl::enumerator &enr,
20520 const enum_type_decl &enom,
20521 vector<enum_type_decl::enumerator>& redundant_enrs)
20523 bool found =
false;
20524 for (
const auto &e : enom.get_enumerators())
20525 if (enumerators_values_are_equal(e, enr))
20529 redundant_enrs.push_back(e);
20551 if (is_enumerator_value_present_in_enum(enr, enom, redundant_enrs))
20553 if (!redundant_enrs.empty())
20581 bool result =
true;
20597 if (!!def1 != !!def2)
20627 if (!(def1->decl_base::operator==(*def2)
20628 && def1->type_base::operator==(*def2)))
20633 if (!def1->decl_base::operator==(*def2))
20635 if (!def1->type_base::operator==(*def2))
20713 && (!is_enumerator_value_redundant(e, *def2)
20714 || !is_enumerator_value_redundant(e, *def1)))
20728 && (!is_enumerator_value_redundant(e, *def1)
20729 || !is_enumerator_value_redundant(e, *def2)))
20753 const enum_type_decl* op =
dynamic_cast<const enum_type_decl*
>(&o);
20768 const decl_base* other =
dynamic_cast<const decl_base*
>(&o);
20771 return *
this == *other;
20786 if (l.get() == r.get())
20788 decl_base_sptr o = r;
20805class enum_type_decl::enumerator::priv
20809 string qualified_name_;
20820 priv(
const string& name,
20822 enum_type_decl* e = 0)
20834enum_type_decl::enumerator::~enumerator() =
default;
20845 : priv_(new priv(name, value))
20852 : priv_(new priv(other.
get_name(),
20879 bool names_equal =
true;
20900{
return priv_->name_;}
20918 if (priv_->qualified_name_.empty())
20920 priv_->qualified_name_ =
20925 return priv_->qualified_name_;
20941{
return priv_->value_;}
20955{
return priv_->enum_type_;}
20962{priv_->enum_type_ = e;}
20968struct typedef_decl::priv
20972 priv(
const type_base_sptr& t)
20973 : underlying_type_(t)
20988typedef_decl::typedef_decl(
const string& name,
20989 const type_base_sptr underlying_type,
20991 const string& linkage_name,
20995 | ABSTRACT_TYPE_BASE
20996 | ABSTRACT_DECL_BASE),
21001 name, locus, linkage_name, vis),
21002 priv_(new priv(underlying_type))
21018typedef_decl::typedef_decl(
const string& name,
21021 const string& mangled_name,
21025 | ABSTRACT_TYPE_BASE
21026 | ABSTRACT_DECL_BASE),
21029 decl_base(env, name, locus, mangled_name, vis),
21030 priv_(new priv(nullptr))
21105 bool result =
true;
21109 if (!(l.decl_base::operator==(r)))
21138 const typedef_decl* other =
dynamic_cast<const typedef_decl*
>(&o);
21153 const decl_base* other =
dynamic_cast<const decl_base*
>(&o);
21156 return *
this == *other;
21178 bool qualified_name)
const
21181 string result =
"typedef ";
21182 if (qualified_name)
21195{
return priv_->underlying_type_.lock();}
21203 priv_->underlying_type_ = t;
21217 bool internal)
const
21235 return decl_base::priv_->internal_qualified_name_;
21237 return decl_base::priv_->qualified_name_;
21256 if (v.visit_begin(
this))
21264 bool result = v.visit_end(
this);
21269typedef_decl::~typedef_decl()
21275struct var_decl::priv
21288 priv(type_base_sptr t,
21291 naked_type_(t.get()),
21299 set_type(type_base_sptr t)
21302 naked_type_ = t.get();
21319var_decl::var_decl(
const string& name,
21320 type_base_sptr type,
21322 const string& linkage_name,
21326 VAR_DECL | ABSTRACT_DECL_BASE),
21328 priv_(new priv(type, bind))
21336const type_base_sptr
21338{
return priv_->type_.lock();}
21345{priv_->set_type(t);}
21356{
return priv_->naked_type_;}
21363{
return priv_->binding_;}
21370{priv_->binding_ = b;}
21386 priv_->symbol_ = sym;
21401{
return priv_->symbol_;}
21470 bool result =
true;
21483 else if (s0 && !textually_equals(*s0, *s1, k))
21489 bool symbols_are_equal = (s0 && s1 && result);
21491 if (symbols_are_equal)
21500 bool decl_bases_different = !l.decl_base::operator==(r);
21504 if (decl_bases_different)
21514 if (!l.decl_base::operator==(r))
21563 bool result =
true;
21595 const var_decl* other =
dynamic_cast<const var_decl*
>(&o);
21599 return equals(*
this, *other, 0);
21614 if (priv_->id_.empty())
21619 sym_str = s->get_id_string();
21624 priv_->id_ = env.
intern(repr);
21625 if (!sym_str.empty())
21626 priv_->id_ = env.
intern(priv_->id_ +
"{" + sym_str +
"}");
21693 result =
"static ";
21697 bool member_of_anonymous_class =
false;
21700 member_of_anonymous_class =
true;
21709 if (member_of_anonymous_class || !qualified_name)
21716 string quals_repr =
21718 if (!quals_repr.empty())
21719 name = quals_repr +
" " + name;
21723 name = string(
" ") + name;
21725 result += array_declaration_name(t, name, qualified_name, internal);
21727 result += pointer_declaration_name(t, name, qualified_name, internal);
21729 result += pointer_declaration_name(t, name, qualified_name, internal);
21731 result += ptr_to_mbr_declaration_name(t, name,
21746 "",
true, internal);
21752 "",
true, internal);
21755 && (member_of_anonymous_class || !qualified_name))
21771 && (member_of_anonymous_class || !qualified_name))
21825 if (v.visit_begin(
this))
21828 if (type_base_sptr t =
get_type())
21832 return v.visit_end(
this);
21835var_decl::~var_decl()
21850 priv_->cached_name_.clear();
21851 priv_->internal_cached_name_.clear();
21871function_type::function_type(type_base_sptr return_type,
21873 size_t size_in_bits,
21874 size_t alignment_in_bits)
21876 FUNCTION_TYPE | ABSTRACT_TYPE_BASE),
21877 type_base(return_type->
get_environment(), size_in_bits, alignment_in_bits),
21878 priv_(new
priv(parms, return_type))
21882 for (parameters::size_type i = 0, j = 1;
21883 i < priv_->parms_.size();
21886 if (i == 0 && priv_->parms_[i]->get_is_artificial())
21893 priv_->parms_[i]->set_index(j);
21904function_type::function_type(type_base_sptr return_type,
21905 size_t size_in_bits,
size_t alignment_in_bits)
21907 FUNCTION_TYPE | ABSTRACT_TYPE_BASE),
21908 type_base(return_type->
get_environment(), size_in_bits, alignment_in_bits),
21909 priv_(new
priv(return_type))
21924 size_t size_in_bits,
21925 size_t alignment_in_bits)
21927 type_base(env, size_in_bits, alignment_in_bits),
21953{
return priv_->return_type_.lock();}
21961{priv_->return_type_ = t;}
21970{
return priv_->parms_;}
22013 for (parameters::size_type i = 0, j = 1;
22014 i < priv_->parms_.size();
22017 if (i == 0 && priv_->parms_[i]->get_is_artificial())
22024 priv_->parms_[i]->set_index(j);
22035 parm->set_index(priv_->parms_.size());
22036 priv_->parms_.push_back(parm);
22050 return (!priv_->parms_.empty()
22051 && priv_->parms_.back()->get_variadic_marker());
22083#define RETURN(value) CACHE_AND_RETURN_COMPARISON_RESULT(value)
22092 bool cached_result =
false;
22100 bool result =
true;
22102 if (!l.type_base::operator==(r))
22113 l_class = m->get_class_type().get();
22116 r_class = m->get_class_type().get();
22120 if (!!l_class != !!r_class)
22130 != r_class->get_qualified_name()))
22147 bool compare_result_types =
true;
22148 string l_rt_name = l_return_type_decl
22151 string r_rt_name = r_return_type_decl
22157 (r_class && (r_class->get_qualified_name() == r_rt_name)))
22158 compare_result_types =
false;
22160 if (compare_result_types)
22184 if (l_rt_name != r_rt_name)
22234function_type::parameters::const_iterator
22240 bool is_method =
dynamic_cast<const method_type*
>(
this);
22244 if (is_method && (*i)->get_is_artificial())
22256function_type::parameters::const_iterator
22283 if (priv_->internal_cached_name_.empty())
22284 priv_->internal_cached_name_ =
22286 return priv_->internal_cached_name_;
22290 priv_->temp_internal_cached_name_ =
22292 return priv_->temp_internal_cached_name_;
22299 if (priv_->cached_name_.empty())
22300 priv_->cached_name_ =
22302 return priv_->cached_name_;
22306 priv_->cached_name_ =
22308 return priv_->cached_name_;
22321 const function_type* o =
dynamic_cast<const function_type*
>(&other);
22369 if (v.visit_begin(
this))
22372 bool keep_going =
true;
22376 if (!t->traverse(v))
22377 keep_going =
false;
22384 if (type_base_sptr parm_type = (*i)->get_type())
22385 if (!parm_type->traverse(v))
22390 return v.visit_end(
this);
22393function_type::~function_type()
22399struct method_type::priv
22401 class_or_union_wptr class_type_;
22429method_type::method_type (type_base_sptr return_type,
22430 class_or_union_sptr class_type,
22431 const std::vector<function_decl::parameter_sptr>& p,
22433 size_t size_in_bits,
22434 size_t alignment_in_bits)
22436 METHOD_TYPE | ABSTRACT_TYPE_BASE | FUNCTION_TYPE),
22438 function_type(return_type, p, size_in_bits, alignment_in_bits),
22469method_type::method_type(type_base_sptr return_type,
22470 type_base_sptr class_type,
22471 const std::vector<function_decl::parameter_sptr>& p,
22473 size_t size_in_bits,
22474 size_t alignment_in_bits)
22476 METHOD_TYPE | ABSTRACT_TYPE_BASE | FUNCTION_TYPE),
22478 function_type(return_type, p, size_in_bits, alignment_in_bits),
22494 size_t size_in_bits,
22495 size_t alignment_in_bits)
22497 type_base(env, size_in_bits, alignment_in_bits),
22498 function_type(env, size_in_bits, alignment_in_bits),
22517method_type::method_type(class_or_union_sptr class_type,
22519 size_t size_in_bits,
22520 size_t alignment_in_bits)
22522 METHOD_TYPE | ABSTRACT_TYPE_BASE | FUNCTION_TYPE),
22526 alignment_in_bits),
22553{
return class_or_union_sptr(priv_->class_type_);}
22566 priv_->class_type_ = t;
22594{priv_->is_const = f;}
22601{
return priv_->is_const;}
22617 if (!first_parm->get_is_artificial())
22620 type_base_sptr this_ptr_type = first_parm->get_type();
22628 type_base_sptr candidate_class_type =
22648struct function_decl::priv
22650 bool declared_inline_;
22658 : declared_inline_(false),
22664 bool declared_inline,
22666 : declared_inline_(declared_inline),
22669 naked_type_(t.get())
22673 bool declared_inline,
22676 : declared_inline_(declared_inline),
22679 naked_type_(t.get()),
22701 bool declared_inline,
22703 const string& mangled_name,
22707 FUNCTION_DECL | ABSTRACT_DECL_BASE),
22738 type_base_sptr fn_type,
22739 bool declared_inline,
22741 const string& linkage_name,
22745 FUNCTION_DECL | ABSTRACT_DECL_BASE),
22746 decl_base(fn_type->
get_environment(), name, locus, linkage_name, vis),
22747 priv_(new priv(dynamic_pointer_cast<
function_type>(fn_type),
22769 bool qualified_name)
const
22774 string fn_prefix = mem_fn ?
"method ":
"function ";
22780 fn_prefix +=
"virtual ";
22782 decl_base_sptr return_type;
22789 return_type = mem_fn
22800 internal) +
" " + result;
22803 result = add_outer_pointer_to_fn_type_expr(p, result,
22808 result = add_outer_pointer_to_array_type_expr(p, result,
22815 return fn_prefix + result;
22845 result += mem_fn->
get_type()->get_class_type()->get_qualified_name()
22851 std::ostringstream fn_parms;
22852 stream_pretty_representation_of_fn_parms(*
get_type(),
22856 result += fn_parms.str();
22861 result +=
" const";
22872function_decl::parameters::const_iterator
22878 bool is_method =
dynamic_cast<const method_decl*
>(
this);
22891const shared_ptr<function_type>
22893{
return priv_->type_.lock();}
22908{
return priv_->naked_type_;}
22913 priv_->type_ = fn_type;
22914 priv_->naked_type_ = fn_type.get();
22931 priv_->symbol_ = sym;
22946{
return priv_->symbol_;}
22953{
return priv_->declared_inline_;}
22960{priv_->declared_inline_ = value;}
22963function_decl::get_binding()
const
22964{
return priv_->binding_;}
22967const shared_ptr<type_base>
22969{
return get_type()->get_return_type();}
22972const std::vector<shared_ptr<function_decl::parameter> >&
22974{
return get_type()->get_parameters();}
22981{
get_type()->append_parameter(parm);}
22989 for (std::vector<shared_ptr<parameter> >::const_iterator i = parms.begin();
23062 bool result =
true;
23066 if (t0 == t1 || *t0 == *t1)
23092 else if (s0 && s0 != s1)
23103 bool symbols_are_equal = (s0 && s1 && result);
23105 if (symbols_are_equal)
23117 bool decl_bases_different = !l.decl_base::operator==(r);
23124 if (decl_bases_different)
23134 if (!l.decl_base::operator==(r))
23146 if (l.get_binding() != r.get_binding())
23203 return equals(*
this, *o, 0);
23230 if (priv_->id_.empty())
23235 string virtual_member_suffix;
23245 virtual_member_suffix +=
"/o";
23248 if (s->has_aliases())
23255 priv_->id_ = env.
intern(s->get_id_string());
23257 if (!virtual_member_suffix.empty())
23258 priv_->id_ = env.
intern(priv_->id_ + virtual_member_suffix);
23302 if (v.visit_begin(
this))
23305 if (type_base_sptr t =
get_type())
23309 return v.visit_end(
this);
23331 if (l.get() == r.get())
23354struct function_decl::parameter::priv
23358 bool variadic_marker_;
23365 priv(type_base_sptr type,
23367 bool variadic_marker)
23370 variadic_marker_(variadic_marker)
23374function_decl::parameter::parameter(
const type_base_sptr type,
23376 const string& name,
23380 FUNCTION_PARAMETER_DECL | ABSTRACT_DECL_BASE),
23381 decl_base(type->get_environment(), name, loc),
23382 priv_(new priv(type, index, is_variadic))
23384 runtime_type_instance(
this);
23387function_decl::parameter::parameter(
const type_base_sptr type,
23389 const string& name,
23392 bool is_artificial)
23394 FUNCTION_PARAMETER_DECL | ABSTRACT_DECL_BASE),
23395 decl_base(type->get_environment(), name, loc),
23396 priv_(new priv(type, index, is_variadic))
23398 runtime_type_instance(
this);
23399 set_is_artificial(is_artificial);
23402function_decl::parameter::parameter(
const type_base_sptr type,
23403 const string& name,
23406 bool is_artificial)
23408 FUNCTION_PARAMETER_DECL | ABSTRACT_DECL_BASE),
23409 decl_base(type->get_environment(), name, loc),
23410 priv_(new priv(type, 0, is_variadic))
23412 runtime_type_instance(
this);
23413 set_is_artificial(is_artificial);
23416function_decl::parameter::parameter(
const type_base_sptr type,
23420 FUNCTION_PARAMETER_DECL | ABSTRACT_DECL_BASE),
23422 priv_(new priv(type, index, variad))
23424 runtime_type_instance(
this);
23427function_decl::parameter::~parameter() =
default;
23429const type_base_sptr
23430function_decl::parameter::get_type()
const
23431{
return priv_->type_.lock();}
23458 if (get_variadic_marker()
23478 std::ostringstream o;
23479 o <<
"parameter-" << get_index();
23481 return env.
intern(o.str());
23485function_decl::parameter::get_index()
const
23486{
return priv_->index_;}
23489function_decl::parameter::set_index(
unsigned i)
23490{priv_->index_ = i;}
23494function_decl::parameter::get_variadic_marker()
const
23495{
return priv_->variadic_marker_;}
23521 bool result =
true;
23523 if ((l.get_variadic_marker() != r.get_variadic_marker())
23524 || (l.get_index() != r.get_index())
23525 || (!!l.get_type() != !!r.get_type()))
23530 if (l.get_index() != r.get_index())
23532 if (l.get_variadic_marker() != r.get_variadic_marker()
23533 || !!l.get_type() != !!r.get_type())
23540 type_base_sptr l_type = l.get_type();
23541 type_base_sptr r_type = r.get_type();
23543 if (l_type != r_type)
23561function_decl::parameter::operator==(
const parameter& o)
const
23562{
return equals(*
this, o, 0);}
23565function_decl::parameter::operator==(
const decl_base& o)
const
23571 return function_decl::parameter::operator==(*p);
23617 if (v.visit_begin(
this))
23620 if (type_base_sptr t =
get_type())
23624 return v.visit_end(
this);
23657 bool qualified_name)
const
23664 type_repr =
"void";
23670 string result = type_repr;
23673 if (!parm_name.empty())
23674 result +=
" " + parm_name;
23708 size_t size_in_bits,
size_t align_in_bits,
23715 | ABSTRACT_DECL_BASE
23716 | ABSTRACT_SCOPE_TYPE_DECL
23717 | ABSTRACT_SCOPE_DECL),
23718 decl_base(env, name, locus, name, vis),
23719 type_base(env, size_in_bits, align_in_bits),
23720 scope_type_decl(env, name, size_in_bits, align_in_bits, locus, vis),
23723 for (member_types::iterator i = mem_types.begin();
23724 i != mem_types.end();
23735 for (member_functions::iterator i = member_fns.begin();
23736 i != member_fns.end();
23738 if (!
has_scope(static_pointer_cast<decl_base>(*i)))
23758 size_t size_in_bits,
size_t align_in_bits,
23762 | ABSTRACT_DECL_BASE
23763 | ABSTRACT_SCOPE_TYPE_DECL
23764 | ABSTRACT_SCOPE_DECL),
23765 decl_base(env, name, locus, name, vis),
23766 type_base(env, size_in_bits, align_in_bits),
23767 scope_type_decl(env, name, size_in_bits, align_in_bits, locus, vis),
23780 bool is_declaration_only)
23783 | ABSTRACT_DECL_BASE
23784 | ABSTRACT_SCOPE_TYPE_DECL
23785 | ABSTRACT_SCOPE_DECL),
23788 scope_type_decl(env, name, 0, 0,
location()),
23805 hash_t h = do_hash(
this);
23826 if (v.visit_begin(
this))
23835 if (!(*i)->traverse(v))
23845 if (!(*i)->traverse(v))
23855 if (!(*i)->traverse(v))
23862 for (member_function_templates::const_iterator i =
23866 if (!(*i)->traverse(v))
23873 for (member_class_templates::const_iterator i =
23877 if (!(*i)->traverse(v))
23885 bool result = v.visit_end(
this);
23914 type_base_sptr t =
is_type(decl);
23939 class_or_union * anon_dm_type =
23944 for (class_or_union::data_members::const_iterator it =
24033 if (t->get_is_anonymous())
24051 if (t->get_is_anonymous())
24069 if (t->get_is_anonymous())
24094 bool is_laid_out,
bool is_static,
24095 size_t offset_in_bits)
24099 priv_->data_members_.push_back(v);
24108 bool is_already_in =
false;
24111 for (
const auto& s_dm: priv_->static_data_members_)
24115 is_already_in =
true;
24119 if (!is_already_in)
24120 priv_->static_data_members_.push_back(v);
24126 for (data_members::const_iterator i =
24127 priv_->non_static_data_members_.begin();
24128 i != priv_->non_static_data_members_.end();
24132 is_already_in =
true;
24135 if (!is_already_in)
24136 priv_->non_static_data_members_.push_back(v);
24152{
return priv_->data_members_;}
24167 if ((*i)->get_name() == name)
24179 if (
var_decl_sptr data_member = type->find_data_member(name))
24180 return data_member;
24194 if (!v->get_name().empty())
24202 if ((*it)->get_pretty_representation(
false,
true)
24203 == v->get_pretty_representation(
false,
true))
24230 if (v->get_name().empty())
24243{
return priv_->non_static_data_members_;}
24251{
return priv_->static_data_members_;}
24269 bool is_static,
bool is_ctor,
24270 bool is_dtor,
bool is_const)
24282 priv_->member_functions_.push_back(f);
24286 if (!f->get_linkage_name().empty())
24287 priv_->mem_fns_map_[f->get_linkage_name()] = f;
24296{
return priv_->member_functions_;}
24317 string_mem_fn_sptr_map_type::const_iterator i =
24318 priv_->mem_fns_map_.find(linkage_name);
24319 if (i == priv_->mem_fns_map_.end())
24321 return i->second.get();
24332 string_mem_fn_sptr_map_type::const_iterator i =
24333 priv_->mem_fns_map_.find(linkage_name);
24334 if (i == priv_->mem_fns_map_.end())
24360 string_mem_fn_ptr_map_type::const_iterator i =
24361 priv_->signature_2_mem_fn_map_.find(s);
24362 if (i == priv_->signature_2_mem_fn_map_.end())
24370const member_function_templates&
24372{
return priv_->member_function_templates_;}
24377const member_class_templates&
24379{
return priv_->member_class_templates_;}
24390 priv_->member_function_templates_.push_back(m);
24405 priv_->member_class_templates_.push_back(m);
24415 && priv_->data_members_.empty()
24416 && priv_->member_functions_.empty()
24417 && priv_->member_function_templates_.empty()
24418 && priv_->member_class_templates_.empty());
24437 else if (method_decl_sptr f = dynamic_pointer_cast<method_decl>(d))
24443 else if (member_function_template_sptr f =
24444 dynamic_pointer_cast<member_function_template>(d))
24446 else if (member_class_template_sptr c =
24447 dynamic_pointer_cast<member_class_template>(d))
24463 const class_or_union* op =
dynamic_cast<const class_or_union*
>(&other);
24469 const class_or_union *l = 0;
24476 const class_or_union *r = 0;
24496 return *
this == *o;
24537 if (l_is_decl_only || r_is_decl_only)
24539 const class_or_union* def1 = l_is_decl_only
24543 const class_or_union* def2 = r_is_decl_only
24547 if (!def1 || !def2)
24551 && l_is_decl_only && r_is_decl_only
24590 if (!!def1 != !!def2)
24598 if (!(l.decl_base::operator==(r)
24599 && l.type_base::operator==(r)))
24610 bool val = *def1 == *def2;
24619 if (!(l.decl_base::operator==(r) && l.type_base::operator==(r)))
24626 if (types_defined_same_linux_kernel_corpus_public(l, r))
24634#define RETURN(value) \
24635 return return_comparison_result(l, r, value);
24641 bool result =
true;
24655 for (class_or_union::data_members::const_iterator
24669 || (*d0)->get_type() == (*d1)->get_type())
24696 for (member_function_templates::const_iterator
24701 ++fn_tmpl_it0, ++fn_tmpl_it1)
24702 if (**fn_tmpl_it0 != **fn_tmpl_it1)
24727 for (member_class_templates::const_iterator
24732 ++cl_tmpl_it0, ++cl_tmpl_it1)
24733 if (**cl_tmpl_it0 != **cl_tmpl_it1)
24761 const method_decl_sptr& method)
24783 old_type->get_parameters(),
24784 old_type->get_is_const(),
24785 old_type->get_size_in_bits(),
24786 old_type->get_alignment_in_bits()));
24787 t->get_translation_unit()->bind_function_type_life_time(new_type);
24796 method->get_binding()));
24797 new_method->set_symbol(method->
get_symbol());
24800 class_type->add_member_function(new_method,
24809 t->add_member_function(new_method,
24826struct class_decl::priv
24829 unordered_map<string, base_spec_sptr> bases_map_;
24830 member_functions virtual_mem_fns_;
24831 virtual_mem_fn_map_type virtual_mem_fns_map_;
24835 : is_struct_(false)
24876 size_t size_in_bits,
size_t align_in_bits,
24884 | ABSTRACT_TYPE_BASE
24885 | ABSTRACT_DECL_BASE
24886 | ABSTRACT_SCOPE_TYPE_DECL
24887 | ABSTRACT_SCOPE_DECL),
24888 decl_base(env, name, locus, name, vis),
24889 type_base(env, size_in_bits, align_in_bits),
24890 class_or_union(env, name, size_in_bits, align_in_bits,
24891 locus, vis, mbr_types, data_mbrs, mbr_fns),
24927 size_t size_in_bits,
size_t align_in_bits,
24934 | ABSTRACT_TYPE_BASE
24935 | ABSTRACT_DECL_BASE
24936 | ABSTRACT_SCOPE_TYPE_DECL
24937 | ABSTRACT_SCOPE_DECL),
24946 is_anonymous ? string() : name,
24948 type_base(env, size_in_bits, align_in_bits),
24949 class_or_union(env, name, size_in_bits, align_in_bits,
24950 locus, vis, mbr_types, data_mbrs, mbr_fns),
24973 size_t size_in_bits,
size_t align_in_bits,
24978 | ABSTRACT_TYPE_BASE
24979 | ABSTRACT_DECL_BASE
24980 | ABSTRACT_SCOPE_TYPE_DECL
24981 | ABSTRACT_SCOPE_DECL),
24982 decl_base(env, name, locus, name, vis),
24983 type_base(env, size_in_bits, align_in_bits),
24984 class_or_union(env, name, size_in_bits, align_in_bits,
25010 size_t size_in_bits,
size_t align_in_bits,
25015 | ABSTRACT_TYPE_BASE
25016 | ABSTRACT_DECL_BASE
25017 | ABSTRACT_SCOPE_TYPE_DECL
25018 | ABSTRACT_SCOPE_DECL),
25027 is_anonymous ? string() : name,
25029 type_base(env, size_in_bits, align_in_bits),
25030 class_or_union(env, name, size_in_bits, align_in_bits,
25048 bool is_struct,
bool is_declaration_only)
25051 | ABSTRACT_TYPE_BASE
25052 | ABSTRACT_DECL_BASE
25053 | ABSTRACT_SCOPE_TYPE_DECL
25054 | ABSTRACT_SCOPE_DECL),
25057 class_or_union(env, name, is_declaration_only),
25073 for (class_decl::virtual_mem_fn_map_type::iterator i =
25074 priv_->virtual_mem_fns_map_.begin();
25075 i != priv_->virtual_mem_fns_map_.end();
25077 sort_virtual_member_functions(i->second);
25085{priv_->is_struct_ = f;}
25092{
return priv_->is_struct_;}
25100 priv_->bases_.push_back(b);
25101 priv_->bases_map_[b->get_base_class()->get_qualified_name()] = b;
25109{
return priv_->bases_;}
25120 unordered_map<string, base_spec_sptr>::iterator i =
25121 priv_->bases_map_.find(qualified_name);
25123 if (i != priv_->bases_map_.end())
25124 return i->second->get_base_class();
25135{
return priv_->virtual_mem_fns_;}
25154{
return priv_->virtual_mem_fns_map_;}
25159{sort_virtual_member_functions(priv_->virtual_mem_fns_);}
25180 bool qualified_name)
const
25182 string cl =
"class ";
25191 if (internal && !
get_name().empty())
25199 string result = cl;
25200 if (qualified_name)
25209class_decl::insert_member_decl(decl_base_sptr d)
25211 if (method_decl_sptr f = dynamic_pointer_cast<method_decl>(d))
25226struct class_decl::base_spec::priv
25229 long offset_in_bits_;
25233 long offset_in_bits,
25236 offset_in_bits_(offset_in_bits),
25237 is_virtual_(is_virtual)
25255 long offset_in_bits,
25258 ABSTRACT_DECL_BASE),
25262 priv_(new priv(base, offset_in_bits, is_virtual))
25288{
return priv_->base_class_.lock();}
25295{
return priv_->is_virtual_;}
25302{
return priv_->offset_in_bits_;}
25322 if (v.visit_begin(
this))
25329 return v.visit_end(
this);
25349class_decl::base_spec::base_spec(
const type_base_sptr& base,
25351 long offset_in_bits,
25354 ABSTRACT_DECL_BASE),
25360 priv_(new priv(dynamic_pointer_cast<class_decl>(base),
25367class_decl::base_spec::~base_spec() =
default;
25393 if (!l.member_base::operator==(r))
25419 return equals(*
this, *o, 0);
25437 return operator==(
static_cast<const decl_base&
>(*o));
25440mem_fn_context_rel::~mem_fn_context_rel()
25460method_decl::method_decl(
const string& name,
25462 bool declared_inline,
25464 const string& linkage_name,
25469 | ABSTRACT_DECL_BASE
25473 declared_inline, locus, linkage_name, vis, bind)
25497method_decl::method_decl(
const string& name,
25499 bool declared_inline,
25501 const string& linkage_name,
25506 | ABSTRACT_DECL_BASE
25511 declared_inline, locus, linkage_name, vis, bind)
25534method_decl::method_decl(
const string& name,
25535 type_base_sptr type,
25536 bool declared_inline,
25538 const string& linkage_name,
25543 | ABSTRACT_DECL_BASE
25548 declared_inline, locus, linkage_name, vis, bind)
25567 class_or_union_sptr cl = t->get_class_type();
25569 cl->priv_->mem_fns_map_[l] = m;
25570 if (!old_lname.empty() && l != old_lname)
25572 if (method_decl_sptr m = cl->find_member_function_sptr(old_lname))
25575 cl->priv_->mem_fns_map_.erase(old_lname);
25581method_decl::~method_decl()
25618 if (l.get() == r.get())
25671{
return dynamic_pointer_cast<method_decl>(d);}
25675struct virtual_member_function_less_than
25699 if (f_offset != s_offset)
return f_offset < s_offset;
25705 if (fn != sn)
return fn < sn;
25711 if ((!f_sym) != (!s_sym))
return !f_sym;
25712 if (f_sym && s_sym)
25714 fn = f_sym->get_id_string();
25715 sn = s_sym->get_id_string();
25716 if (fn != sn)
return fn < sn;
25723 if (fn != sn)
return fn < sn;
25727 string fn_filepath, sn_filepath;
25728 unsigned line = 0, column = 0;
25731 fn_loc.
expand(fn_filepath, line, column);
25733 sn_loc.expand(sn_filepath, line, column);
25734 return fn_filepath < sn_filepath;
25749 operator()(
const method_decl_sptr f,
25750 const method_decl_sptr s)
25751 {
return operator()(*f, *s);}
25760 virtual_member_function_less_than lt;
25761 std::stable_sort(mem_fns.begin(), mem_fns.end(), lt);
25790 size_t vtable_offset,
25791 bool is_static,
bool is_ctor,
25792 bool is_dtor,
bool is_const)
25795 is_dtor, is_const);
25802 sort_virtual_member_functions(klass->priv_->virtual_mem_fns_);
25821 class_decl::member_functions::const_iterator m;
25822 for (m = klass->priv_->virtual_mem_fns_.begin();
25823 m != klass->priv_->virtual_mem_fns_.end();
25825 if (m->get() == method.get()
25826 || (*m)->get_linkage_name() == method->get_linkage_name())
25828 if (m == klass->priv_->virtual_mem_fns_.end())
25829 klass->priv_->virtual_mem_fns_.push_back(method);
25837 class_decl::virtual_mem_fn_map_type::iterator i =
25838 klass->priv_->virtual_mem_fns_map_.find(voffset);
25839 if (i == klass->priv_->virtual_mem_fns_map_.end())
25842 virtual_mem_fns_at_voffset.push_back(method);
25843 klass->priv_->virtual_mem_fns_map_[voffset] = virtual_mem_fns_at_voffset;
25847 for (m = i->second.begin() ; m != i->second.end(); ++m)
25848 if (m->get() == method.get()
25849 || (*m)->get_linkage_name() == method->get_linkage_name())
25851 if (m == i->second.end())
25852 i->second.push_back(method);
25881 if ((*b)->get_is_virtual()
25882 || (*b)->get_base_class()->has_virtual_bases())
25911 ssize_t offset = -1;
25912 for (class_decl::virtual_mem_fn_map_type::const_iterator e =
25916 if (e->first > offset)
25946methods_equal_modulo_elf_symbol(
const method_decl_sptr& f,
25947 const method_decl_sptr& s)
25949 method_decl_sptr first = f, second = s;
25951 first->get_symbol();
25953 second->get_symbol();
25955 first->get_linkage_name();
25957 second->get_linkage_name();
25960 first->set_linkage_name(
"");
25962 second->set_linkage_name(
"");
25964 bool equal = *first == *second;
25966 first->set_symbol(saved_first_elf_symbol);
25967 first->set_linkage_name(saved_first_linkage_name);
25968 second->set_symbol(saved_second_elf_symbol);
25969 second->set_linkage_name(saved_second_linkage_name);
25990method_matches_at_least_one_in_vector(
const method_decl_sptr& method,
25993 for (class_decl::member_functions::const_iterator i = fns.begin();
26002 if (methods_equal_modulo_elf_symbol(method, *i))
26035 bool result =
false;
26036 if (l.
get_environment().priv_->is_type_comparison_cached(l, r, result))
26044 static_cast<const class_or_union&
>(r),
26047 bool result =
true;
26048 if (!
equals(
static_cast<const class_or_union&
>(l),
26049 static_cast<const class_or_union&
>(r),
26061#define RETURN(value) CACHE_AND_RETURN_COMPARISON_RESULT(value)
26073 for (class_decl::base_specs::const_iterator
26085 (*b1)->get_base_class().get()))
26131 for (class_decl::virtual_mem_fn_map_type::const_iterator first_v_fn_entry =
26134 ++first_v_fn_entry)
26136 unsigned voffset = first_v_fn_entry->first;
26138 first_v_fn_entry->second;
26140 const class_decl::virtual_mem_fn_map_type::const_iterator
26152 second_v_fn_entry->second;
26154 bool matches =
false;
26155 for (class_decl::member_functions::const_iterator i =
26156 first_vfns.begin();
26157 i != first_vfns.end();
26159 if (method_matches_at_least_one_in_vector(*i, second_vfns))
26220 const class_decl *l = 0;
26229 const class_decl *r = 0;
26253 return *
this == *o;
26297 if (l.get() == r.get())
26329operator==(
const class_or_union_sptr& l,
const class_or_union_sptr& r)
26331 if (l.get() == r.get())
26348operator!=(
const class_or_union_sptr& l,
const class_or_union_sptr& r)
26368 if (v.visit_begin(
this))
26377 if (!(*i)->traverse(v))
26388 if (!(*i)->traverse(v))
26398 if (!(*i)->traverse(v))
26408 if (!(*i)->traverse(v))
26415 for (member_function_templates::const_iterator i =
26419 if (!(*i)->traverse(v))
26426 for (member_class_templates::const_iterator i =
26430 if (!(*i)->traverse(v))
26438 bool result = v.visit_end(
this);
26447context_rel::~context_rel()
26451member_base::operator==(
const member_base& o)
const
26471 if (l.get() == r.get())
26476 return *l ==
static_cast<const decl_base&
>(*r);
26515{
return dynamic_pointer_cast<class_decl::base_spec>(tod);}
26518member_function_template::operator==(
const member_base& other)
const
26525 if (!(is_constructor() == o.is_constructor()
26526 && is_const() == o.is_const()
26527 && member_base::operator==(o)))
26534 return ftdecl->function_tdecl::operator==(*other_ftdecl);
26553 const member_function_template_sptr& r)
26555 if (l.get() == r.get())
26574 const member_function_template_sptr& r)
26591 if (v.visit_begin(
this))
26598 return v.visit_end(
this);
26611 const member_class_template& o =
26612 dynamic_cast<const member_class_template&
>(other);
26614 if (!member_base::operator==(o))
26617 return as_class_tdecl()->class_tdecl::operator==(o);
26631 if (!decl_base::operator==(other))
26633 return as_class_tdecl()->class_tdecl::operator==(other);
26646 const decl_base* o =
dynamic_cast<const decl_base*
>(&other);
26647 return *
this == *o;
26660 const member_class_template_sptr& r)
26662 if (l.get() == r.get())
26680 const member_class_template_sptr& r)
26697 if (v.visit_begin(
this))
26704 return v.visit_end(
this);
26724 case private_access:
26727 case protected_access:
26730 case public_access:
26754 c->set_is_static(s);
26764 for (
const auto& dm : cl->get_data_members())
26765 if (dm->get_name() == v->get_name())
26776 for (class_decl::data_members::iterator i =
26777 cl->priv_->non_static_data_members_.begin();
26778 i != cl->priv_->non_static_data_members_.end();
26781 if ((*i)->get_name() == v->get_name())
26783 cl->priv_->non_static_data_members_.erase(i);
26790 bool already_in_static_dms =
false;
26791 for (
const auto& s_dm : cl->priv_->static_data_members_)
26792 if (s_dm->get_name() == v->get_name())
26794 already_in_static_dms =
true;
26797 if (!already_in_static_dms)
26798 cl->priv_->static_data_members_.push_back(var);
26803 for (class_or_union::data_members::iterator i =
26804 cl->priv_->static_data_members_.begin();
26805 i != cl->priv_->static_data_members_.end();
26807 if ((*i)->get_name() == v->get_name())
26809 cl->priv_->static_data_members_.erase(i);
26815 bool is_already_in_non_static_data_members =
false;
26816 for (
const auto& ns_dm : cl->priv_->non_static_data_members_)
26817 if (ns_dm->get_name() == v->get_name())
26819 is_already_in_non_static_data_members =
true;
26822 if (!is_already_in_non_static_data_members)
26823 cl->priv_->non_static_data_members_.push_back(var);
26863 size_t size_in_bits,
const location& locus,
26868 | ABSTRACT_TYPE_BASE
26869 | ABSTRACT_DECL_BASE),
26870 decl_base(env, name, locus, name, vis),
26872 class_or_union(env, name, size_in_bits, 0,
26873 locus, vis, mbr_types, data_mbrs, member_fns)
26899 size_t size_in_bits,
const location& locus,
26905 | ABSTRACT_TYPE_BASE
26906 | ABSTRACT_DECL_BASE),
26915 is_anonymous ? string() : name,
26918 class_or_union(env, name, size_in_bits, 0,
26919 locus, vis, mbr_types, data_mbrs, member_fns)
26937 size_t size_in_bits,
const location& locus,
26941 | ABSTRACT_TYPE_BASE
26942 | ABSTRACT_DECL_BASE
26943 | ABSTRACT_SCOPE_TYPE_DECL
26944 | ABSTRACT_SCOPE_DECL),
26945 decl_base(env, name, locus, name, vis),
26947 class_or_union(env, name, size_in_bits,
26968 size_t size_in_bits,
const location& locus,
26972 | ABSTRACT_TYPE_BASE
26973 | ABSTRACT_DECL_BASE
26974 | ABSTRACT_SCOPE_TYPE_DECL
26975 | ABSTRACT_SCOPE_DECL),
26984 is_anonymous ? string() : name,
26987 class_or_union(env, name, size_in_bits,
27003 const string& name,
27004 bool is_declaration_only)
27007 | ABSTRACT_TYPE_BASE
27008 | ABSTRACT_DECL_BASE
27009 | ABSTRACT_SCOPE_TYPE_DECL
27010 | ABSTRACT_SCOPE_DECL),
27013 class_or_union(env, name, is_declaration_only)
27051 bool qualified_name)
const
27056 if (internal && !
get_name().empty())
27057 repr = string(
"union ") +
27067 if (qualified_name)
27085 const union_decl* op =
dynamic_cast<const union_decl*
>(&other);
27104 return *
this == *o;
27118 return *
this == *o;
27151 if (v.visit_begin(
this))
27160 if (!(*i)->traverse(v))
27170 if (!(*i)->traverse(v))
27180 if (!(*i)->traverse(v))
27187 for (member_function_templates::const_iterator i =
27191 if (!(*i)->traverse(v))
27198 for (member_class_templates::const_iterator i =
27202 if (!(*i)->traverse(v))
27210 bool result = v.visit_end(
this);
27249 bool result =
false;
27250 if (l.
get_environment().priv_->is_type_comparison_cached(l, r, result))
27271 const method_decl_sptr& f)
27286 const class_or_union_sptr t = union_type;
27301 if (l.get() == r.get())
27325class template_decl::priv
27329 std::list<template_parameter_sptr> parms_;
27342{priv_->parms_.push_back(p);}
27348const std::list<template_parameter_sptr>&
27350{
return priv_->parms_;}
27363 const string& name,
27367 decl_base(env, name, locus,
"", vis),
27385 const template_decl* other =
dynamic_cast<const template_decl*
>(&o);
27388 return *
this == *other;
27401 list<shared_ptr<template_parameter> >::const_iterator t0, t1;
27427class template_parameter::priv
27433 mutable bool hashing_started_;
27434 mutable bool comparison_started_;
27442 template_decl_(enclosing_template_decl),
27443 hashing_started_(),
27444 comparison_started_()
27448template_parameter::template_parameter(
unsigned index,
27450 : priv_(new priv(index, enclosing_template))
27454template_parameter::get_index()
const
27455{
return priv_->index_;}
27458template_parameter::get_enclosing_template_decl()
const
27459{
return priv_->template_decl_.lock();}
27465 if (get_index() != o.get_index())
27468 if (priv_->comparison_started_)
27471 bool result =
false;
27476 priv_->comparison_started_ =
true;
27478 if (!!get_enclosing_template_decl() != !!o.get_enclosing_template_decl())
27480 else if (get_enclosing_template_decl()
27481 && (*get_enclosing_template_decl()
27482 != *o.get_enclosing_template_decl()))
27487 priv_->comparison_started_ =
false;
27500{
return !operator==(other);}
27507class type_tparameter::priv
27522type_tparameter::type_tparameter(
unsigned index,
27524 const string& name,
27528 | ABSTRACT_TYPE_BASE
27533 template_parameter(index, enclosing_tdecl),
27547 if (!type_decl::operator==(other))
27552 const type_tparameter& o =
dynamic_cast<const type_tparameter&
>(other);
27553 return template_parameter::operator==(o);
27567 if (!type_decl::operator==(other))
27572 const type_tparameter& o =
dynamic_cast<const type_tparameter&
>(other);
27573 return template_parameter::operator==(o);
27587 if (!decl_base::operator==(other))
27592 const type_tparameter& o =
dynamic_cast<const type_tparameter&
>(other);
27593 return template_parameter::operator==(o);
27623{
return *
this ==
static_cast<const type_base&
>(other);}
27625type_tparameter::~type_tparameter()
27629class non_type_tparameter::priv
27639 priv(type_base_sptr type)
27657non_type_tparameter::non_type_tparameter(
unsigned index,
27659 const string& name,
27660 type_base_sptr type,
27664 template_parameter(index, enclosing_tdecl),
27665 priv_(new priv(type))
27673const type_base_sptr
27675{
return priv_->type_.lock();}
27681 if (!decl_base::operator==(other))
27686 const non_type_tparameter& o =
27687 dynamic_cast<const non_type_tparameter&
>(other);
27688 return (template_parameter::operator==(o)
27707non_type_tparameter::~non_type_tparameter()
27713class template_tparameter::priv
27727template_tparameter::template_tparameter(
unsigned index,
27729 const string& name,
27733 | ABSTRACT_TYPE_BASE
27738 0, 0, locus, name, VISIBILITY_DEFAULT),
27739 type_tparameter(index, enclosing_tdecl, name, locus),
27756 const template_tparameter& o =
27757 dynamic_cast<const template_tparameter&
>(other);
27758 return (type_tparameter::operator==(o)
27759 && template_decl::operator==(o));
27775 const template_tparameter& o =
27776 dynamic_cast<const template_tparameter&
>(other);
27777 return (type_tparameter::operator==(o)
27778 && template_decl::operator==(o));
27789 const template_tparameter& other =
27790 dynamic_cast<const template_tparameter&
>(o);
27791 return *
this ==
static_cast<const type_base&
>(other);
27802 const template_tparameter& other =
27803 dynamic_cast<const template_tparameter&
>(o);
27810template_tparameter::~template_tparameter()
27818class type_composition::priv
27842type_composition::type_composition(
unsigned index,
27846 ABSTRACT_DECL_BASE),
27848 template_parameter(index, tdecl),
27857const type_base_sptr
27859{
return priv_->type_.lock();}
27868type_composition::~type_composition()
27877class function_tdecl::priv
27889 : pattern_(pattern), binding_(bind)
27916 | ABSTRACT_SCOPE_DECL),
27918 template_decl(env,
"", locus, vis),
27919 scope_decl(env,
"", locus),
27920 priv_(new priv(bind))
27944 | ABSTRACT_SCOPE_DECL),
27949 priv_(new priv(pattern, bind))
27960 priv_->pattern_ = p;
27970{
return priv_->pattern_;}
27977{
return priv_->binding_;}
27987 const function_tdecl* o =
dynamic_cast<const function_tdecl*
>(&other);
27989 return *
this == *o;
28001 const function_tdecl* o =
dynamic_cast<const function_tdecl*
>(&other);
28003 return *
this == *o;
28016 && template_decl::operator==(o)
28017 && scope_decl::operator==(o)
28041 if (!v.visit_begin(
this))
28048 return v.visit_end(
this);
28051function_tdecl::~function_tdecl()
28059class class_tdecl::priv
28070 : pattern_(pattern)
28089 | ABSTRACT_SCOPE_DECL),
28091 template_decl(env,
"", locus, vis),
28092 scope_decl(env,
"", locus),
28114 | ABSTRACT_SCOPE_DECL),
28119 priv_(new priv(pattern))
28130 priv_->pattern_ = p;
28140{
return priv_->pattern_;}
28147 const class_tdecl& o =
dynamic_cast<const class_tdecl&
>(other);
28149 if (!(template_decl::operator==(o)
28150 && scope_decl::operator==(o)
28168 const class_tdecl& o =
dynamic_cast<const class_tdecl&
>(other);
28169 return *
this ==
static_cast<const decl_base&
>(o);
28177{
return *
this ==
static_cast<const decl_base&
>(o);}
28193 if (v.visit_begin(
this))
28197 pattern->traverse(v);
28200 return v.visit_end(
this);
28203class_tdecl::~class_tdecl()
28214 non_canonicalized_subtype_detector();
28217 non_canonicalized_subtype_detector(
type_base* type)
28219 has_non_canonical_type_()
28228 has_non_canonical_type()
const
28229 {
return has_non_canonical_type_;}
28234 visit_begin(function_decl* f)
28252 visit_begin(type_base* t)
28256 if (!t->get_canonical_type())
28260 has_non_canonical_type_ = t;
28275 visit_end(type_base* )
28277 if (has_non_canonical_type_)
28294 non_canonicalized_subtype_detector v(t.get());
28296 return v.has_non_canonical_type();
28312 const type_base_sptr t_v2)
28319 return (t1 != t2 && repr1 == repr2);
28330 env.priv_->extra_live_types_.push_back(t);
28365 result =
reinterpret_cast<size_t>(g);
28367 result =
reinterpret_cast<size_t>(s);
28373 string repr = v->get_pretty_representation(
true);
28374 std::hash<string> hash_string;
28382 string repr = f->get_pretty_representation(
true);
28383 std::hash<string> hash_string;
28389 type_base_sptr parm_type = p->get_type();
28391 std::hash<bool> hash_bool;
28392 std::hash<unsigned> hash_unsigned;
28401 std::hash<size_t> hash_size;
28402 std::hash<bool> hash_bool;
28403 type_base_sptr type = bs->get_base_class();
28440{
return hash_as_canonical_type_or_constant(t);}
28463 const type_or_decl_base* artefactp = &artefact;
28467 if (d->type_or_decl_base::priv_->get_hashing_state()
28469 return d->type_or_decl_base::priv_->hash_value_;
28472 return artefact.priv_->hash_value_;
28574 exemplar =
const_cast<type_base*
>(type);
28603hash_as_canonical_type_or_constant(
const type_base *t)
28610 if (!canonical_type)
28628 if (canonical_type)
28629 return reinterpret_cast<size_t>(canonical_type);
28704 const type_base_sptr& second,
28705 bool indirect_type)
28737 bool indirect_type)
28739 if (!!first != !!second)
28751 if (
typeid(*first) !=
typeid(*second))
28767 if (ty1->is_lvalue() != ty2->is_lvalue())
28770 ty2->get_pointed_to_type(),
28789 if (!indirect_type)
28793 return ty1->get_name() == ty2->
get_name();
28799 if (!indirect_type)
28803 return (
get_name(ty1->get_underlying_type())
28811 && ty1->get_name() != ty2->
get_name())
28814 if (!indirect_type)
28817 || (ty1->get_non_static_data_members().size()
28821 for (class_or_union::data_members::const_iterator
28822 i = ty1->get_non_static_data_members().begin(),
28824 (i != ty1->get_non_static_data_members().end()
28831 dm2->get_type().get(),
28844 && ty1->get_name() != ty2->
get_name())
28847 if (!indirect_type)
28856 if (!indirect_type)
28859 || ty1->get_dimension_count() != ty2->get_dimension_count())
28879 for (
auto r1 = ty1->get_subranges().begin(),
28880 r2 = ty1->get_subranges().begin();
28881 (r1 != ty1->get_subranges().end()
28884 if ((*r1)->get_length() != (*r2)->get_length())
28919 if (ty1->get_parameters().size() != ty2->
get_parameters().size())
28922 for (function_type::parameters::const_iterator
28923 i = ty1->get_parameters().begin(),
28925 (i != ty1->get_parameters().end()
28955 const char* dm_name)
28983 return cou->find_data_member(dm);
28998 unsigned parm_index)
29005 if (parms.size() <= parm_index)
29008 return parms[parm_index].get();
29023 std::ostringstream o;
29026 o <<
"unnamed-enum";
29028 o <<
"enum-" << base_name;
29030 o <<
"-underlying-type-" << size;
29050 return data_member;
29070 for (; d != e; ++d)
29091stream_pretty_representation_of_fn_parms(
const function_type& fn_type,
29092 ostream& o,
bool qualified,
29100 type_base_sptr type;
29107 if (i != first_parm)
29110 type = parm->get_type();
29173add_outer_pointer_to_fn_type_expr(
const type_base* p,
29174 const string& input,
29175 bool qualified,
bool internal)
29181 string star_or_ref;
29194 if (!pointed_to_fn)
29197 if (pointed_to_fn->priv_->is_pretty_printing())
29207 pointed_to_fn->priv_->set_is_pretty_printing();
29209 std::ostringstream left, right, inner;
29211 inner <<
"(" << star_or_ref << input <<
")";
29213 type_base_sptr type;
29214 stream_pretty_representation_of_fn_parms(*pointed_to_fn, right,
29215 qualified, internal);
29217 type_base_sptr return_type = pointed_to_fn->get_return_type();
29226 result = left.str() +
" " + inner.str() + right.str();
29230 string inner_string = inner.str() + right.str();
29231 result = add_outer_pointer_to_fn_type_expr(p, inner_string,
29232 qualified, internal);
29236 string inner_string = inner.str() + right.str();
29237 result = add_outer_pointer_to_array_type_expr(p, inner_string,
29238 qualified, internal);
29246 pointed_to_fn->priv_->unset_is_pretty_printing();
29297add_outer_pointer_to_fn_type_expr(
const type_base_sptr& p,
29298 const string& input,
29299 bool qualified,
bool internal)
29300{
return add_outer_pointer_to_fn_type_expr(p.get(), input, qualified, internal);}
29353add_outer_pointer_to_array_type_expr(
const type_base* p,
29354 const string& input,
bool qualified,
29360 string star_or_ref;
29361 type_base_sptr pointed_to_type;
29365 pointed_to_type = ptr->get_pointed_to_type();
29370 pointed_to_type = ref->get_pointed_to_type();
29378 std::ostringstream left, right, inner;
29379 inner <<
"(" << star_or_ref << input <<
")";
29380 right << array->get_subrange_representation();
29383 type_base_sptr array_element_type = array->get_element_type();
29389 left <<
get_type_name(array_element_type, qualified, internal);
29390 result = left.str() + inner.str() + right.str();
29395 string r = inner.str() + right.str();
29396 result = add_outer_pointer_to_fn_type_expr(p, r, qualified, internal);
29401 string inner_string = inner.str() + right.str();
29402 result = add_outer_pointer_to_array_type_expr(p, inner_string,
29403 qualified, internal);
29462add_outer_pointer_to_array_type_expr(
const type_base_sptr& pointer_to_ar,
29463 const string& input,
bool qualified,
29465{
return add_outer_pointer_to_array_type_expr(pointer_to_ar.get(),
29466 input, qualified, internal);}
29515 const string& input,
bool qualified,
29521 std::ostringstream left, right, inner;
29522 type_base_sptr void_type = p->get_environment().get_void_type();
29523 string containing_type_name =
get_type_name(p->get_containing_type(),
29524 qualified, internal);
29525 type_base_sptr mbr_type = p->get_member_type();
29529 inner <<
"(" << containing_type_name <<
"::*" << input <<
")";
29530 stream_pretty_representation_of_fn_parms(*fn_type, right,
29531 qualified, internal);
29534 return_type = void_type;
29541 left <<
get_type_name(return_type, qualified, internal) <<
" ";;
29542 result = left.str() + inner.str() + right.str();
29546 string inner_str = inner.str() + right.str();
29547 result = pointer_declaration_name(p, inner_str, qualified, internal);
29551 string inner_str = inner.str() + right.str();
29552 result = add_outer_ptr_to_mbr_type_expr(p, inner_str,
29553 qualified, internal);
29560 inner <<
"(" << containing_type_name <<
"::*" << input <<
")";
29561 stream_pretty_representation_of_fn_parms(*fn_type, right,
29562 qualified, internal);
29563 string inner_str = inner.str() + right.str();
29564 result = add_outer_ptr_to_mbr_type_expr(ptr_mbr_type, inner_str,
29565 qualified, internal);
29569 left <<
get_type_name(p->get_member_type(), qualified, internal) <<
" ";
29570 inner << containing_type_name <<
"::*" << input;
29571 result = left.str()+ inner.str();
29591 string d1_name, d2_name;
29608 return d1_name != d2_name;