cprover
validate_types.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Validate types
4 
5 Author: Daniel Poetzl
6 
7 \*******************************************************************/
8 
9 #include "validate_types.h"
10 
11 #ifdef REPORT_UNIMPLEMENTED_TYPE_CHECKS
12 #include <iostream>
13 #endif
14 
15 #include "namespace.h"
16 #include "std_types.h"
17 #include "type.h"
18 #include "validate.h"
19 #include "validate_helpers.h"
20 
21 #define CALL_ON_TYPE(type_type) \
22  C<typet, type_type>()(type, std::forward<Args>(args)...)
23 
24 template <template <typename, typename> class C, typename... Args>
25 void call_on_type(const typet &type, Args &&... args)
26 {
27  if(type.id() == ID_bv)
28  {
30  }
31  else if(type.id() == ID_unsignedbv)
32  {
34  }
35  else if(type.id() == ID_signedbv)
36  {
38  }
39  else if(type.id() == ID_fixedbv)
40  {
42  }
43  else if(type.id() == ID_floatbv)
44  {
46  }
47  else if(type.id() == ID_pointer)
48  {
50  }
51  else if(type.id() == ID_c_bool)
52  {
54  }
55  else
56  {
57 #ifdef REPORT_UNIMPLEMENTED_TYPE_CHECKS
58  std::cerr << "Unimplemented well-formedness check for type with id: "
59  << type.id_string() << std::endl;
60 #endif
61 
63  }
64 }
65 
74 void check_type(const typet &type, const validation_modet vm)
75 {
76  call_on_type<call_checkt>(type, vm);
77 }
78 
88  const typet &type,
89  const namespacet &ns,
90  const validation_modet vm)
91 {
92  call_on_type<call_validatet>(type, ns, vm);
93 }
94 
104  const typet &type,
105  const namespacet &ns,
106  const validation_modet vm)
107 {
108  call_on_type<call_validate_fullt>(type, ns, vm);
109 }
CALL_ON_TYPE
#define CALL_ON_TYPE(type_type)
Definition: validate_types.cpp:21
validate_full_type
void validate_full_type(const typet &type, const namespacet &ns, const validation_modet vm)
Check that the given type is well-formed (full check, including checks of subtypes)
Definition: validate_types.cpp:103
typet
The type of an expression, extends irept.
Definition: type.h:29
floatbv_typet
Fixed-width bit-vector with IEEE floating-point interpretation.
Definition: std_types.h:1379
namespace.h
unsignedbv_typet
Fixed-width bit-vector with unsigned binary interpretation.
Definition: std_types.h:1216
type.h
Defines typet, type_with_subtypet and type_with_subtypest.
c_bool_typet
The C/C++ Booleans.
Definition: std_types.h:1604
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:92
call_on_type
void call_on_type(const typet &type, Args &&... args)
Definition: validate_types.cpp:25
check_type
void check_type(const typet &type, const validation_modet vm)
Check that the given type is well-formed (shallow checks only, i.e., subtypes are not checked)
Definition: validate_types.cpp:74
signedbv_typet
Fixed-width bit-vector with two's complement interpretation.
Definition: std_types.h:1265
std_types.h
Pre-defined types.
irept::id_string
const std::string & id_string() const
Definition: irep.h:421
validation_modet
validation_modet
Definition: validation_mode.h:13
irept::id
const irep_idt & id() const
Definition: irep.h:418
fixedbv_typet
Fixed-width bit-vector with signed fixed-point interpretation.
Definition: std_types.h:1318
validate_type
void validate_type(const typet &type, const namespacet &ns, const validation_modet vm)
Check that the given type is well-formed, assuming that its subtypes have already been checked for we...
Definition: validate_types.cpp:87
validate_helpers.h
validate.h
pointer_typet
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
Definition: std_types.h:1488
validate_types.h
bv_typet
Fixed-width bit-vector without numerical interpretation.
Definition: std_types.h:1106