Is_Initialized_Helper_Variable

class Is_Initialized_Helper_Variable (concrete, logical)

Helper variable (always of type bool) used to keep track if a temporary has been initialized. This is used when temporaries are created within a conditional expression, e.g.:

bool foo(bool x);
bool bar(bool x) {
   return foo(x || get_string().empty());
}

In this example, the std::string destructor is called after the foo() call, but only if it was initialized (= if x is false).

Direct parents:
Ancestor classes and implemented interfaces:

Declarative_Node, General_Object_Interface, Helper_Variable, Initialization_Start_End_Interface, Logical_IR_Root, Named_Entity, Object, Stack_Object, Symbol, Typed_Object, Variable

Field

Kind

Type

Description

Temporary

semantic

class Init_Helper_Variable

The associated temporary object.

Initialization (from Variable)

semantic

class Instruction

If there is either:

  1. A single instruction that uses a Direct_Full_Write_Operand to initialize the variable, or

  2. A Direct_Call_Instruction calling a constructor that fully initializes the variable

then the Initialization edge will point to that instruction. Otherwise, it will be null.

Because constructors return type void, the two cases can be distinguished by checking whether Initialization.Left is NoNode.

Note that the variable can still be modified after it is initialized. Only when (!has_definition && !address_taken), it is guaranteed that the variable’s value is equal to that computed by the Initialization instruction.

Its_Type (from Typed_Object)

semantic

class Type

the normalized, ‘underlying’ type

Object_Flags (from Typed_Object)

attribute

bitfield Object_Flags_Type

bits like “address taken” and “is pointer”

Parent (from Logical_IR_Root)

semantic

class Logical_IR_Root

Physical (from Logical_IR_Root)

semantic to physical

class Physical_IR_Root

Initialization_Start (from Initialization_Start_End_Interface)

semantic

class Execution_Node

Start of the variable’s initialization. If set to an instruction, that instruction is part of the variable’s initialization. If set to a block, the variable’s initialization begins with the tail jump of that block, but does not include the block’s code. Use is_part_of_variable_initialization() to determine if an instruction is between Initialization_Start and Initialization_End.

Initialization_End (from Initialization_Start_End_Interface)

semantic

class Execution_Node

If set to an instruction, it is the first instruction after those responsible for the variable’s initialization. If set to a block, the initialization includes all instructions in that block but not the block’s tail jump. In other words: A block is used to refer to the “instruction-after-last” in that block; all instructions between Initialization_Start (inclusive) to Initialization_End (exclusive) belong to the variable’s initializer. If Initialization_Start==Initialization_End, then the variable has no initializer.

Name (from Named_Entity)

attribute

builtin String