6.5.2.2. Nodes (Entities)

In the following we describe the possible types of nodes contained in C RFGs. In general it holds that if node type B inherits from a node type A, nodes of type B can also have attributes that are defined for A.

A node either represents an entity in the source code (e.g., a global variable), or describes one or more units of the file system, like a file, a directory, or a module.

Common Attributes for all Node Types

Source.Name

The Source.Name (of type string) is the name the entity possesses in the source code. If an entity does not have a name, for instance anonymous structs or unions, their name will be a question mark ?.

Linkage.Name

The Linkage.Name (of type string) unambiguously identifies the entity within one RFG.

Source.File, Source.Path, Source.Line, Source.Column

These four attributes characterize the source location of the definition of the entity, or one of the declarations if no definition has been seen at all. Source.File and Source.Path are of type string, Source.Line and Source.Column are of type int.

The option -B of cafeCC influences the prefix of the path used in the source location information, see Tool Reference.

Note

If there is no definition, one of the possibly multiple declarations is arbitrarily chosen for the source location. This happens if a system is only partially analyzed. This also happens for elements that originate in a library where you do not have the source code but only the header files.

Caution

Please note that types in C/C++ generally do not have a single point of definition throughout a system unless defined in a single header file, so for them, one of the source locations of their definitions is arbitrarily chosen.

Note

As long as any entity has a unique point of declaration (only in one header or C source file), the source location information will be the same, no matter which order of translation and linking of the system is performed.

Source.Region_Start, Source.Region_Length

: These attributes denote the start line and length (in lines) of the source entity. Both attributes are of type int.

Source.Physical_File, Source.Physical_Path

: These attributes characterize the actual source location in the presence of #line directives.

Source.Physical_Region_Start, Source.Physical_Region_Length

: These attributes denote the actual start line and length (in lines) of the source entity in the presence of #line directives.

Element.Has_Ambiguous_Declaration

This attribute of type toggle indicates that there is more than one declaration for the represented entity. This is only used for typedefs and undefined entities.

Note

Nodes that have Element.Has_Ambiguous_Declaration are ignored in the architecture analysis because they will most likely lead to confusing results.

Linkage.Is_Definition

The attribute of type toggle indicates whether the node represents a definition (toggle set) or a declaration (toggle unset).

For nodes in the Code Facts view holds the following: Nodes that do not possess this attribute are from the environment (e.g., printf) or in parts of the system under analysis that are not yet analyzed. If you create partial RFG files for IR libraries or single unit files, the parts that are not inside the partial RFG are also not marked with Linkage.Is_Definition.

For nodes in the Declaration Facts view holds the following: Nodes that do possess this attribute are definitions, nodes that do not posses this attributes are declarations. There is a edge-declare Declare edge from a declaration to its matching definition.

Linkage.LIR_Node, Linkage.PIR_Node

In an RFG generated by Architecture-Dependencies, the nodes in the Code Facts view have the Linkage.LIR_Node attribute. Nodes in the Declaration Facts view have the Linkage.PIR_Node attribute. These attributes create a mapping between the nodes in the RFG file and the nodes in the IR file it has been created from.

Class

node-class Class (inherits from: node-type Type)

Subtypes

none

Containing Views

Code Facts, Declaration Facts, File, Module

Description

A node-class Class represents the user-defined C type constructs struct, union, and enum.

Attributes

Attribute name

Attribute type

Inherited from

Element.Is_Anonymous

Toggle

-

Element.Is_Enum

Toggle

-

Element.Is_Struct

Toggle

-

Element.Is_Typedef_To_Anonymous

Toggle

-

Element.Is_Union

Toggle

-

Linkage.Is_Definition

Toggle

-

Element.Has_Ambiguous_Declaration

Toggle

Type

Element.Is_Anonymous

Toggle

Type

Element.Is_Enum

Toggle

Type

Element.Is_Struct

Toggle

Type

Element.Is_Typedef_To_Anonymous

Toggle

Type

Element.Is_Union

Toggle

Type

Linkage.Is_Ambiguous_Name

Toggle

Source_Entity

Linkage.Is_Definition

Toggle

Source_Entity

Linkage.LIR_Node

Integer

Source_Entity

Linkage.Name

String

Source_Entity

Linkage.PIR_Node

Integer

Source_Entity

Source.Body_End_Column

Integer

Source_Entity

Source.Body_End_Line

Integer

Source_Entity

Source.Body_Start_Column

Integer

Source_Entity

Source.Body_Start_Line

Integer

Source_Entity

Source.Column

Integer

Source_Entity

Source.Declaration_Start

Integer

Source_Entity

Source.File

String

Source_Entity

Source.Line

Integer

Source_Entity

Source.Name

String

Source_Entity

Source.Path

String

Source_Entity

Source.Physical_File

String

Source_Entity

Source.Physical_Path

String

Source_Entity

Source.Physical_Region_Length

Integer

Source_Entity

Source.Physical_Region_Start

Integer

Source_Entity

Source.Region_Length

Integer

Source_Entity

Source.Region_Start

Integer

Source_Entity

Source.Signature_Start

Integer

Source_Entity

The appropriate toggle attribute Element.Is_Struct is_struct-icon, Element.Is_Union is_union-icon, and Element.Is_Enum is_enum-icon is set to indicate the exact kind of modelled type.

Note

The struct, union, and enum constructs are represented as classes to facilitate linking of parts of a system written in C and C++.

Note

Code Example

struct {
int i;
} global_variable;
Example: Unnamed struct.

Example: Unnamed struct.

Constant

node-constant Constant (inherits from: node-object Object)

Subtypes

none

Containing Views

Code Facts, Declaration Facts, File, Module

Description

A node-constant Constant represents an enumerator constant; it is contained in the node representing its enumeration type by edge-enclosing Enclosing edges.

Attributes

Attribute name

Attribute type

Inherited from

Element.Is_Static

Toggle

Object

Linkage.Is_Ambiguous_Name

Toggle

Source_Entity

Linkage.Is_Definition

Toggle

Source_Entity

Linkage.LIR_Node

Integer

Source_Entity

Linkage.Name

String

Source_Entity

Linkage.PIR_Node

Integer

Source_Entity

Source.Body_End_Column

Integer

Source_Entity

Source.Body_End_Line

Integer

Source_Entity

Source.Body_Start_Column

Integer

Source_Entity

Source.Body_Start_Line

Integer

Source_Entity

Source.Column

Integer

Source_Entity

Source.Declaration_Start

Integer

Source_Entity

Source.File

String

Source_Entity

Source.Line

Integer

Source_Entity

Source.Name

String

Source_Entity

Source.Path

String

Source_Entity

Source.Physical_File

String

Source_Entity

Source.Physical_Path

String

Source_Entity

Source.Physical_Region_Length

Integer

Source_Entity

Source.Physical_Region_Start

Integer

Source_Entity

Source.Region_Length

Integer

Source_Entity

Source.Region_Start

Integer

Source_Entity

Source.Signature_Start

Integer

Source_Entity

Note

Code Example

enum NameOfEnum
{
    someEnumerator,
    anotherName
    // ...
};
Example: Enum type with two enumerator values.

Example: Enum type with two enumerator values.

Directory

node-directory Directory (inherits from: node-file-system-entity File_System_Entity)

Subtypes

none

Containing Views

File, Include, Module

Description

In addition to the language representation, the Axivion Suite captures the containment of declarations/definitions in modules, files, and directories.

A node-directory Directory represents a directory in the file system. A node-directory Directory node can contain node-file File nodes, node-module Module nodes, and node-directory Directory nodes depending on the kind of view.

Attributes

Attribute name

Attribute type

Inherited from

Linkage.Name

String

File_System_Entity

Linkage.PIR_Node

Integer

File_System_Entity

Source.Column

Integer

File_System_Entity

Source.File

String

File_System_Entity

Source.Line

Integer

File_System_Entity

Source.Name

String

File_System_Entity

Source.Path

String

File_System_Entity

Source.Physical_File

String

File_System_Entity

Source.Physical_Path

String

File_System_Entity

Source.Physical_Region_Length

Integer

File_System_Entity

Source.Physical_Region_Start

Integer

File_System_Entity

Source.Region_Length

Integer

File_System_Entity

Source.Region_Start

Integer

File_System_Entity

File

node-file File (inherits from: node-file-system-entity File_System_Entity)

Subtypes

none

Containing Views

File, Include

Description

A node-file File node represents a source file. It contains all declarations and definitions by incoming edge-enclosing Enclosing edges. A node-file File node itself may be contained in a node-directory Directory node. The path is expressed by the hierarchy of node-directory Directory nodes.

Attributes

Attribute name

Attribute type

Inherited from

Element.Is_Preinclude_File

Toggle

-

Element.Is_System_Header

Toggle

-

Linkage.Name

String

File_System_Entity

Linkage.PIR_Node

Integer

File_System_Entity

Source.Column

Integer

File_System_Entity

Source.File

String

File_System_Entity

Source.Line

Integer

File_System_Entity

Source.Name

String

File_System_Entity

Source.Path

String

File_System_Entity

Source.Physical_File

String

File_System_Entity

Source.Physical_Path

String

File_System_Entity

Source.Physical_Region_Length

Integer

File_System_Entity

Source.Physical_Region_Start

Integer

File_System_Entity

Source.Region_Length

Integer

File_System_Entity

Source.Region_Start

Integer

File_System_Entity

The Source.Name of a node-file File node is the name of the file in the file system (with extension).

File_System_Entity

node-file-system-entity File_System_Entity

Subtypes

node-directory Directory, node-file File, node-module Module

Containing Views

none (only subtypes of node-file-system-entity File_System_Entity are contained in views)

Description

The node-file-system-entity File_System_Entity node type is the base type of all nodes representing entities of the file system, like directories, files, and modules.

Attributes

Attribute name

Attribute type

Inherited from

Linkage.Name

String

-

Linkage.PIR_Node

Integer

-

Source.Column

Integer

-

Source.File

String

-

Source.Line

Integer

-

Source.Name

String

-

Source.Path

String

-

Source.Physical_File

String

-

Source.Physical_Path

String

-

Source.Physical_Region_Length

Integer

-

Source.Physical_Region_Start

Integer

-

Source.Region_Length

Integer

-

Source.Region_Start

Integer

-

Macro

node-macro Macro (inherits from: node-object Source_Entity)

Subtypes

none

Containing Views

Call, Code Facts, Declaration Facts, File, Module

Description

A node-macro Macro node represents a macro in the C/C++ language.

Macros are often used like constants and inline functions and the Axivion Suite tries to get as close as possible to allow analyzing such code. On the other hand, heavy use of token pasting etc. leads to very detailed invocation trees.

The treatment of macros can be configured, see option macro_options.represent_macros of rule /Analysis/Architecture/Architecture-Dependencies.

Note

Because macro expansion can lead to different expansions in different contexts, you may see more macro nodes than you would expect on first sight from the source code.

Attributes

Attribute name

Attribute type

Inherited from

Linkage.Is_Ambiguous_Name

Toggle

Source_Entity

Linkage.Is_Definition

Toggle

Source_Entity

Linkage.LIR_Node

Integer

Source_Entity

Linkage.Name

String

Source_Entity

Linkage.PIR_Node

Integer

Source_Entity

Source.Body_End_Column

Integer

Source_Entity

Source.Body_End_Line

Integer

Source_Entity

Source.Body_Start_Column

Integer

Source_Entity

Source.Body_Start_Line

Integer

Source_Entity

Source.Column

Integer

Source_Entity

Source.Declaration_Start

Integer

Source_Entity

Source.File

String

Source_Entity

Source.Line

Integer

Source_Entity

Source.Name

String

Source_Entity

Source.Path

String

Source_Entity

Source.Physical_File

String

Source_Entity

Source.Physical_Path

String

Source_Entity

Source.Physical_Region_Length

Integer

Source_Entity

Source.Physical_Region_Start

Integer

Source_Entity

Source.Region_Length

Integer

Source_Entity

Source.Region_Start

Integer

Source_Entity

Source.Signature_Start

Integer

Source_Entity

Member

node-member Member (inherits from: node-object Source_Entity)

Subtypes

none

Containing Views

Code Facts, Declaration Facts, File, Module

Description

A node-member Member represents components of structs and unions. Member nodes are contained in the respective type by edge-enclosing Enclosing edges leading from the member to the type as depicted in Figure  Example: Type with enclosed member nodes shown flat and hierarchically.. In hierarchical graph windows of gravis, the containment is shown by the layout of the members inside the rectangle representing the interior of a type.

Note

A component of an enum is represented as a Constant.

Attributes

Attribute name

Attribute type

Inherited from

Element.Has_Public_Visibility

Toggle

-

Element.Is_Anonymous

Toggle

-

Element.Is_Const

Toggle

-

Linkage.Is_Ambiguous_Name

Toggle

Source_Entity

Linkage.Is_Definition

Toggle

Source_Entity

Linkage.LIR_Node

Integer

Source_Entity

Linkage.Name

String

Source_Entity

Linkage.PIR_Node

Integer

Source_Entity

Source.Body_End_Column

Integer

Source_Entity

Source.Body_End_Line

Integer

Source_Entity

Source.Body_Start_Column

Integer

Source_Entity

Source.Body_Start_Line

Integer

Source_Entity

Source.Column

Integer

Source_Entity

Source.Declaration_Start

Integer

Source_Entity

Source.File

String

Source_Entity

Source.Line

Integer

Source_Entity

Source.Name

String

Source_Entity

Source.Path

String

Source_Entity

Source.Physical_File

String

Source_Entity

Source.Physical_Path

String

Source_Entity

Source.Physical_Region_Length

Integer

Source_Entity

Source.Physical_Region_Start

Integer

Source_Entity

Source.Region_Length

Integer

Source_Entity

Source.Region_Start

Integer

Source_Entity

Source.Signature_Start

Integer

Source_Entity

A node-member Member in a C RFG is always tagged with the attribute Element.Has_Public_Visibility (has_public_visibility-icon).

Note

Code Example

Example: Type with enclosed member nodes shown flat and hierarchically.

Example: Type with enclosed member nodes shown flat and hierarchically.

Module

node-module Module (inherits from: node-file-system-entity File_System_Entity)

Subtypes

none

Containing Views

Module

Description

A node-module Module M represents the combination of a C source file M.c and its corresponding header file M.h. A node-module Module contains all definitions in the corresponding files by incoming edge-enclosing Enclosing edges. It may be contained in a node-directory Directory node.

Attributes

Attribute name

Attribute type

Inherited from

Linkage.Name

String

File_System_Entity

Linkage.PIR_Node

Integer

File_System_Entity

Source.Column

Integer

File_System_Entity

Source.File

String

File_System_Entity

Source.Line

Integer

File_System_Entity

Source.Name

String

File_System_Entity

Source.Path

String

File_System_Entity

Source.Physical_File

String

File_System_Entity

Source.Physical_Path

String

File_System_Entity

Source.Physical_Region_Length

Integer

File_System_Entity

Source.Physical_Region_Start

Integer

File_System_Entity

Source.Region_Length

Integer

File_System_Entity

Source.Region_Start

Integer

File_System_Entity

The Source.Name of a node-module Module is the name of the corresponding source file(s) without extension.

Object

node-object Object (inherits from: node-object Source_Entity)

Subtypes

node-constant Constant, node-variable Variable

Containing Views

none (only subtypes of node-object Object are contained in views)

Description

node-object Object specializes into node-variable Variable which represents global variables and node-constant Constant which represents global constants and enumerator constants.

Attributes

Attribute name

Attribute type

Inherited from

Element.Is_Static

Toggle

-

Linkage.Is_Ambiguous_Name

Toggle

Source_Entity

Linkage.Is_Definition

Toggle

Source_Entity

Linkage.LIR_Node

Integer

Source_Entity

Linkage.Name

String

Source_Entity

Linkage.PIR_Node

Integer

Source_Entity

Source.Body_End_Column

Integer

Source_Entity

Source.Body_End_Line

Integer

Source_Entity

Source.Body_Start_Column

Integer

Source_Entity

Source.Body_Start_Line

Integer

Source_Entity

Source.Column

Integer

Source_Entity

Source.Declaration_Start

Integer

Source_Entity

Source.File

String

Source_Entity

Source.Line

Integer

Source_Entity

Source.Name

String

Source_Entity

Source.Path

String

Source_Entity

Source.Physical_File

String

Source_Entity

Source.Physical_Path

String

Source_Entity

Source.Physical_Region_Length

Integer

Source_Entity

Source.Physical_Region_Start

Integer

Source_Entity

Source.Region_Length

Integer

Source_Entity

Source.Region_Start

Integer

Source_Entity

Source.Signature_Start

Integer

Source_Entity

The toggle attribute Element.Is_Static ( is_static-icon ) indicates whether the variable is declared static.

Routine

node-routine Routine (inherits from: node-object Source_Entity)

Subtypes

none

Containing Views

Call, Code Facts, Declaration Facts, File, Module

Description

A node-routine Routine represents a C function.

Attributes

Attribute name

Attribute type

Inherited from

Analysis.Dead_Code

Toggle

-

Element.Has_Ambiguous_Declaration

Toggle

-

Element.Has_Ellipsis

Toggle

-

Element.Is_Anonymous

Toggle

-

Element.Is_Artificial

Toggle

-

Element.Is_Destructor

Toggle

-

Element.Is_Inline

Toggle

-

Element.Is_Interrupt

Toggle

-

Element.Is_Static

Toggle

-

Linkage.Is_Ambiguous_Name

Toggle

Source_Entity

Linkage.Is_Definition

Toggle

Source_Entity

Linkage.LIR_Node

Integer

Source_Entity

Linkage.Name

String

Source_Entity

Linkage.PIR_Node

Integer

Source_Entity

Source.Body_End_Column

Integer

Source_Entity

Source.Body_End_Line

Integer

Source_Entity

Source.Body_Start_Column

Integer

Source_Entity

Source.Body_Start_Line

Integer

Source_Entity

Source.Column

Integer

Source_Entity

Source.Declaration_Start

Integer

Source_Entity

Source.File

String

Source_Entity

Source.Line

Integer

Source_Entity

Source.Name

String

Source_Entity

Source.Path

String

Source_Entity

Source.Physical_File

String

Source_Entity

Source.Physical_Path

String

Source_Entity

Source.Physical_Region_Length

Integer

Source_Entity

Source.Physical_Region_Start

Integer

Source_Entity

Source.Region_Length

Integer

Source_Entity

Source.Region_Start

Integer

Source_Entity

Source.Signature_Start

Integer

Source_Entity

A node-routine Routine has the attribute Element.Number_Of_Parameters of type Integer which contains the number of parameters of the routine. The toggle attribute Element.Is_Static ( is_static-icon ) indicates whether the function is declared static.

Note

Code Example

void f(void)
{
}

static void g(void)
{
}
Example: Routines.

Example: Routines.

Source_Entity

node-object Source_Entity

Subtypes

node-macro Macro, node-member Member, node-object Object, node-routine Routine, node-type Type

Containing Views

none (only subtypes of node-object Source_Entity are contained in views)

Description

The node-object Source_Entity node type is the base type of all source-related entities like types, routines, variables, and members.

Attributes

Attribute name

Attribute type

Inherited from

Linkage.Is_Ambiguous_Name

Toggle

-

Linkage.Is_Definition

Toggle

-

Linkage.LIR_Node

Integer

-

Linkage.Name

String

-

Linkage.PIR_Node

Integer

-

Source.Body_End_Column

Integer

-

Source.Body_End_Line

Integer

-

Source.Body_Start_Column

Integer

-

Source.Body_Start_Line

Integer

-

Source.Column

Integer

-

Source.Declaration_Start

Integer

-

Source.File

String

-

Source.Line

Integer

-

Source.Name

String

-

Source.Path

String

-

Source.Physical_File

String

-

Source.Physical_Path

String

-

Source.Physical_Region_Length

Integer

-

Source.Physical_Region_Start

Integer

-

Source.Region_Length

Integer

-

Source.Region_Start

Integer

-

Source.Signature_Start

Integer

-

Type

node-type Type (inherits from: node-object Source_Entity)

Subtypes

node-class Class

Containing Views

Code Facts, Declaration Facts, File, Module

Description

A node-type Type represents a user-defined C type alias introduced by typedef, as well as enum types.

Attributes

Attribute name

Attribute type

Inherited from

Element.Has_Ambiguous_Declaration

Toggle

-

Element.Is_Anonymous

Toggle

-

Element.Is_Enum

Toggle

-

Element.Is_Struct

Toggle

-

Element.Is_Typedef_To_Anonymous

Toggle

-

Element.Is_Union

Toggle

-

Linkage.Is_Ambiguous_Name

Toggle

Source_Entity

Linkage.Is_Definition

Toggle

Source_Entity

Linkage.LIR_Node

Integer

Source_Entity

Linkage.Name

String

Source_Entity

Linkage.PIR_Node

Integer

Source_Entity

Source.Body_End_Column

Integer

Source_Entity

Source.Body_End_Line

Integer

Source_Entity

Source.Body_Start_Column

Integer

Source_Entity

Source.Body_Start_Line

Integer

Source_Entity

Source.Column

Integer

Source_Entity

Source.Declaration_Start

Integer

Source_Entity

Source.File

String

Source_Entity

Source.Line

Integer

Source_Entity

Source.Name

String

Source_Entity

Source.Path

String

Source_Entity

Source.Physical_File

String

Source_Entity

Source.Physical_Path

String

Source_Entity

Source.Physical_Region_Length

Integer

Source_Entity

Source.Physical_Region_Start

Integer

Source_Entity

Source.Region_Length

Integer

Source_Entity

Source.Region_Start

Integer

Source_Entity

Source.Signature_Start

Integer

Source_Entity

If the configuration option node_options.merge_typedef_to_anonymous of rule Architecture-Dependencies is set to True (which is the default), the node for the typedef defining a type name for an anonymous struct or union subsumes the definition of the anonymous type and gets the toggle Element.Is_Typedef_To_Anonymous attached. If the configuration key is set to False, the type node representing the typedef is not marked by the above mentioned toggle.

If toggle attribute Element.Is_Anonymous is attached, the type has been declared without a name (see the following example).

Note

The RFG does not represent primitive types such as float and int. However, typedefs to primitive types are represented.

Note

Code Example

struct Struct {
  int field;
  // ...
};

union Union {
  int field;
  // ...
};

enum Enum {
  enumerator
  // ...
};
Example: Structures, unions, and enumerations in C.

Example: Structures, unions, and enumerations in C.

Variable

node-variable Variable (inherits from: node-object Object)

Subtypes

none

Containing Views

Code Facts, Declaration Facts, File, Module

Description

A node-variable Variable represents global variables (also const, static and volatile ones).

Note

Bauhaus does not extract local variables at the RFG level because they are the secret of routines and therefore not relevant at the architectural level.

Attributes

Attribute name

Attribute type

Inherited from

Element.Has_Ambiguous_Declaration

Toggle

-

Element.Is_Const

Toggle

-

Element.Is_Static

Toggle

-

Element.Is_Volatile

Toggle

-

Element.Is_Static

Toggle

Object

Linkage.Is_Ambiguous_Name

Toggle

Source_Entity

Linkage.Is_Definition

Toggle

Source_Entity

Linkage.LIR_Node

Integer

Source_Entity

Linkage.Name

String

Source_Entity

Linkage.PIR_Node

Integer

Source_Entity

Source.Body_End_Column

Integer

Source_Entity

Source.Body_End_Line

Integer

Source_Entity

Source.Body_Start_Column

Integer

Source_Entity

Source.Body_Start_Line

Integer

Source_Entity

Source.Column

Integer

Source_Entity

Source.Declaration_Start

Integer

Source_Entity

Source.File

String

Source_Entity

Source.Line

Integer

Source_Entity

Source.Name

String

Source_Entity

Source.Path

String

Source_Entity

Source.Physical_File

String

Source_Entity

Source.Physical_Path

String

Source_Entity

Source.Physical_Region_Length

Integer

Source_Entity

Source.Physical_Region_Start

Integer

Source_Entity

Source.Region_Length

Integer

Source_Entity

Source.Region_Start

Integer

Source_Entity

Source.Signature_Start

Integer

Source_Entity

Note

Code Example

/* We are in the global scope */
int globalvariable;
Example: Global variable.

Example: Global variable.