The Medium-level Intermediate Representation (MIR) representation falls between source code and object code. The conceptual parts of MIR are:
- Nodes of the control-flow graph. Every node is either a conditional node, switch node, leaf node, or expression node.
- Edges of the control-flow graph, representing control-flow between nodes.
- Expression nodes, similar in nature to abstract syntax trees (AST) for expressions. Each node may contain a read expression (right-hand side) and write expression (left-hand side).
- Memory items, which are conceptual objects that represent some abstract location in memory. Not every possible memory location is represented by a memory item. For example, there are no memory items for individual array elements, only for the whole array. A memory item is an object that allows value tracking across multiple nodes. Expressions cannot be used to do this because every node has a unique instance of an expression. However, it is possible to extract memory items from two expressions and see if they are the same.
- Semantic information, which describes the program data and types. This information is somewhat limited compared to semantic information that can be derived using the Code Style Analysis API.
- Value constraints, which are constraints on integer values inferred by the Klocwork engine. You can query the Klocwork C/C++ Path API Reference PDF about whether values for certain memory items lie within some specific range.
The MIR is built separately for each function and class method.