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 "bitvector_types.h"
16 #include "c_types.h"
17 #include "pointer_expr.h"
18 #include "validate_helpers.h"
19 
20 #define CALL_ON_TYPE(type_type) \
21  C<typet, type_type>()(type, std::forward<Args>(args)...)
22 
23 template <template <typename, typename> class C, typename... Args>
24 void call_on_type(const typet &type, Args &&... args)
25 {
26  if(type.id() == ID_bv)
27  {
29  }
30  else if(type.id() == ID_unsignedbv)
31  {
33  }
34  else if(type.id() == ID_signedbv)
35  {
37  }
38  else if(type.id() == ID_fixedbv)
39  {
41  }
42  else if(type.id() == ID_floatbv)
43  {
45  }
46  else if(type.id() == ID_pointer)
47  {
48  if(type.get_bool(ID_C_reference))
50  else
52  }
53  else if(type.id() == ID_c_bool)
54  {
56  }
57  else if(type.id() == ID_array)
58  {
60  }
61  else
62  {
63 #ifdef REPORT_UNIMPLEMENTED_TYPE_CHECKS
64  std::cerr << "Unimplemented well-formedness check for type with id: "
65  << type.id_string() << std::endl;
66 #endif
67 
69  }
70 }
71 
80 void check_type(const typet &type, const validation_modet vm)
81 {
82  call_on_type<call_checkt>(type, vm);
83 }
84 
94  const typet &type,
95  const namespacet &ns,
96  const validation_modet vm)
97 {
98  call_on_type<call_validatet>(type, ns, vm);
99 }
100 
110  const typet &type,
111  const namespacet &ns,
112  const validation_modet vm)
113 {
114  call_on_type<call_validate_fullt>(type, ns, vm);
115 }
Pre-defined bitvector types.
Arrays with given size.
Definition: std_types.h:763
Fixed-width bit-vector without numerical interpretation.
The C/C++ Booleans.
Definition: c_types.h:62
Fixed-width bit-vector with signed fixed-point interpretation.
Fixed-width bit-vector with IEEE floating-point interpretation.
bool get_bool(const irep_namet &name) const
Definition: irep.cpp:58
const std::string & id_string() const
Definition: irep.h:410
const irep_idt & id() const
Definition: irep.h:407
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:91
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
Definition: pointer_expr.h:24
The reference type.
Definition: pointer_expr.h:89
Fixed-width bit-vector with two's complement interpretation.
The type of an expression, extends irept.
Definition: type.h:28
Fixed-width bit-vector with unsigned binary interpretation.
API to expression classes for Pointers.
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)
#define CALL_ON_TYPE(type_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...
void call_on_type(const typet &type, Args &&... args)
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)
validation_modet