CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cpp_declaration.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: C++ Language Type Checking
4
5Author: Daniel Kroening, kroening@cs.cmu.edu
6
7\*******************************************************************/
8
11
12#ifndef CPROVER_CPP_CPP_DECLARATION_H
13#define CPROVER_CPP_CPP_DECLARATION_H
14
15#include "cpp_declarator.h"
16#include "cpp_storage_spec.h"
17#include "cpp_member_spec.h"
18#include "cpp_template_type.h"
19#include "cpp_template_args.h"
20
22{
23public:
24 typedef std::vector<cpp_declaratort> declaratorst;
25
29
30 bool is_empty() const
31 {
32 return type().is_nil() && !has_operands();
33 }
34
35 bool is_constructor() const
36 {
37 return type().id()==ID_constructor;
38 }
39
40 bool is_static_assert() const
41 {
43 }
44
45 bool is_destructor() const
46 {
47 return type().id()==ID_destructor;
48 }
49
50 bool is_template() const
51 {
53 }
54
55 bool is_class_template() const
56 {
57 return is_template() &&
58 type().id()==ID_struct &&
59 declarators().empty();
60 }
61
63 {
64 return (const declaratorst &)operands();
65 }
66
68 {
69 return (declaratorst &)operands();
70 }
71
73 {
74 return static_cast<const cpp_storage_spect &>(
76 }
77
79 {
80 return static_cast<cpp_storage_spect &>(
82 }
83
85 {
86 return static_cast<const cpp_member_spect &>(
88 }
89
91 {
92 return static_cast<cpp_member_spect &>(
94 }
95
97 {
98 return static_cast<template_typet &>(add(ID_template_type));
99 }
100
102 {
103 return static_cast<const template_typet &>(find(ID_template_type));
104 }
105
111
117
119 {
121 }
122
124 {
126 }
127
129 {
130 set(ID_is_typedef, true);
131 }
132
133 bool is_typedef() const
134 {
135 return get_bool(ID_is_typedef);
136 }
137
138 void output(std::ostream &out) const;
139
140 // for assigning a tag for struct/union in the type based on
141 // the name of the first declarator
143 void name_anon_struct_union(typet &dest);
144};
145
147{
149 return static_cast<cpp_declarationt &>(irep);
150}
151
152inline const cpp_declarationt &to_cpp_declaration(const irept &irep)
153{
155 return static_cast<const cpp_declarationt &>(irep);
156}
157
158#endif // CPROVER_CPP_CPP_DECLARATION_H
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
const template_typet & template_type() const
const declaratorst & declarators() const
bool is_destructor() const
bool is_static_assert() const
void output(std::ostream &out) const
const cpp_member_spect & member_spec() const
const cpp_storage_spect & storage_spec() const
void set_specialization_of(const irep_idt &id)
irep_idt get_specialization_of() const
bool is_template() const
cpp_member_spect & member_spec()
bool is_constructor() const
bool is_class_template() const
bool is_empty() const
std::vector< cpp_declaratort > declaratorst
const cpp_template_args_non_tct & partial_specialization_args() const
cpp_template_args_non_tct & partial_specialization_args()
declaratorst & declarators()
template_typet & template_type()
bool is_typedef() const
cpp_storage_spect & storage_spec()
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
Base class for all expressions.
Definition expr.h:56
bool has_operands() const
Return true if there is at least one operand.
Definition expr.h:91
typet & type()
Return the type of the expression.
Definition expr.h:84
operandst & operands()
Definition expr.h:94
There are a large number of kinds of tree structured or tree-like data in CPROVER.
Definition irep.h:364
bool get_bool(const irep_idt &name) const
Definition irep.cpp:57
const irept & find(const irep_idt &name) const
Definition irep.cpp:93
const irep_idt & get(const irep_idt &name) const
Definition irep.cpp:44
void set(const irep_idt &name, const irep_idt &value)
Definition irep.h:412
const irep_idt & id() const
Definition irep.h:388
irept & add(const irep_idt &name)
Definition irep.cpp:103
bool is_nil() const
Definition irep.h:368
The type of an expression, extends irept.
Definition type.h:29
cpp_declarationt & to_cpp_declaration(irept &irep)
C++ Language Type Checking.
C++ Language Type Checking.
#define PRECONDITION(CONDITION)
Definition invariant.h:463