9#include "abg-internal.h"
11ABG_BEGIN_EXPORT_DECLARATIONS
16ABG_END_EXPORT_DECLARATIONS
26#define abigail_hash_mix(a, b, c) \
28 a -= b; a -= c; a ^= (c>>13); \
29 b -= c; b -= a; b ^= (a<< 8); \
30 c -= a; c -= b; c ^= ((b&0xffffffff)>>13); \
31 a -= b; a -= c; a ^= ((c&0xffffffff)>>12); \
32 b -= c; b -= a; b = (b ^ (a<<16)) & 0xffffffff; \
33 c -= a; c -= b; c = (c ^ (b>> 5)) & 0xffffffff; \
34 a -= b; a -= c; a = (a ^ (c>> 3)) & 0xffffffff; \
35 b -= c; b -= a; b = (b ^ (a<<10)) & 0xffffffff; \
36 c -= a; c -= b; c = (c ^ (b>>15)) & 0xffffffff; \
40combine_hashes(
size_t val1,
size_t val2)
43 size_t a = 0x9e3779b9;
44 abigail_hash_mix(a, val1, val2);
67 const uint32_t offset_basis = 0x811c9dc5;
69 for (std::string::const_iterator i = str.begin(); i != str.end(); ++i)
95type_base::hash::operator()(
const type_base& t)
const
97 std::hash<size_t> size_t_hash;
98 std::hash<string> str_hash;
100 size_t v = str_hash(
typeid(t).name());
114{
return operator()(*t);}
122type_base::hash::operator()(
const type_base_sptr t)
const
123{
return operator()(*t);}
125struct decl_base::hash
130 std::hash<string> str_hash;
132 size_t v = str_hash(
typeid(d).name());
151 decl_base::hash decl_hash;
153 std::hash<string> str_hash;
155 size_t v = str_hash(
typeid(t).name());
156 v = hashing::combine_hashes(v, decl_hash(t));
157 v = hashing::combine_hashes(v, type_hash(t));
171 std::hash<string> hash_string;
172 size_t v = hash_string(
typeid(d).name());
173 for (scope_decl::declarations::const_iterator i =
177 v = hashing::combine_hashes(v, (*i)->get_hash());
189{
return d? operator()(*d) : 0;}
196 decl_base::hash decl_hash;
198 std::hash<string> str_hash;
200 size_t v = str_hash(
typeid(t).name());
201 v = hashing::combine_hashes(v, decl_hash(t));
202 v = hashing::combine_hashes(v, type_hash(t));
214 decl_base::hash decl_hash;
215 std::hash<string> str_hash;
217 size_t v = str_hash(
typeid(t).name());
218 v = hashing::combine_hashes(v, type_hash(t));
219 v = hashing::combine_hashes(v, decl_hash(t));
230 std::hash<string> str_hash;
232 decl_base::hash decl_hash;
235 size_t v = str_hash(
typeid(t).name());
236 v = hashing::combine_hashes(v, decl_hash(t));
237 v = hashing::combine_hashes(v, type_base_hash(t));
248 std::hash<string> hash_str;
250 decl_base::hash hash_decl;
253 size_t v = hash_str(
typeid(t).name());
254 v = hashing::combine_hashes(v, hash_str(t.is_lvalue()
257 v = hashing::combine_hashes(v, hash_type_base(t));
258 v = hashing::combine_hashes(v, hash_decl(t));
259 v = hashing::combine_hashes(v, hash_type_ptr(t.get_pointed_to_type()));
269 std::hash<int> hash_size_t;
281 std::hash<string> hash_str;
283 decl_base::hash hash_decl;
287 size_t v = hash_str(
typeid(t).name());
289 v = hashing::combine_hashes(v, hash_type_base(t));
290 v = hashing::combine_hashes(v, hash_decl(t));
293 for (vector<array_type_def::subrange_sptr >::const_iterator i =
297 v = hashing::combine_hashes(v, hash_subrange(**i));
308 std::hash<string> str_hash;
309 decl_base::hash decl_hash;
311 std::hash<size_t> size_t_hash;
313 size_t v = str_hash(
typeid(t).name());
314 v = hashing::combine_hashes(v, decl_hash(t));
316 for (enum_type_decl::enumerators::const_iterator i =
321 v = hashing::combine_hashes(v, str_hash(i->get_name()));
322 v = hashing::combine_hashes(v, size_t_hash(i->get_value()));
333 std::hash<string> str_hash;
335 decl_base::hash decl_hash;
338 size_t v = str_hash(
typeid(t).name());
339 v = hashing::combine_hashes(v,
hash_type(t));
340 v = hashing::combine_hashes(v, decl_hash(t));
359 std::hash<string> hash_string;
360 decl_base::hash hash_decl;
362 std::hash<size_t> hash_size_t;
364 size_t v = hash_string(
typeid(t).name());
365 v = hashing::combine_hashes(v, hash_decl(t));
366 v = hashing::combine_hashes(v, hash_type_ptr(t.
get_type()));
370 v = hashing::combine_hashes(v, hash_decl(*t.
get_scope()));
384{
return operator()(*t);}
398 std::hash<int> hash_int;
399 std::hash<size_t> hash_size_t;
400 std::hash<bool> hash_bool;
401 std::hash<string> hash_string;
402 decl_base::hash hash_decl_base;
405 size_t v = hash_string(
typeid(t).name());
406 v = hashing::combine_hashes(v, hash_decl_base(t));
407 v = hashing::combine_hashes(v, hash_type_ptr(t.
get_type()));
409 v = hashing::combine_hashes(v, hash_int(t.get_binding()));
418 v = hashing::combine_hashes(v, hash_bool(is_ctor));
419 v = hashing::combine_hashes(v, hash_bool(is_dtor));
420 v = hashing::combine_hashes(v, hash_bool(is_static));
421 v = hashing::combine_hashes(v, hash_bool(is_const));
422 if (!is_static && !is_ctor)
423 v = hashing::combine_hashes(v, hash_size_t(voffset));
436{
return operator()(*t);}
439function_decl::parameter::hash::operator()
443 std::hash<bool> hash_bool;
444 std::hash<unsigned> hash_unsigned;
445 size_t v = hash_type_ptr(p.get_type());
446 v = hashing::combine_hashes(v, hash_unsigned(p.get_index()));
447 v = hashing::combine_hashes(v, hash_bool(p.get_variadic_marker()));
452function_decl::parameter::hash::operator()
454{
return operator()(*p);}
457function_decl::parameter::hash::operator()
459{
return operator()(p.get());}
467 std::hash<string> hash_string;
471 size_t v = hash_string(
typeid(t).name());
473 v = hashing::combine_hashes(v, hash_string(class_name));
475 vector<shared_ptr<function_decl::parameter> >::const_iterator i =
479 v = hashing::combine_hashes(v, hash_parameter(**i));
486 {
return operator()(*t);}
490 {
return operator()(t.get());}
503 std::hash<string> hash_string;
507 size_t v = hash_string(
typeid(t).name());
509 for (vector<shared_ptr<function_decl::parameter> >::const_iterator i =
513 v = hashing::combine_hashes(v, hash_parameter(**i));
530 return operator()(*t);
540{
return operator()(t.get());}
545member_base::hash::operator()(
const member_base& m)
const
547 std::hash<int> hash_int;
552class_decl::base_spec::hash::operator()(
const base_spec& t)
const
556 std::hash<size_t> hash_size;
557 std::hash<bool> hash_bool;
558 std::hash<string> hash_string;
560 size_t v = hash_string(
typeid(t).name());
561 v = hashing::combine_hashes(v, hash_member(t));
562 v = hashing::combine_hashes(v, hash_size(t.get_offset_in_bits()));
563 v = hashing::combine_hashes(v, hash_bool(t.get_is_virtual()));
564 v = hashing::combine_hashes(v, hash_type_ptr(t.get_base_class()));
569member_function_template::hash::operator()
572 std::hash<bool> hash_bool;
575 std::hash<string> hash_string;
577 size_t v = hash_member(t);
578 string n = t.get_qualified_name();
579 v = hashing::combine_hashes(v, hash_string(n));
580 v = hashing::combine_hashes(v, hash_function_tdecl(t));
581 v = hashing::combine_hashes(v, hash_bool(t.is_constructor()));
582 v = hashing::combine_hashes(v, hash_bool(t.is_const()));
587member_class_template::hash::operator()
592 std::hash<string> hash_string;
594 size_t v = hash_member(t);
595 string n = t.get_qualified_name();
596 v = hashing::combine_hashes(v, hash_string(n));
597 v = hashing::combine_hashes(v, hash_class_tdecl(t));
623 size_t v = operator()
630 std::hash<string> hash_string;
636 size_t v = hash_string(
typeid(t).name());
637 v = hashing::combine_hashes(v, hash_scope_type(t));
642 for (class_decl::data_members::const_iterator d =
646 v = hashing::combine_hashes(v, hash_data_member(**d));
653 for (member_function_templates::const_iterator f =
657 v = hashing::combine_hashes(v, hash_member_fn_tmpl(**f));
660 for (member_class_templates::const_iterator c =
664 v = hashing::combine_hashes(v, hash_member_class_tmpl(**c));
678{
return t ? operator()(*t) : 0;}
709 std::hash<string> hash_string;
713 size_t v = hash_string(
typeid(t).name());
718 for (class_decl::base_specs::const_iterator b =
724 v = hashing::combine_hashes(v, hash_base(**b));
727 v = hashing::combine_hashes(v, hash_class_or_union(t));
741{
return t ? operator()(*t) : 0;}
743struct template_parameter::hash
753 if (t.get_hashing_has_started())
756 t.set_hashing_has_started(
true);
758 std::hash<unsigned> hash_unsigned;
759 std::hash<std::string> hash_string;
762 size_t v = hash_string(
typeid(t).name());
763 v = hashing::combine_hashes(v, hash_unsigned(t.get_index()));
764 v = hashing::combine_hashes(v, hash_template_decl
765 (*t.get_enclosing_template_decl()));
767 t.set_hashing_has_started(
false);
773struct template_parameter::dynamic_hash
779struct template_parameter::shared_ptr_hash
782 operator()(
const shared_ptr<template_parameter> t)
const
783 {
return template_parameter::dynamic_hash()(t.get());}
789 std::hash<string> hash_string;
790 template_parameter::shared_ptr_hash hash_template_parameter;
792 size_t v = hash_string(
typeid(t).name());
795 for (list<template_parameter_sptr>::const_iterator p =
799 if (!(*p)->get_hashing_has_started())
800 v = hashing::combine_hashes(v, hash_template_parameter(*p));
810 std::hash<string> hash_string;
811 template_parameter::hash hash_template_parameter;
814 size_t v = hash_string(
typeid(t).name());
815 v = hashing::combine_hashes(v, hash_template_parameter(t));
816 v = hashing::combine_hashes(v,
hash_type(t));
830 template_parameter::hash hash_template_parameter;
831 std::hash<string> hash_string;
834 size_t v = hash_string(
typeid(t).name());
835 v = hashing::combine_hashes(v, hash_template_parameter(t));
836 v = hashing::combine_hashes(v, hash_string(t.
get_name()));
849{
return t ? operator()(*t) : 0;}
856 std::hash<string> hash_string;
860 size_t v = hash_string(
typeid(t).name());
861 v = hashing::combine_hashes(v, hash_template_type_parm(t));
862 v = hashing::combine_hashes(v, hash_template_decl(t));
869template_parameter::dynamic_hash::
883 return template_parameter::hash()(*t);
894 std::hash<string> hash_string;
897 size_t v = hash_string(
typeid(t).name());
909{
return t ? operator()(*t): 0;}
912function_tdecl::hash::
915 std::hash<string> hash_string;
916 decl_base::hash hash_decl_base;
920 size_t v = hash_string(
typeid(t).name());
922 v = hashing::combine_hashes(v, hash_decl_base(t));
923 v = hashing::combine_hashes(v, hash_template_decl(t));
925 v = hashing::combine_hashes(v, hash_function_decl(*t.
get_pattern()));
931function_tdecl::shared_ptr_hash::
932operator()(
const shared_ptr<function_tdecl> f)
const
936 return hash_fn_tmpl_decl(*f);
944 std::hash<string> hash_string;
945 decl_base::hash hash_decl_base;
949 size_t v = hash_string(
typeid(t).name());
950 v = hashing::combine_hashes(v, hash_decl_base(t));
951 v = hashing::combine_hashes(v, hash_template_decl(t));
953 v = hashing::combine_hashes(v, hash_class_decl(*t.
get_pattern()));
959class_tdecl::shared_ptr_hash::
960operator()(
const shared_ptr<class_tdecl> t)
const
965 return hash_class_tmpl_decl(*t);
1035type_base::shared_ptr_hash::operator()(
const shared_ptr<type_base> t)
const
#define ABG_ASSERT(cond)
This is a wrapper around the 'assert' glibc call. It allows for its argument to have side effects,...
Types of the main internal representation of libabigail.
bool empty() const
Test if the current instance of interned_string is empty.
Abstraction for an array range type, like in Ada, or just for an array dimension like in C or C++.
int64_t get_upper_bound() const
Getter of the upper bound of the subrange type.
int64_t get_lower_bound() const
Getter of the lower bound of the subrange type.
The abstraction of an array type.
const type_base_sptr get_element_type() const
Getter of the type of an array element.
const std::vector< subrange_sptr > & get_subranges() const
Get the array's subranges.
Abstracts a class declaration.
const base_specs & get_base_specifiers() const
Get the base specifiers for this class.
The base type of class_decl and union_decl.
const member_function_templates & get_member_function_templates() const
Get the member function templates of this class.
const data_members & get_non_static_data_members() const
Get the non-static data memebers of this class_or_union.
const member_class_templates & get_member_class_templates() const
Get the member class templates of this class.
Abstract a class template.
shared_ptr< class_decl > get_pattern() const
Getter of the pattern of the template.
The base type of all declarations.
scope_decl * get_scope() const
Return the type containing the current decl, if any.
friend bool get_member_is_static(const decl_base &d)
Gets a flag saying if a class member is static or not.
virtual void get_qualified_name(interned_string &qualified_name, bool internal=false) const
Compute the qualified name of the decl.
const interned_string & get_name() const
Getter for the name of the current decl.
const decl_base_sptr get_definition_of_declaration() const
If this decl_base is declaration-only, get its definition, if any.
bool get_is_declaration_only() const
Test if a decl_base is a declaration-only decl.
const interned_string & get_linkage_name() const
Getter for the mangled name.
friend enum access_specifier get_member_access_specifier(const decl_base &d)
Gets the access specifier for a class member.
Abstracts a declaration for an enum type.
const enumerators & get_enumerators() const
type_base_sptr get_underlying_type() const
Return the underlying type of the enum.
Abstraction of a function parameter.
Abstraction for a function declaration.
shared_ptr< parameter > parameter_sptr
Convenience typedef for a shared pointer on a function_decl::parameter.
const function_type_sptr get_type() const
Return the type of the current instance of function_decl.
bool is_declared_inline() const
Test if the function was declared inline.
Abstract a function template declaration.
shared_ptr< function_decl > get_pattern() const
Get the pattern of the function template.
Abstraction of a function type.
type_base_sptr get_return_type() const
Getter for the return type of the current instance of function_type.
parameters::const_iterator get_first_non_implicit_parm() const
Get the first parameter of the function.
const parameters & get_parameters() const
Getter for the set of parameters of the current intance of function_type.
The base class for member types, data members and member functions. Its purpose is mainly to carry th...
access_specifier get_access_specifier() const
Getter for the access specifier of this member.
Abstracts a member class template template.
Abstract a member function template.
Abstracts the type of a class member function.
class_or_union_sptr get_class_type() const
Get the class type this method belongs to.
Abstracts non type template parameters.
const type_base_sptr get_type() const
Getter for the type of the template parameter.
The abstraction of a pointer type.
const type_base_sptr get_pointed_to_type() const
Getter of the pointed-to type.
The abstraction of a qualified type.
CV get_cv_quals() const
Getter of the const/volatile qualifier bit field.
Abstracts a reference type.
A declaration that introduces a scope.
const declarations & get_member_decls() const
Getter for the member declarations carried by the current scope_decl.
A type that introduces a scope.
The base class of templates.
const std::list< template_parameter_sptr > & get_template_parameters() const
Get the list of template parameters of the current instance of template_decl.
Base class for a template parameter. Client code should use the more specialized type_template_parame...
Abstracts a template template parameter.
An abstraction helper for type declarations.
virtual size_t get_size_in_bits() const
Getter for the size of the type.
virtual size_t get_alignment_in_bits() const
Getter for the alignment of the type.
This abstracts a composition of types based on template type parameters. The result of the compositio...
const type_base_sptr get_composed_type() const
Getter for the resulting composed type.
A basic type declaration that introduces no scope.
friend class_decl * is_class_type(const type_or_decl_base *)
Test whether a type is a class.
bool hashing_started() const
Getter for the 'hashing_started' property.
Abstracts a type template parameter.
The abstraction of a typedef declaration.
type_base_sptr get_underlying_type() const
Getter of the underlying type of the typedef.
Abstracts a union type declaration.
Abstracts a variable declaration.
const type_base_sptr get_type() const
Getter of the type of the variable.
uint32_t fnv_hash(const std::string &str)
Compute a stable string hash.
The namespace of the internal representation of ABI artifacts like types and decls.
bool get_member_function_is_dtor(const function_decl &f)
Test whether a member function is a destructor.
shared_ptr< method_type > method_type_sptr
Convenience typedef for shared pointer to method_type.
size_t hash_type(const type_base *t)
Hash an ABI artifact that is either a type.
ssize_t get_member_function_vtable_offset(const function_decl &f)
Get the vtable offset of a member function.
class_or_union * is_class_or_union_type(const type_or_decl_base *t)
Test if a type is a class_or_union.
shared_ptr< class_decl > class_decl_sptr
Convenience typedef for a shared pointer on a class_decl.
shared_ptr< function_type > function_type_sptr
Convenience typedef for a shared pointer on a function_type.
bool get_data_member_is_laid_out(const var_decl &m)
Test whether a data member is laid out.
bool get_member_function_is_const(const function_decl &f)
Test whether a member function is const.
bool is_member_function(const function_decl &f)
Test whether a function_decl is a member function.
uint64_t get_data_member_offset(const var_decl &m)
Get the offset of a data member.
bool is_data_member(const var_decl &v)
Test if a var_decl is a data member.
bool is_member_decl(const decl_base_sptr d)
Tests if a declaration is a class member.
bool get_member_function_is_ctor(const function_decl &f)
Test whether a member function is a constructor.
Toplevel namespace for libabigail.
The hashing functor for class_decl::base_spec.
Hasher for the class_decl type.
size_t operator()(const class_decl &t) const
Compute a hash for a class_decl.
Hasher for the class_or_union type.
size_t operator()(const class_or_union &t) const
Compute a hash for a class_or_union.
A hashing functor fo instances and pointers of function_decl.
size_t operator()(const function_decl &t) const
Compute a hash value for an instance of function_decl.
A hashing functor for a function_decl::parameter.
The hashing functor for function_type.
size_t operator()(const function_type &t) const
Hashing function for function_type.
The hashing functor for member_base.
The hashing functor for member_class_template.
The hashing functor for member_function_template.
Hasher for the non_type_tparameter type.
size_t operator()(const non_type_tparameter &t) const
Compute a hash value for a non_type_tparameter.
Hasher for the scope_decl type.
size_t operator()(const type_base *t) const
A hashing function for type declarations.
Hash functor for instances of type_base.
size_t operator()(const type_composition &t) const
Compute a hash value for a type_composition type.
A hashing functor for instances and pointers of var_decl.