-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathcpp_template_args.h
94 lines (73 loc) · 2.19 KB
/
cpp_template_args.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*******************************************************************\
Module: C++ Language Type Checking
Author: Daniel Kroening, [email protected]
\*******************************************************************/
/// \file
/// C++ Language Type Checking
#ifndef CPROVER_CPP_CPP_TEMPLATE_ARGS_H
#define CPROVER_CPP_CPP_TEMPLATE_ARGS_H
#include <util/expr.h>
#include <util/invariant.h>
// A data structures for template arguments, i.e.,
// a sequence of types/expressions of the form <E1, T2, ...>.
// Not to be confused with the template parameters!
class cpp_template_args_baset:public irept
{
public:
cpp_template_args_baset():irept(ID_template_args)
{
}
typedef exprt::operandst argumentst;
argumentst &arguments()
{
return (argumentst &)(add(ID_arguments).get_sub());
}
const argumentst &arguments() const
{
return (const argumentst &)(find(ID_arguments).get_sub());
}
};
// the non-yet typechecked variant
class cpp_template_args_non_tct:public cpp_template_args_baset
{
};
inline cpp_template_args_non_tct &to_cpp_template_args_non_tc(
irept &irep)
{
PRECONDITION(irep.id() == ID_template_args);
return static_cast<cpp_template_args_non_tct &>(irep);
}
inline const cpp_template_args_non_tct &to_cpp_template_args_non_tc(
const irept &irep)
{
PRECONDITION(irep.id() == ID_template_args);
return static_cast<const cpp_template_args_non_tct &>(irep);
}
// the already typechecked variant
class cpp_template_args_tct:public cpp_template_args_baset
{
public:
bool has_unassigned() const
{
const argumentst &_arguments=arguments();
for(argumentst::const_iterator
it=_arguments.begin();
it!=_arguments.end();
it++)
if(it->id()==ID_unassigned ||
it->type().id()==ID_unassigned)
return true;
return false;
}
};
inline cpp_template_args_tct &to_cpp_template_args_tc(irept &irep)
{
PRECONDITION(irep.id() == ID_template_args);
return static_cast<cpp_template_args_tct &>(irep);
}
inline const cpp_template_args_tct &to_cpp_template_args_tc(const irept &irep)
{
PRECONDITION(irep.id() == ID_template_args);
return static_cast<const cpp_template_args_tct &>(irep);
}
#endif // CPROVER_CPP_CPP_TEMPLATE_ARGS_H