Tree to keep track of the destructors generated along each branch of a function. More...
#include <scope_tree.h>
os in dot format. Tree to keep track of the destructors generated along each branch of a function.
Used to compare and find out what dead instructions are needed when moving from one branch to another.
For example, if you had this code:
object a; if (enabled) object b; object c; else object e;
It would generate a tree like this:
-> b -> c
Root -> a -> e
Where each split represents a different block and each letter represents the destructor codet for that particular variable.
To find out anything interesting you need to get a node ID (currently only got by calling get_current_node at a particular point in the tree) and then use that later to compare against a different point in the tree.
So if I took note of the nodes at the end of each branch (c, e) and wanted to compare them, I'd find that 'a' is the common ancestor, and the steps required to get there from 'c' was 2 and 'e' was 1, which also tells you if a certain branch is a prefix or not. In this case neither are a prefix of the other.
Definition at line 92 of file scope_tree.h.
Definition at line 114 of file scope_tree.h.
Adds a destructor/declaration pair to the current stack, attaching it to the current node.
Definition at line 11 of file scope_tree.cpp.
Walks the current node down to its child.
Definition at line 100 of file scope_tree.cpp.
Gets the node that the next addition will be added to as a child.
Definition at line 109 of file scope_tree.cpp.
Fetches the declaration value for the passed-in node index.
Definition at line 31 of file scope_tree.cpp.
Fetches the destructor value for the passed-in node index.
Definition at line 24 of file scope_tree.cpp.
{},
{}
Builds a vector of destructors that start from starting_index and ends at end_index.
Definition at line 68 of file scope_tree.cpp.
Finds the nearest common ancestor of two nodes and then returns it.
This should be used when you want to find out what parts of the two branches are common to each other.
Definition at line 37 of file scope_tree.cpp.
Output scope tree to os in dot format.
Definition at line 169 of file scope_tree.h.
Sets the current node.
Next time a node is added to the stack it will be added as a child of this node.
Definition at line 95 of file scope_tree.cpp.
Sets the current node.
Next time a node is added to the stack it will be added as a child of this node. If passed an empty index, no assignment will be done.
Definition at line 89 of file scope_tree.cpp.
Definition at line 197 of file scope_tree.h.
Definition at line 196 of file scope_tree.h.