Skip to content

Commit bb8aa52

Browse files
author
svorenova
committed
Doc type_eq cont.
1 parent c1b6654 commit bb8aa52

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
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: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
/*******************************************************************\
22
3-
Module: Type checking
3+
Module: Type equality
44
55
Author: Daniel Kroening, [email protected]
66
Maria Svorenova, [email protected]
77
88
\*******************************************************************/
99

1010
/// \file
11-
/// Type checking
11+
/// Type equality
1212

1313
#include "type_eq.h"
1414

1515
#include "namespace.h"
1616
#include "std_types.h"
1717
#include "symbol.h"
1818

19-
/// Check types for equality. If either of the types is a symbol type, i.e. a
20-
/// reference into the symbol table, retrieve it from the namespace and compare.
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.
2127
/// \param type1 The first type to compare.
2228
/// \param type2 The second type to compare.
2329
/// \param ns The namespace, needed for resolution of symbols.

src/util/type_eq.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*******************************************************************\
22
3-
Module: Type checking
3+
Module: Type equality
44
55
Author: Daniel Kroening, [email protected]
66
Maria Svorenova, [email protected]
77
88
\*******************************************************************/
99

1010
/// \file
11-
/// Type checking
11+
/// Type equality
1212

1313
#ifndef CPROVER_UTIL_TYPE_EQ_H
1414
#define CPROVER_UTIL_TYPE_EQ_H

0 commit comments

Comments
 (0)