libabigail
|
Namespace for hashing. More...
Enumerations | |
enum | hashing_state { HASHING_NOT_DONE_STATE , HASHING_STARTED_STATE , HASHING_CYCLED_TYPE_STATE , HASHING_SUBTYPE_STATE , HASHING_FINISHED_STATE } |
Enumeration of the different hashing states of an IR node being hashed. More... | |
Functions | |
hash_t | combine_hashes (hash_t val1, hash_t val2) |
Combine two hash values to produce a third hash value. | |
bool | deserialize_hash (const string &input, uint64_t &hash) |
Read a string of characters representing a string of hexadecimal digits which itself represents a hash value that was computed using the XH64 algorithm from the xxhash project. | |
uint32_t | fnv_hash (const std::string &str) |
Compute a stable string hash. | |
hashing::hashing_state | get_hashing_state (const type_or_decl_base &tod) |
Get the hashing state of an IR node. | |
hash_t | hash (const std::string &str) |
Hash a string. | |
hash_t | hash (std::uint64_t v, std::uint64_t seed=0) |
hash_t | hash (uint64_t v, uint64_t seed) |
Hash an integer value and combine it with a hash previously computed. | |
bool | is_recursive_artefact (const type_or_decl_base &t) |
Test if an artifact is recursive. | |
void | is_recursive_artefact (const type_or_decl_base &t, bool f) |
Set the property that flags an artifact as recursive. | |
bool | serialize_hash (uint64_t hash, string &output) |
Serialiaze a hash value computed using the XH64 algorithm (from the xxhash project) into a string of characters representing the digits of the hash in the canonical form requested by the xxhash project. That canonical form is basically a big endian representation of the hexadecimal hash number. | |
void | set_hashing_state (const type_or_decl_base &tod, hashing::hashing_state s) |
Set the hashing state of an IR node. | |
Namespace for hashing.
enum hashing_state |
Enumeration of the different hashing states of an IR node being hashed.
Enumerator | |
---|---|
HASHING_NOT_DONE_STATE | No hashing has been done/started. |
HASHING_STARTED_STATE | Hashing started but is not yet finished. Note that when a type_or_decl_base::priv::set_hash_value is invoked on an artifact which has this state, then the hash value is set/saved onto the artifact. |
HASHING_CYCLED_TYPE_STATE | A cycle has been detected in the graph on the current node node. This means the hashing has started on the current IR node and while hashing its children nodes, this very same IR node is visited again to be hashed. This is a cycle and it needs to be broken otherwise the hashing continues forever. Note that when a type_or_decl_base::priv::set_hash_value is invoked on an artifact which has this state, then the hash value is set/saved onto the artifact. |
HASHING_SUBTYPE_STATE | Hashing a sub-type while hashing another type. When a type_or_decl_base::hash_value() is invoked on an artifact which has this state, it means the hash value that is computed must NOT be set/saved onto the artifact. type_or_decl_base::priv::set_hash_value is where this is enforced. |
HASHING_FINISHED_STATE | Hashing of given IR node started and is now done. If an ABI artifact is in this state, then it must have an hash value available and should be get by peek_hash_value or type_or_decl_base::hash_value(). |
Definition at line 24 of file abg-hash.h.
Combine two hash values to produce a third hash value.
If one of the hash values is empty then the other one is returned, intact. If the two hash values are empty then an empty hash value is returned as a result.
val1 | the first hash value. |
val2 | the second hash value. |
val1
and val2
. Definition at line 172 of file abg-hash.cc.
bool deserialize_hash | ( | const string & | input, |
uint64_t & | hash ) |
Read a string of characters representing a string of hexadecimal digits which itself represents a hash value that was computed using the XH64 algorithm from the xxhash project.
That string of digit (characters) is laid out in the "canonical form" requested by the xxhash project. That form is basically the hash number, represented in big endian.
input | the input string of characters to consider. |
hash | the resulting hash value de-serialized from input . This is set by the function iff it returns true. |
input
into the hash value hash
. Definition at line 99 of file abg-hash.cc.
uint32_t fnv_hash | ( | const std::string & | str | ) |
Compute a stable string hash.
std::hash has no portability or stability guarantees so is unsuitable where reproducibility is a requirement such as in XML output.
This is the 32-bit FNV-1a algorithm. The algorithm, reference code and constants are all unencumbered. It is fast and has reasonable distribution properties.
https://en.wikipedia.org/wiki/Fowler-Noll-Vo_hash_function
str | the string to hash. |
Definition at line 241 of file abg-hash.cc.
hashing::hashing_state get_hashing_state | ( | const type_or_decl_base & | tod | ) |
Get the hashing state of an IR node.
tod | the type or decl IR node to get the hashing state for. |
tod
. Definition at line 261 of file abg-hash.cc.
hash_t hash | ( | const std::string & | str | ) |
Hash a string.
str | the string to hash. |
Definition at line 219 of file abg-hash.cc.
hash_t hash | ( | uint64_t | v, |
uint64_t | seed ) |
Hash an integer value and combine it with a hash previously computed.
v | the value to hash. |
seed | a previous hash value that is to be combined with the result of hashing v . This is can be zero if no previous hash value is available. |
Definition at line 196 of file abg-hash.cc.
bool is_recursive_artefact | ( | const type_or_decl_base & | t | ) |
Test if an artifact is recursive.
For now, a recursive artifact is a type that contains a sub-type that refers to itself.
t | the artifact to consider. |
t
is recursive. Definition at line 302 of file abg-hash.cc.
void is_recursive_artefact | ( | const type_or_decl_base & | t, |
bool | f ) |
Set the property that flags an artifact as recursive.
For now, a recursive artifact is a type that contains a sub-type that refers to itself.
t | the artifact to consider. |
f | the new value of the flag. If true, then the artefact t is considered recursive. |
Definition at line 327 of file abg-hash.cc.
bool serialize_hash | ( | uint64_t | hash, |
string & | output ) |
Serialiaze a hash value computed using the XH64 algorithm (from the xxhash project) into a string of characters representing the digits of the hash in the canonical form requested by the xxhash project. That canonical form is basically a big endian representation of the hexadecimal hash number.
hash | the hash number to serialize. |
output | the resulting string of characters representing the hash value hash in its serialized form. This is set iff the function return true. |
hash
into a serialized form that is set into the output parameter output
. Definition at line 138 of file abg-hash.cc.
void set_hashing_state | ( | const type_or_decl_base & | tod, |
hashing::hashing_state | s ) |
Set the hashing state of an IR node.
tod | the type or decl IR node to set the hashing state for. |
s | the new hashing state to set. |
Definition at line 280 of file abg-hash.cc.