CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
refined_string_type.h
Go to the documentation of this file.
1/********************************************************************\
2
3Module: Type for string expressions used by the string solver.
4 These string expressions contain a field `length`, of type
5 `index_type`, a field `content` of type `content_type`.
6 This module also defines functions to recognise the C and java
7 string types.
8
9Author: Romain Brenguier, romain.brenguier@diffblue.com
10
11\*******************************************************************/
12
18
19#ifndef CPROVER_UTIL_REFINED_STRING_TYPE_H
20#define CPROVER_UTIL_REFINED_STRING_TYPE_H
21
22#include "cprover_prefix.h"
23#include "std_types.h"
24
25class pointer_typet;
26
27// Internal type used for string refinement
29{
30public:
32 const typet &index_type,
34
35 // Type for the content (list of characters) of a string
37 {
38 PRECONDITION(components().size()==2);
39 return to_array_type(components()[1].type());
40 }
41
42 const typet &get_char_type() const
43 {
44 return get_content_type().element_type();
45 }
46
47 const typet &get_index_type() const
48 {
49 PRECONDITION(components().size()==2);
50 return components()[0].type();
51 }
52};
53
54inline bool is_refined_string_type(const typet &type)
55{
56 return
57 type.id()==ID_struct &&
58 to_struct_type(type).get_tag()==CPROVER_PREFIX"refined_string_type";
59}
60
62 const typet &type)
63{
65 return static_cast<const refined_string_typet &>(type);
66}
67
68#endif
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
Arrays with given size.
Definition std_types.h:807
const irep_idt & id() const
Definition irep.h:388
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
const typet & get_index_type() const
const array_typet & get_content_type() const
const typet & get_char_type() const
Structure type, corresponds to C style structs.
Definition std_types.h:231
const componentst & components() const
Definition std_types.h:147
The type of an expression, extends irept.
Definition type.h:29
#define CPROVER_PREFIX
bool is_refined_string_type(const typet &type)
const refined_string_typet & to_refined_string_type(const typet &type)
#define PRECONDITION(CONDITION)
Definition invariant.h:463
Pre-defined types.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
Definition std_types.h:308
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
Definition std_types.h:888