Skip to content

Commit 7ad664c

Browse files
author
svorenova
committed
Add documentation to type_eq
1 parent a54746f commit 7ad664c

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
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/type_eq.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
/*******************************************************************\
22
3-
Module: Type Checking
3+
Module: Type equality
44
55
Author: Daniel Kroening, [email protected]
6+
Maria Svorenova, [email protected]
67
78
\*******************************************************************/
89

910
/// \file
10-
/// Type Checking
11+
/// Type equality
1112

1213
#include "type_eq.h"
1314

1415
#include "namespace.h"
1516
#include "std_types.h"
1617
#include "symbol.h"
1718

19+
/// Check types for equality at the top level. If either of the types is a
20+
/// symbol type, i.e., a reference into the symbol table, retrieve it from
21+
/// the namespace and compare but don't do this recursively. For equality
22+
/// across all level in the hierarchy use \ref base_type_eq.
23+
/// Example:
24+
/// - `symbol_typet("a")` and `ns.lookup("a").type` will compare equal,
25+
/// - `struct_typet {symbol_typet("a")}` and `struct_typet {ns.lookup("a")
26+
/// .type}` will not compare equal.
27+
/// \param type1 The first type to compare.
28+
/// \param type2 The second type to compare.
29+
/// \param ns The namespace, needed for resolution of symbols.
1830
bool type_eq(const typet &type1, const typet &type2, const namespacet &ns)
1931
{
2032
if(type1==type2)

src/util/type_eq.h

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

10+
/// \file
11+
/// Type equality
912

1013
#ifndef CPROVER_UTIL_TYPE_EQ_H
1114
#define CPROVER_UTIL_TYPE_EQ_H

0 commit comments

Comments
 (0)