Skip to content

Commit 2ebbb24

Browse files
author
svorenova
authored
Merge pull request #2771 from svorenova/doc_typet
Complete typet documentation [DOC-12]
2 parents 12efeab + 592b114 commit 2ebbb24

File tree

7 files changed

+430
-524
lines changed

7 files changed

+430
-524
lines changed

src/util/base_type.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,15 @@ bool base_type_eqt::base_type_eq_rec(
320320
return true;
321321
}
322322

323+
/// Check types for equality across all levels of hierarchy. For equality
324+
/// in the top level of the hierarchy only use \ref type_eq.
325+
/// Example:
326+
/// - `symbol_typet("a")` and `ns.lookup("a").type` will compare equal,
327+
/// - `struct_typet {symbol_typet("a")}` and `struct_typet {ns.lookup("a")
328+
/// .type}` will also compare equal.
329+
/// \param type1 The first type to compare.
330+
/// \param type2 The second type to compare.
331+
/// \param ns The namespace, needed for resolution of symbols.
323332
bool base_type_eq(
324333
const typet &type1,
325334
const typet &type2,
@@ -329,6 +338,10 @@ bool base_type_eq(
329338
return base_type_eq.base_type_eq(type1, type2);
330339
}
331340

341+
/// Check expressions for equality across all levels of hierarchy.
342+
/// \param expr1 The first expression to compare.
343+
/// \param expr2 The second expression to compare.
344+
/// \param ns The namespace, needed for resolution of symbols.
332345
bool base_type_eq(
333346
const exprt &expr1,
334347
const exprt &expr2,

src/util/std_types.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
/*******************************************************************\
22
3-
Module:
3+
Module: Pre-defined types
44
55
Author: Daniel Kroening, [email protected]
6+
Maria Svorenova, [email protected]
67
78
\*******************************************************************/
89

10+
/// \file
11+
/// Pre-defined types
12+
913
#include "std_types.h"
1014

1115
#include "string2int.h"
@@ -26,6 +30,7 @@ std::size_t floatbv_typet::get_f() const
2630
return unsafe_string2unsigned(id2string(f));
2731
}
2832

33+
/// Return the sequence number of the component with given name.
2934
std::size_t struct_union_typet::component_number(
3035
const irep_idt &component_name) const
3136
{
@@ -48,6 +53,7 @@ std::size_t struct_union_typet::component_number(
4853
return 0;
4954
}
5055

56+
/// Get the reference to a component with given name.
5157
const struct_union_typet::componentt &struct_union_typet::get_component(
5258
const irep_idt &component_name) const
5359
{
@@ -73,6 +79,10 @@ typet struct_union_typet::component_type(
7379
return c.type();
7480
}
7581

82+
/// Returns true if the struct is a prefix of \a other, i.e., if this struct
83+
/// has n components then the component types and names of this struct must
84+
/// match the first n components of \a other struct.
85+
/// \param other Struct type to compare with.
7686
bool struct_typet::is_prefix_of(const struct_typet &other) const
7787
{
7888
const componentst &ot_components=other.components();
@@ -102,12 +112,14 @@ bool struct_typet::is_prefix_of(const struct_typet &other) const
102112
return true; // ok, *this is a prefix of ot
103113
}
104114

115+
/// Returns true if the type is a reference.
105116
bool is_reference(const typet &type)
106117
{
107118
return type.id()==ID_pointer &&
108119
type.get_bool(ID_C_reference);
109120
}
110121

122+
/// Returns if the type is an R value reference.
111123
bool is_rvalue_reference(const typet &type)
112124
{
113125
return type.id()==ID_pointer &&

0 commit comments

Comments
 (0)