6.5.3.1. Views

C++ RFGs contain the same views as C RFGs (see Language Representation for C), since the C++ language model is an extended C model. C++ RFGs contain the following:

  • a Code Facts view,

  • a Module view,

  • an Environment view,

  • a Call view,

  • an Entries view,

  • a Declaration Facts view,

  • a File view,

  • a Declaration Call view,

  • a Declaration Environment view, and

  • an Include view.

Analyses might enrich the RFG with further views (e.g., a Dead/Alive view).

Code Facts View

The Code Facts view contains nodes and edges for the definitions of the analyzed system. In C++ RFGs, it additionally covers class hierarchies, member functions, templates and their instantiations, and namespace structures, all of which extend the corresponding C model.

Module View

The Module view contains the file and directory hierarchy of the system under analysis. The leaves are nodes from the Code Facts view. It groups source entities by the translation unit (module) in which they are defined.

Environment View

The Environment view contains the subset of nodes from the Code Facts view that stem from the environment (libraries, system headers, etc.) rather than from the source code directly under analysis.

Call View

The Call view contains the subset of the Code Facts view consisting of the node-routine Routine nodes and edge-call Call edges. In C++ RFGs, this includes member functions, constructors, destructors, and function template instantiations. It is useful for detecting call cycles in the program.

Entries View

The Entries view contains the entry points of the program. Initially, it contains only the artificial node-routine Routine node .entry, from which artificial edge-static-call Static_Call edges lead to main and to the artificial routines .init and .fini. The EntryPoints rules add further entry points to this view. Analyses such as dead code analysis consider the nodes in this view as initially alive.

Declaration Facts View

The Declaration Facts view contains nodes and edges for the declarations and definitions of the analyzed system. Unlike the Code Facts view, which focuses on definitions, the Declaration Facts view also captures forward declarations, making it suitable for architecture analyses that treat header-file interfaces as class or module boundaries.

File View

The File view contains directory and file nodes representing the code files of the analyzed project. Nested within a source file F are all nodes representing source entities from the Declaration Facts view that are contained in F.

Declaration Call View

The Declaration Call view is the counterpart of the Call view for the Declaration Facts view. It contains the routine nodes and edge-call Call edges of the Declaration Facts view as well as the edge-declare Declare edges between these routine nodes.

Declaration Environment View

The Declaration Environment view contains the subset of nodes from the Declaration Facts view that stem from the environment (libraries, system headers, etc.) rather than from the source code directly under analysis.

Include View

The Include view contains directory and file nodes. It illustrates how code files include one another, reflecting the #include directive relationships between translation units.

Note

For some analyses, you need a pair of views: one containing the dependency information (i.e., the source dependency edges) and one containing the hierarchy information. You can choose between the pairs Code Facts/ Module and Declaration Facts/ File. Other combinations of these views do not make sense in general.

Which pair you choose depends on the appropriate elements for the analysis.

  • If, e.g., your architecture depends on “modules” that can be used as a whole, choose the Code Facts/ Module pair.

  • If, on the other hand, your architecture depends on declarations that are made visible in header files (as some kind of interfaces), choose the Declaration Facts/ File pair.

  • If your architecture actively uses declarations for interfacing (e.g., “I state my need for some function that must be defined somewhere else”), also choose the Declaration Facts/ File pair.