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_signedbv)
28  {
30  }
31  else if(type.id() == ID_unsignedbv)
32  {
34  }
35  else
36  {
37 #ifdef REPORT_UNIMPLEMENTED_TYPE_CHECKS
38  std::cerr << "Unimplemented well-formedness check for type with id: "
39  << type.id_string() << std::endl;
40 #endif
41 
43  }
44 }
45 
54 void check_type(const typet &type, const validation_modet vm)
55 {
56  call_on_type<call_checkt>(type, vm);
57 }
58 
68  const typet &type,
69  const namespacet &ns,
70  const validation_modet vm)
71 {
72  call_on_type<call_validatet>(type, ns, vm);
73 }
74 
84  const typet &type,
85  const namespacet &ns,
86  const validation_modet vm)
87 {
88  call_on_type<call_validate_fullt>(type, ns, vm);
89 }
The type of an expression, extends irept.
Definition: type.h:27
Fixed-width bit-vector with unsigned binary interpretation.
Definition: std_types.h:1223
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)
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)
const irep_idt & id() const
Definition: irep.h:259
#define CALL_ON_TYPE(type_type)
Fixed-width bit-vector with two's complement interpretation.
Definition: std_types.h:1278
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:93
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...
Pre-defined types.
void call_on_type(const typet &type, Args &&... args)
const std::string & id_string() const
Definition: irep.h:262
validation_modet
Defines typet, type_with_subtypet and type_with_subtypest.