7.5.2. Class hierarchyΒΆ

The IR representation of an analyzed program is given in form of a graph. Its nodes belong to different classes representing different aspects of the program. Each class defines its own collection of fields, each with a fixed type: they can store attributes (like strings or numbers or bitfields), source code locations (SLocs), or references to nodes. In the latter case the fields actually represent edges in the IR graph. Fields can also store not only single elements but also sets or lists of attributes or nodes.

Each part of the IR has its own class hierarchy and its own subgraph in the IR graph. In the physical part of the IR there exist node classes for representing variable declarations, for example. As another example, in the logical part one can find classes for representing namespaces, whereas in the physical part only node classes for namespace declarations are stored (not for the semantical entity of a namespace itself).

In the following we denote a subgraph of a particular part of the IR just by the term subgraph. Edges between nodes can be either syntactic, semantic, or a cross edge. Each node field that can store node references is of one of these three types.

The syntactic edges form a tree containing all nodes of the corresponding subgraph, and can therefore be used for a simple traversion of the entire subgraph.

Semantic edges however represent facts like a backward reference of a node that represents the use of a variable to the node that represents the variable itself. They do not form a tree in general.

The subgraphs of the different parts of the IR are connected by cross edges: a node representing a namespace declaration in the subgraph of the physical part of the IR for example has a field Logical that refers to the node representing the namespace in the subgraph of the logical part of the IR.

The classes of the IR form a hierarchy: they can inherit fields from a base class. Multiple inheritance is not possible; however, there exist interfaces which represent a (named) set of fields. If a class implements an interface it has to define all fields described by the interface.