File: typedef_type.h

package info (click to toggle)
cbmc 5.10-5
  • links: PTS
  • area: main
  • in suites: buster
  • size: 73,416 kB
  • sloc: cpp: 264,330; ansic: 38,268; java: 19,025; python: 4,539; yacc: 4,275; makefile: 2,547; lex: 2,394; sh: 932; perl: 525; xml: 289; pascal: 169
file content (66 lines) | stat: -rw-r--r-- 1,459 bytes parent folder | download
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
/*******************************************************************\

Module:

Author: Daniel Kroening, kroening@kroening.com

\*******************************************************************/

#ifndef CPROVER_ANSI_C_TYPEDEF_TYPE_H
#define CPROVER_ANSI_C_TYPEDEF_TYPE_H

#include <util/type.h>

/*! \brief A typedef
*/
class typedef_typet : public typet
{
public:
  explicit typedef_typet(const irep_idt &identifier) : typet(ID_typedef_type)
  {
    set_identifier(identifier);
  }

  void set_identifier(const irep_idt &identifier)
  {
    set(ID_identifier, identifier);
  }

  const irep_idt &get_identifier() const
  {
    return get(ID_identifier);
  }
};

/*! \brief Cast a generic typet to a \ref typedef_typet
 *
 * This is an unchecked conversion. \a type must be known to be \ref
 * typedef_typet.
 *
 * \param type Source type
 * \return Object of type \ref typedef_typet
 *
 * \ingroup gr_std_types
*/
inline const typedef_typet &to_typedef_type(const typet &type)
{
  PRECONDITION(type.id() == ID_typedef_type);
  return static_cast<const typedef_typet &>(type);
}

/*! \copydoc to_typedef_type(const typet &)
 * \ingroup gr_std_types
*/
inline typedef_typet &to_typedef_type(typet &type)
{
  PRECONDITION(type.id() == ID_typedef_type);
  return static_cast<typedef_typet &>(type);
}

template <>
inline bool can_cast_type<typedef_typet>(const typet &type)
{
  return type.id() == ID_typedef_type;
}

#endif // CPROVER_ANSI_C_TYPEDEF_TYPE_H