CBMC
c_types_util.h File Reference

This file contains functions, that should support test for underlying c types, in cases where this is required for analysis purpose. More...

#include "arith_tools.h"
#include "invariant.h"
#include "std_types.h"
#include "type.h"
#include <algorithm>
#include <string>
+ Include dependency graph for c_types_util.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool is_c_char_type (const typet &type)
 This function checks, whether this has been a char type in the c program. More...
 
bool is_c_bool_type (const typet &type)
 This function checks, whether the type has been a bool type in the c program. More...
 
bool is_c_integral_type (const typet &type)
 This function checks, whether the type has been some kind of integer type in the c program. More...
 
bool is_c_char_pointer_type (const typet &type)
 This function checks, whether type is a pointer and the target type of the pointer has been a char type in the c program. More...
 
bool is_c_integral_pointer_type (const typet &type)
 This function checks, whether type is a pointer and the target type has been some kind of int type in the c program. More...
 
bool is_c_enum_type (const typet &type)
 This function checks, whether the type has been an enum type in the c program. More...
 
constant_exprt convert_member_name_to_enum_value (const irep_idt &member_name, const c_enum_typet &c_enum)
 This function creates a constant representing the bitvector encoded integer value of a string in the enum. More...
 
bool id2boolean (const std::string &bool_value)
 Convert id to a Boolean value. More...
 
constant_exprt from_c_boolean_value (bool bool_value, const typet &type)
 This function creates a constant representing either 0 or 1 as value of type type. More...
 

Detailed Description

This file contains functions, that should support test for underlying c types, in cases where this is required for analysis purpose.

Definition in file c_types_util.h.

Function Documentation

◆ convert_member_name_to_enum_value()

constant_exprt convert_member_name_to_enum_value ( const irep_idt member_name,
const c_enum_typet c_enum 
)
inline

This function creates a constant representing the bitvector encoded integer value of a string in the enum.

Parameters
member_nameis a string that should be in the enum.
c_enumthe enum type member_name is supposed to be part of.
Returns
constant, that could be assigned as the value of an expression with type c_enum.

Definition at line 85 of file c_types_util.h.

◆ from_c_boolean_value()

constant_exprt from_c_boolean_value ( bool  bool_value,
const typet type 
)
inline

This function creates a constant representing either 0 or 1 as value of type type.

Parameters
bool_valueA Boolean value.
typeThe type, the resulting constant is supposed to have.
Returns
a constant of type type with either 0 or 1 as value.

Definition at line 122 of file c_types_util.h.

◆ id2boolean()

bool id2boolean ( const std::string &  bool_value)
inline

Convert id to a Boolean value.

Parameters
bool_valueA string that is compared to "true" ignoring case.
Returns
a constant of type Boolean

Definition at line 105 of file c_types_util.h.

◆ is_c_bool_type()

bool is_c_bool_type ( const typet type)
inline

This function checks, whether the type has been a bool type in the c program.

Definition at line 35 of file c_types_util.h.

◆ is_c_char_pointer_type()

bool is_c_char_pointer_type ( const typet type)
inline

This function checks, whether type is a pointer and the target type of the pointer has been a char type in the c program.

Definition at line 57 of file c_types_util.h.

◆ is_c_char_type()

bool is_c_char_type ( const typet type)
inline

This function checks, whether this has been a char type in the c program.

Definition at line 25 of file c_types_util.h.

◆ is_c_enum_type()

bool is_c_enum_type ( const typet type)
inline

This function checks, whether the type has been an enum type in the c program.

Definition at line 74 of file c_types_util.h.

◆ is_c_integral_pointer_type()

bool is_c_integral_pointer_type ( const typet type)
inline

This function checks, whether type is a pointer and the target type has been some kind of int type in the c program.

is_c_int_derivate answers is used for checking the int type.

Definition at line 66 of file c_types_util.h.

◆ is_c_integral_type()

bool is_c_integral_type ( const typet type)
inline

This function checks, whether the type has been some kind of integer type in the c program.

It considers the signed and unsigned verison of int, short, long and long long as integer types in c.

Definition at line 44 of file c_types_util.h.