cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
cpp_declaration.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: C++ Language Type Checking
4
5
Author: Daniel Kroening, kroening@cs.cmu.edu
6
7
\*******************************************************************/
8
11
12
#include "
cpp_declaration.h
"
13
14
#include <ostream>
15
16
void
cpp_declarationt::output
(std::ostream &out)
const
17
{
18
out <<
"is_template: "
<<
is_template
() <<
'\n'
;
19
out <<
"storage: "
<<
storage_spec
().
pretty
() <<
'\n'
;
20
out <<
"template_type: "
<<
template_type
().
pretty
() <<
'\n'
;
21
out <<
"type: "
<<
type
().
pretty
() <<
'\n'
;
22
23
out <<
"Declarators:"
<<
'\n'
;
24
25
for
(
const
auto
&it :
declarators
())
26
{
27
it.output(out);
28
out <<
'\n'
;
29
}
30
}
31
32
void
cpp_declarationt::name_anon_struct_union
(
typet
&dest)
33
{
34
// We name any anon struct/unions according to the first
35
// declarator. No need to do anon enums, which get
36
// a name based on the enum elements.
37
38
if
(dest.
id
()==ID_struct || dest.
id
()==ID_union)
39
{
40
if
(dest.
find
(ID_tag).
is_nil
())
41
{
42
// it's anonymous
43
44
const
declaratorst
&d=
declarators
();
45
46
if
(!d.empty() &&
47
d.front().name().is_simple_name())
48
{
49
// Anon struct/unions without declarator are pretty
50
// useless, but still possible.
51
52
irep_idt
base_name=
"anon-"
+
id2string
(d.front().name().get_base_name());
53
dest.
set
(ID_tag,
cpp_namet
(base_name));
54
dest.
set
(ID_C_is_anonymous,
true
);
55
}
56
}
57
}
58
else
if
(dest.
id
()==ID_merged_type)
59
{
60
for
(
typet
&subtype :
to_type_with_subtypes
(dest).subtypes())
61
name_anon_struct_union
(subtype);
62
}
63
}
cpp_declarationt::declarators
const declaratorst & declarators() const
Definition
cpp_declaration.h:62
cpp_declarationt::output
void output(std::ostream &out) const
Definition
cpp_declaration.cpp:16
cpp_declarationt::storage_spec
const cpp_storage_spect & storage_spec() const
Definition
cpp_declaration.h:72
cpp_declarationt::is_template
bool is_template() const
Definition
cpp_declaration.h:50
cpp_declarationt::declaratorst
std::vector< cpp_declaratort > declaratorst
Definition
cpp_declaration.h:24
cpp_declarationt::template_type
template_typet & template_type()
Definition
cpp_declaration.h:96
cpp_declarationt::name_anon_struct_union
void name_anon_struct_union()
Definition
cpp_declaration.h:142
cpp_namet
Definition
cpp_name.h:17
exprt::type
typet & type()
Return the type of the expression.
Definition
expr.h:85
irept::pretty
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
Definition
irep.cpp:482
irept::find
const irept & find(const irep_idt &name) const
Definition
irep.cpp:93
irept::set
void set(const irep_idt &name, const irep_idt &value)
Definition
irep.h:412
irept::id
const irep_idt & id() const
Definition
irep.h:388
irept::is_nil
bool is_nil() const
Definition
irep.h:368
typet
The type of an expression, extends irept.
Definition
type.h:29
cpp_declaration.h
C++ Language Type Checking.
id2string
const std::string & id2string(const irep_idt &d)
Definition
irep.h:44
to_type_with_subtypes
const type_with_subtypest & to_type_with_subtypes(const typet &type)
Definition
type.h:252
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
cpp
cpp_declaration.cpp
Generated by
1.17.0