CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cpp_id.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_ID_H
13#define CPROVER_CPP_CPP_ID_H
14
15#include <map>
16#include <string>
17#include <iosfwd>
18
19#include <util/expr.h>
20#include <util/invariant.h>
21
23{
24public:
25 cpp_idt();
26
27 enum class id_classt
28 {
29 UNKNOWN,
30 SYMBOL,
31 TYPEDEF,
32 CLASS,
33 ENUM,
40 };
41
44
46
47 bool is_class() const
48 {
50 }
51
52 bool is_enum() const
53 {
55 }
56
57 bool is_namespace() const
58 {
60 }
61
62 bool is_typedef() const
63 {
65 }
66
67 bool is_template_scope() const
68 {
70 }
71
73
74 // if it is a member or method, what class is it in?
77
78 // scope data
79 std::string prefix, suffix;
81
83 {
84 PRECONDITION(parent!=nullptr);
85 return *parent;
86 }
87
89 {
90 PRECONDITION(_parent.is_scope);
92 }
93
94 void clear()
95 {
96 *this=cpp_idt();
97 }
98
99 void print(std::ostream &out, unsigned indent=0) const;
100 void print_fields(std::ostream &out, unsigned indent=0) const;
101
102protected:
103 typedef std::multimap<irep_idt, cpp_idt> cpp_id_mapt;
105
106 // These are used for base classes and 'using' clauses.
107 typedef std::vector<cpp_idt *> scope_listt;
110};
111
112std::ostream &operator<<(std::ostream &out, const cpp_idt &cpp_id);
113std::ostream &operator<<(std::ostream &out, const cpp_idt::id_classt &id_class);
114
115#endif // CPROVER_CPP_CPP_ID_H
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
std::multimap< irep_idt, cpp_idt > cpp_id_mapt
Definition cpp_id.h:103
irep_idt identifier
Definition cpp_id.h:72
bool is_member
Definition cpp_id.h:42
exprt this_expr
Definition cpp_id.h:76
void clear()
Definition cpp_id.h:94
scope_listt using_scopes
Definition cpp_id.h:108
std::string prefix
Definition cpp_id.h:79
bool is_namespace() const
Definition cpp_id.h:57
cpp_idt & get_parent() const
Definition cpp_id.h:82
bool is_scope
Definition cpp_id.h:43
id_classt
Definition cpp_id.h:28
bool is_typedef() const
Definition cpp_id.h:62
cpp_id_mapt sub
Definition cpp_id.h:104
id_classt id_class
Definition cpp_id.h:45
void print(std::ostream &out, unsigned indent=0) const
Definition cpp_id.cpp:31
bool is_constructor
Definition cpp_id.h:43
bool is_method
Definition cpp_id.h:42
bool is_template_scope() const
Definition cpp_id.h:67
cpp_idt()
Definition cpp_id.cpp:18
bool is_static_member
Definition cpp_id.h:42
bool is_class() const
Definition cpp_id.h:47
void print_fields(std::ostream &out, unsigned indent=0) const
Definition cpp_id.cpp:44
void set_parent(cpp_idt &_parent)
Definition cpp_id.h:88
scope_listt secondary_scopes
Definition cpp_id.h:108
bool is_enum() const
Definition cpp_id.h:52
std::vector< cpp_idt * > scope_listt
Definition cpp_id.h:107
unsigned compound_counter
Definition cpp_id.h:80
irep_idt class_identifier
Definition cpp_id.h:75
irep_idt base_name
Definition cpp_id.h:72
std::string suffix
Definition cpp_id.h:79
cpp_idt * parent
Definition cpp_id.h:109
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
std::ostream & operator<<(std::ostream &out, const cpp_idt &cpp_id)
Definition cpp_id.cpp:92
#define PRECONDITION(CONDITION)
Definition invariant.h:463