libabigail
|
The abstraction of a change between two ABI artifacts, a.k.a an artifact change. More...
#include <abg-comparison.h>
Public Member Functions | |
diff_category | add_to_category (diff_category c) |
Adds the current diff tree node to an additional set of categories. Note that the categories include thoses inherited from the children nodes of this diff node. More... | |
void | add_to_local_and_inherited_categories (diff_category c) |
Adds the current diff tree node to the categories resulting from the local and inherited changes of the current diff node. More... | |
diff_category | add_to_local_category (diff_category c) |
Adds the current diff tree node to the categories resulting from the local changes of the current diff node. More... | |
void | append_child_node (diff_sptr) |
Add a new child node to the vector of children nodes for the current diff node. More... | |
virtual void | chain_into_hierarchy () |
This constructs the relation between this diff node and its detail diff nodes, in the generic view of the diff node. More... | |
const vector< diff * > & | children_nodes () const |
Getter for the children nodes of the current diff node. More... | |
const diff_context_sptr | context () const |
Getter of the context of the current diff. More... | |
void | context (diff_context_sptr c) |
Setter of the context of the current diff. More... | |
bool | currently_reporting () const |
Tests if we are currently in the middle of emitting a report for this diff. More... | |
void | currently_reporting (bool f) const |
Sets a flag saying if we are currently in the middle of emitting a report for this diff. More... | |
type_or_decl_base_sptr | first_subject () const |
Getter of the first subject of the diff. More... | |
diff * | get_canonical_diff () const |
Getter for the canonical diff of the current instance of diff. More... | |
diff_category | get_category () const |
Getter for the category of the current diff tree node. More... | |
diff_category | get_class_of_equiv_category () const |
Getter of the category of the class of equivalence of the current diff tree node. More... | |
diff_category | get_local_category () const |
Getter for the local category of the current diff tree node. More... | |
virtual const string & | get_pretty_representation () const |
Get a pretty representation of the current diff node. More... | |
virtual bool | has_changes () const =0 |
Pure interface to get the length of the changes encapsulated by this diff. A length of zero means that the current instance of diff doesn't carry any change. More... | |
bool | has_descendant_allowed_by_specific_negated_suppression () const |
Test if the current diff node has a descendant node which is specifically allowed by a negated suppression specification. More... | |
virtual enum change_kind | has_local_changes () const =0 |
Pure interface to know if the current instance of @diff carries a local change. A local change is a change that is on the diff object itself, as opposed to a change that is carried by some of its children nodes. More... | |
bool | has_local_changes_to_be_reported () const |
Test if this diff tree node should be reported when considering the categories that were *NOT* inherited from its children nodes. More... | |
bool | has_parent_allowed_by_specific_negated_suppression () const |
Test if the current diff node has a parent node which is specifically allowed by a negated suppression specification. More... | |
bool | is_allowed_by_specific_negated_suppression () const |
Test if this diff node is allowed (prevented from being suppressed) by at least one negated suppression specification. More... | |
bool | is_filtered_out () const |
Test if this diff tree node is to be filtered out for reporting purposes. More... | |
bool | is_filtered_out_without_looking_at_allowed_changes () const |
Test if this diff tree node is to be filtered out for reporting purposes, but without considering the categories that can /force/ the node to be unfiltered. More... | |
bool | is_filtered_out_wrt_non_inherited_categories () const |
Test if this diff tree node is to be filtered out for reporting purposes, but by considering only the categories that were *NOT* inherited from its children nodes. More... | |
bool | is_suppressed () const |
Test if the current diff node has been suppressed by a user-provided suppression specification. More... | |
bool | is_suppressed (bool &is_private_type) const |
Test if the current diff node has been suppressed by a user-provided suppression specification or by an auto-generated "private type" suppression specification. More... | |
bool | is_traversing () const |
Tell if a given node is being traversed or not. More... | |
const diff * | parent_node () const |
Getter for the parent node of the current diff node. More... | |
diff_category | remove_from_category (diff_category c) |
Remove the current diff tree node from an a existing sef of categories. The categories include those inherited from the children nodes of the current diff node. More... | |
diff_category | remove_from_local_category (diff_category c) |
Remove the current diff tree node from the categories resulting from the local changes. More... | |
virtual void | report (ostream &out, const string &indent="") const =0 |
Pure interface to report the diff in a serialized form that is legible for the user. More... | |
bool | reported_once () const |
Tests if a report has already been emitted for the current diff. More... | |
void | reported_once (bool f) const |
Sets a flag saying if a report has already been emitted for the current diff. More... | |
type_or_decl_base_sptr | second_subject () const |
Getter of the second subject of the diff. More... | |
void | set_category (diff_category c) |
Set the category of the current diff node. This category includes the categories inherited from the children nodes of the current diff node. More... | |
void | set_local_category (diff_category c) |
Set the local category of the current diff node. More... | |
bool | to_be_reported () const |
Test if this diff tree node should be reported. More... | |
virtual bool | traverse (diff_node_visitor &v) |
The generic traversing code that walks a given diff sub-tree. More... | |
![]() | |
virtual | ~traversable_base () |
Destructor of the traversable_base type. More... | |
Protected Member Functions | |
diff (type_or_decl_base_sptr first_subject, type_or_decl_base_sptr second_subject) | |
Constructor for the diff type. More... | |
diff (type_or_decl_base_sptr first_subject, type_or_decl_base_sptr second_subject, diff_context_sptr ctxt) | |
Constructor for the diff type. More... | |
void | begin_traversing () |
Flag a given diff node as being traversed. More... | |
bool | do_log () const |
Test if logging was requested. More... | |
void | do_log (bool) |
Request logging (or not) More... | |
void | end_traversing () |
Flag a given diff node as not being traversed anymore. More... | |
virtual void | finish_diff_type () |
Finish the insertion of a diff tree node into the diff graph. More... | |
void | set_canonical_diff (diff *) |
Setter for the canonical diff of the current instance of diff. More... | |
![]() | |
traversable_base () | |
Default constructor of the traversable_base type. More... | |
bool | visiting () const |
This should returns false before and after the node has been visiting. During the visiting of the node (and of its children) this should return true. More... | |
void | visiting (bool f) |
The traversing code should be responsible of calling this, not the user code. More... | |
Protected Attributes | |
std::unique_ptr< priv > | priv_ |
Friends | |
class | diff_context |
The abstraction of a change between two ABI artifacts, a.k.a an artifact change.
In the grand scheme of things, a diff is strongly typed; for instance, a change between two enums is represented by an enum_diff type. A change between two function_type is represented by a function_type_diff type and a change between two class_decl is represented by a class_diff type. All of these types derive from the diff parent class.
An artifact change D can have one (or more) details named D'. A detail is an artifact change that "belongs" to another one. Here, D' belongs to D. Or said otherwise, D' is a child change of D. Said otherwise, D and D' are related, and the relation is a "child relation".
For instance, if we consider a change carried by a class_diff, the detail change might be a change on one data member of the class. In other word, the class_diff change might have a child diff node that would be a var_diff node.
There are two ways to get the child var_diff node (for the data member change detail) of the class_diff.
The first way is through the typed API, that is, through the class_diff::sorted_changed_data_members() member function which returns var_diff nodes.
The second way is through the generic API, that is, through the diff::children_nodes() member function which returns generic diff nodes. This second way enables us to walk the diff nodes graph in a generic way, regardless of the types of the diff nodes.
Said otherwise, there are two views for a given diff node. There is typed view, and there is the generic view. In the typed view, the details are accessed through the typed API. In the generic view, the details are gathered through the generic view.
Please read more about the IR of the comparison engine to learn more about this.
This type encapsulates an edit script (a set of insertions and deletions) for two constructs that are to be diff'ed. The two constructs are called the "subjects" of the diff.
Definition at line 965 of file abg-comparison.h.
|
protected |
Constructor for the diff type.
This constructs a diff between two subjects that are actually declarations; the first and the second one.
first_subject | the first decl (subject) of the diff. |
second_subject | the second decl (subject) of the diff. |
Definition at line 2003 of file abg-comparison.cc.
|
protected |
Constructor for the diff type.
This constructs a diff between two subjects that are actually declarations; the first and the second one.
first_subject | the first decl (subject) of the diff. |
second_subject | the second decl (subject) of the diff. |
ctxt | the context of the diff. Note that this context object must stay alive during the entire life time of the current instance of diff. Otherwise, memory corruption issues occur. |
Definition at line 2024 of file abg-comparison.cc.
diff_category add_to_category | ( | diff_category | c | ) |
Adds the current diff tree node to an additional set of categories. Note that the categories include thoses inherited from the children nodes of this diff node.
c | a bit-map representing the set of categories to add the current diff tree node to. |
Definition at line 2418 of file abg-comparison.cc.
void add_to_local_and_inherited_categories | ( | diff_category | c | ) |
Adds the current diff tree node to the categories resulting from the local and inherited changes of the current diff node.
c | a bit-map representing the set of categories to add the current diff tree node to. |
Definition at line 2445 of file abg-comparison.cc.
diff_category add_to_local_category | ( | diff_category | c | ) |
Adds the current diff tree node to the categories resulting from the local changes of the current diff node.
c | a bit-map representing the set of categories to add the current diff tree node to. |
Definition at line 2433 of file abg-comparison.cc.
void append_child_node | ( | diff_sptr | d | ) |
Add a new child node to the vector of children nodes for the current diff node.
d | the new child node to add to the children nodes. |
Definition at line 2179 of file abg-comparison.cc.
|
protected |
Flag a given diff node as being traversed.
For certain diff nodes like class_diff, it's important to avoid traversing the node again while it's already being traversed; otherwise this leads to infinite loops. So the diff::begin_traversing() and diff::end_traversing() methods flag a given node as being traversed (or not), so that diff::is_traversing() can tell if the node is being traversed.
Note that traversing a node means visiting it *and* visiting its children nodes.
The canonical node is marked as being traversed too.
These functions are called by the traversing code.
Definition at line 2063 of file abg-comparison.cc.
|
virtual |
This constructs the relation between this diff node and its detail diff nodes, in the generic view of the diff node.
Default implementation of the hierachy chaining virtual function.
Each specific typed diff node should implement how the typed view "links" itself to its detail nodes in the generic sense.
There are several types of diff nodes that have logical children nodes; for instance, a typedef_diff has the diff of the underlying type as a child node. A var_diff has the diff of the types of the variables as a child node, etc.
But because the diff base has a generic representation for children nodes of the all the types of diff nodes (regardless of the specific most-derived type of diff node) that one can get using the method diff::children_nodes(), one need to populate that vector of children node.
Populating that vector of children node is done by this function; it must be overloaded by each most-derived type of diff node that extends the diff type.
Reimplemented in typedef_diff, function_decl_diff, function_type_diff, fn_parm_diff, scope_diff, base_diff, class_diff, class_or_union_diff, enum_diff, qualified_type_diff, array_diff, subrange_diff, ptr_to_mbr_diff, reference_diff, pointer_diff, var_diff, and distinct_diff.
Definition at line 2731 of file abg-comparison.cc.
const vector< diff * > & children_nodes | ( | ) | const |
Getter for the children nodes of the current diff node.
Definition at line 2143 of file abg-comparison.cc.
const diff_context_sptr context | ( | ) | const |
Getter of the context of the current diff.
Definition at line 2201 of file abg-comparison.cc.
void context | ( | diff_context_sptr | c | ) |
Setter of the context of the current diff.
c | the new context to set. |
Definition at line 2208 of file abg-comparison.cc.
bool currently_reporting | ( | ) | const |
Tests if we are currently in the middle of emitting a report for this diff.
Definition at line 2217 of file abg-comparison.cc.
void currently_reporting | ( | bool | f | ) | const |
Sets a flag saying if we are currently in the middle of emitting a report for this diff.
f | true if we are currently emitting a report for the current diff, false otherwise. |
Definition at line 2230 of file abg-comparison.cc.
|
protected |
Test if logging was requested.
Definition at line 2037 of file abg-comparison.cc.
|
protected |
Request logging (or not)
f | true iff logging is to be requested. |
Definition at line 2044 of file abg-comparison.cc.
|
protected |
Flag a given diff node as not being traversed anymore.
Note that traversing a node means visiting it *and* visiting its children nodes.
Please read the comments of the function diff::begin_traversing() for mode context.
Definition at line 2098 of file abg-comparison.cc.
|
protectedvirtual |
Finish the insertion of a diff tree node into the diff graph.
This function might be called several times. It must perform the insertion only once.
For instance, certain kinds of diff tree node have specific children nodes that are populated after the constructor of the diff tree node has been called. In that case, calling overloads of this method ensures that these children nodes are properly gathered and setup.
Definition at line 2117 of file abg-comparison.cc.
type_or_decl_base_sptr first_subject | ( | ) | const |
Getter of the first subject of the diff.
Definition at line 2129 of file abg-comparison.cc.
diff * get_canonical_diff | ( | ) | const |
Getter for the canonical diff of the current instance of diff.
Note that the canonical diff node for the current instanc eof diff node must have been set by invoking class_diff::initialize_canonical_diff() on the current instance of diff node.
Definition at line 2163 of file abg-comparison.cc.
diff_category get_category | ( | ) | const |
Getter for the category of the current diff tree node.
This category represents the union of the local category and the categories inherited from the children diff nodes.
Definition at line 2404 of file abg-comparison.cc.
diff_category get_class_of_equiv_category | ( | ) | const |
Getter of the category of the class of equivalence of the current diff tree node.
That is, if the current diff tree node has a canonical node, return the category of that canonical node. Otherwise, return the category of the current node.
Definition at line 2391 of file abg-comparison.cc.
diff_category get_local_category | ( | ) | const |
Getter for the local category of the current diff tree node.
The local category represents the set of categories of a diff node, not taking in account the categories inherited from its children nodes.
Definition at line 2378 of file abg-comparison.cc.
|
virtual |
Get a pretty representation of the current diff node.
This is suitable for e.g. emitting debugging traces for the diff tree nodes.
Reimplemented in typedef_diff, type_decl_diff, function_decl_diff, function_type_diff, fn_parm_diff, scope_diff, base_diff, union_diff, class_diff, enum_diff, qualified_type_diff, array_diff, subrange_diff, ptr_to_mbr_diff, reference_diff, pointer_diff, var_diff, and distinct_diff.
Definition at line 2707 of file abg-comparison.cc.
|
pure virtual |
Pure interface to get the length of the changes encapsulated by this diff. A length of zero means that the current instance of diff doesn't carry any change.
This is to be implemented by all descendants of this type.
Implemented in translation_unit_diff, typedef_diff, type_decl_diff, function_decl_diff, function_type_diff, fn_parm_diff, scope_diff, base_diff, class_diff, class_or_union_diff, enum_diff, qualified_type_diff, array_diff, subrange_diff, ptr_to_mbr_diff, reference_diff, pointer_diff, var_diff, and distinct_diff.
bool has_descendant_allowed_by_specific_negated_suppression | ( | ) | const |
Test if the current diff node has a descendant node which is specifically allowed by a negated suppression specification.
Definition at line 2682 of file abg-comparison.cc.
|
pure virtual |
Pure interface to know if the current instance of @diff carries a local change. A local change is a change that is on the diff object itself, as opposed to a change that is carried by some of its children nodes.
This is to be implemented by all descendants of this type.
Implemented in decl_diff_base, type_diff_base, translation_unit_diff, typedef_diff, type_decl_diff, function_decl_diff, function_type_diff, fn_parm_diff, scope_diff, base_diff, class_diff, class_or_union_diff, enum_diff, qualified_type_diff, array_diff, subrange_diff, ptr_to_mbr_diff, reference_diff, pointer_diff, var_diff, and distinct_diff.
bool has_local_changes_to_be_reported | ( | ) | const |
Test if this diff tree node should be reported when considering the categories that were *NOT* inherited from its children nodes.
Definition at line 2647 of file abg-comparison.cc.
bool has_parent_allowed_by_specific_negated_suppression | ( | ) | const |
Test if the current diff node has a parent node which is specifically allowed by a negated suppression specification.
Definition at line 2694 of file abg-comparison.cc.
bool is_allowed_by_specific_negated_suppression | ( | ) | const |
Test if this diff node is allowed (prevented from being suppressed) by at least one negated suppression specification.
Definition at line 2661 of file abg-comparison.cc.
bool is_filtered_out | ( | ) | const |
Test if this diff tree node is to be filtered out for reporting purposes.
There is a difference between a diff node being filtered out and being suppressed. Being suppressed means that there is a suppression specification that suppresses the diff node specifically. Being filtered out mean the node is either suppressed, or it's filtered out because the suppression of a set of (children) nodes caused this node to be filtered out as well. For instance, if a function diff has all its children diff nodes suppressed and if the function diff node carries no local change, then the function diff node itself is going to be filtered out.
The function tests if the categories of the diff tree node are "forbidden" by the context or not.
Definition at line 2517 of file abg-comparison.cc.
bool is_filtered_out_without_looking_at_allowed_changes | ( | ) | const |
Test if this diff tree node is to be filtered out for reporting purposes, but without considering the categories that can /force/ the node to be unfiltered.
The function tests if the categories of the diff tree node are "forbidden" by the context or not.
Definition at line 2558 of file abg-comparison.cc.
bool is_filtered_out_wrt_non_inherited_categories | ( | ) | const |
Test if this diff tree node is to be filtered out for reporting purposes, but by considering only the categories that were *NOT* inherited from its children nodes.
The function tests if the local categories of the diff tree node are "forbidden" by the context or not.
Definition at line 2544 of file abg-comparison.cc.
bool is_suppressed | ( | ) | const |
Test if the current diff node has been suppressed by a user-provided suppression specification.
Definition at line 2574 of file abg-comparison.cc.
bool is_suppressed | ( | bool & | is_private_type | ) | const |
Test if the current diff node has been suppressed by a user-provided suppression specification or by an auto-generated "private type" suppression specification.
Note that private type suppressions are auto-generated from the path to where public headers are, as given by the user.
Here is the current algorithm:
First, suppress this diff node if it's not matched by any negated suppression specifications. If it's not suppressed, then suppress it if it's matched by direct suppression specifications.
is_private_type | out parameter if the current diff node was suppressed because it's a private type then this parameter is set to true. |
Definition at line 2601 of file abg-comparison.cc.
bool is_traversing | ( | ) | const |
Tell if a given node is being traversed or not.
Note that traversing a node means visiting it *and* visiting its children nodes.
It's the canonical node which is looked at, actually.
Please read the comments for the diff::begin_traversing() for mode context.
Definition at line 2083 of file abg-comparison.cc.
const diff * parent_node | ( | ) | const |
Getter for the parent node of the current diff node.
Definition at line 2150 of file abg-comparison.cc.
diff_category remove_from_category | ( | diff_category | c | ) |
Remove the current diff tree node from an a existing sef of categories. The categories include those inherited from the children nodes of the current diff node.
c | a bit-map representing the set of categories to add the current diff tree node to. |
Definition at line 2462 of file abg-comparison.cc.
diff_category remove_from_local_category | ( | diff_category | c | ) |
Remove the current diff tree node from the categories resulting from the local changes.
c | a bit-map representing the set of categories to add the current diff tree node to. |
Definition at line 2477 of file abg-comparison.cc.
|
pure virtual |
Pure interface to report the diff in a serialized form that is legible for the user.
Note that the serializd report has to leave one empty line at the end of its content.
out | the output stream to serialize the report to. |
indent | the indentation string to use. |
Implemented in translation_unit_diff, type_decl_diff, scope_diff, var_diff, distinct_diff, typedef_diff, function_decl_diff, function_type_diff, fn_parm_diff, base_diff, union_diff, class_diff, class_or_union_diff, enum_diff, qualified_type_diff, array_diff, subrange_diff, ptr_to_mbr_diff, reference_diff, and pointer_diff.
bool reported_once | ( | ) | const |
Tests if a report has already been emitted for the current diff.
Definition at line 2242 of file abg-comparison.cc.
void reported_once | ( | bool | f | ) | const |
Sets a flag saying if a report has already been emitted for the current diff.
f | true if a report has already been emitted for the current diff, false otherwise. |
Definition at line 2363 of file abg-comparison.cc.
type_or_decl_base_sptr second_subject | ( | ) | const |
Getter of the second subject of the diff.
Definition at line 2136 of file abg-comparison.cc.
|
protected |
Setter for the canonical diff of the current instance of diff.
d | the new canonical node to set. |
Definition at line 2171 of file abg-comparison.cc.
void set_category | ( | diff_category | c | ) |
Set the category of the current diff node. This category includes the categories inherited from the children nodes of the current diff node.
c | the new category for the current diff node. |
Definition at line 2489 of file abg-comparison.cc.
void set_local_category | ( | diff_category | c | ) |
Set the local category of the current diff node.
c | the new category for the current diff node. |
Definition at line 2496 of file abg-comparison.cc.
bool to_be_reported | ( | ) | const |
Test if this diff tree node should be reported.
Definition at line 2635 of file abg-comparison.cc.
|
virtual |
The generic traversing code that walks a given diff sub-tree.
Note that there is a difference between traversing a diff node and visiting it. Basically, traversing a diff node means visiting it and visiting its children nodes too. So one can visit a node without traversing it. But traversing a node without visiting it is not possible.
Note that the insertion of the "generic view" of the diff node into the graph being traversed is done "on the fly". The insertion of the "typed view" of the diff node into the graph is done implicitely. To learn more about the generic and typed view of the diff node, please read the introductory comments of the diff class.
Note that by default this traversing code visits a given class of equivalence of a diff node only once. This behaviour can been changed by calling diff_context::visiting_a_node_twice_is_forbidden(), but this is very risky as it might create endless loops while visiting a diff tree graph that has changes that refer to themselves; that is, diff tree graphs with cycles.
When a diff node is encountered, the diff_node_visitor::visit_begin() method is invoked on the diff node first.
If the diff node has already been visited, then node_visitor::visit_end() is called on it and the node traversing is done; the children of the diff node are not visited in this case.
If the diff node has *NOT* been visited yet, then the diff_node_visitor::visit() method is invoked with it's 'pre' argument set to true. Then if the diff_node_visitor::visit() returns true, then the children nodes of the diff node are visited. Otherwise, no children nodes of the diff node is visited and the diff_node_visitor::visit_end() is called. After the children nodes are visited (and only if they are visited) the diff_node_visitor::visit() method is invoked with it's 'pre' argument set to false. And then the diff_node_visitor::visit_end() is called.
v | the entity that visits each node of the diff sub-tree. |
Reimplemented from diff_traversable_base.
Definition at line 2298 of file abg-comparison.cc.