Skip to content

Commit 8cbf554

Browse files
smowtonpeterschrammel
authored andcommitted
Trim and rename namespace-utils
This avoids a name clash with an old deprecated file.
1 parent e9205e6 commit 8cbf554

File tree

4 files changed

+52
-132
lines changed

4 files changed

+52
-132
lines changed

src/util/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ SRC = arith_tools.cpp base_type.cpp cmdline.cpp config.cpp symbol_table.cpp \
2222
irep_ids.cpp byte_operators.cpp string2int.cpp file_util.cpp \
2323
memory_info.cpp pipe_stream.cpp irep_hash.cpp endianness_map.cpp \
2424
ssa_expr.cpp json_irep.cpp json_expr.cpp \
25-
string_utils.cpp parameter_indices.cpp namespace_utils.cpp
25+
string_utils.cpp parameter_indices.cpp symbol_utils.cpp
2626

2727
INCLUDES= -I ..
2828

src/util/namespace_utils.h

-117
This file was deleted.

src/util/namespace_utils.cpp renamed to src/util/symbol_utils.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*******************************************************************\
22
3-
Module:
3+
Module: Symbol utilities
44
5-
Author: Daniel Kroening, kroening@kroening.com
5+
Author: Nathan Phillips, nathan.phillips@diffblue.com
66
77
\*******************************************************************/
88

9-
#include "namespace_utils.h"
9+
#include "symbol_utils.h"
1010
#include "symbol.h"
1111
#include <goto-programs/remove_returns.h>
1212

1313
/*******************************************************************\
1414
15-
Function: namespace_utils_baset::does_symbol_match
15+
Function: symbol_utilst::does_symbol_match
1616
1717
Purpose:
1818
Checks whether an exprt is actually a symbolt matching a predicate
@@ -28,21 +28,21 @@ Author: Daniel Kroening, [email protected]
2828
2929
\*******************************************************************/
3030

31-
bool namespace_utils_baset::does_symbol_match(
31+
bool symbol_utilst::does_symbol_match(
3232
const exprt &lvalue,
3333
std::function<bool(symbolt)> predicate) const
3434
{
3535
if(lvalue.id()!=ID_symbol)
3636
return false;
3737
const symbolt *symbol;
38-
if(lookup(lvalue.get(ID_identifier), symbol))
38+
if(ns.lookup(lvalue.get(ID_identifier), symbol))
3939
return false;
4040
return predicate(*symbol);
4141
}
4242

4343
/*******************************************************************\
4444
45-
Function: namespace_utils_baset::is_parameter
45+
Function: symbol_utilst::is_parameter
4646
4747
Purpose:
4848
Checks whether an exprt is actually a parameter symbol
@@ -56,7 +56,7 @@ bool namespace_utils_baset::does_symbol_match(
5656
5757
\*******************************************************************/
5858

59-
bool namespace_utils_baset::is_parameter(const exprt &lvalue) const
59+
bool symbol_utilst::is_parameter(const exprt &lvalue) const
6060
{
6161
return does_symbol_match(
6262
lvalue,
@@ -65,7 +65,7 @@ bool namespace_utils_baset::is_parameter(const exprt &lvalue) const
6565

6666
/*******************************************************************\
6767
68-
Function: namespace_utils_baset::is_static
68+
Function: symbol_utilst::is_static
6969
7070
Purpose:
7171
Checks whether an exprt is actually a static symbol
@@ -79,7 +79,7 @@ bool namespace_utils_baset::is_parameter(const exprt &lvalue) const
7979
8080
\*******************************************************************/
8181

82-
bool namespace_utils_baset::is_static(const exprt &lvalue) const
82+
bool symbol_utilst::is_static(const exprt &lvalue) const
8383
{
8484
// TODO: Also check for static member accesses
8585
return does_symbol_match(
@@ -89,7 +89,7 @@ bool namespace_utils_baset::is_static(const exprt &lvalue) const
8989

9090
/*******************************************************************\
9191
92-
Function: namespace_utils_baset::is_auxiliary_variable
92+
Function: symbol_utilst::is_auxiliary_variable
9393
9494
Purpose:
9595
Checks whether an exprt is actually an auxiliary variable symbol
@@ -103,7 +103,7 @@ bool namespace_utils_baset::is_static(const exprt &lvalue) const
103103
104104
\*******************************************************************/
105105

106-
bool namespace_utils_baset::is_auxiliary_variable(const exprt &lvalue) const
106+
bool symbol_utilst::is_auxiliary_variable(const exprt &lvalue) const
107107
{
108108
return does_symbol_match(
109109
lvalue,
@@ -112,7 +112,7 @@ bool namespace_utils_baset::is_auxiliary_variable(const exprt &lvalue) const
112112

113113
/*******************************************************************\
114114
115-
Function: namespace_utils_baset::is_return_value_auxiliary
115+
Function: symbol_utilst::is_return_value_auxiliary
116116
117117
Purpose:
118118
Checks whether an exprt is actually an auxiliary return value symbol
@@ -126,7 +126,7 @@ bool namespace_utils_baset::is_auxiliary_variable(const exprt &lvalue) const
126126
127127
\*******************************************************************/
128128

129-
bool namespace_utils_baset::is_return_value_auxiliary(const exprt &lvalue) const
129+
bool symbol_utilst::is_return_value_auxiliary(const exprt &lvalue) const
130130
{
131131
return
132132
does_symbol_match(

src/util/symbol_utils.h

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*******************************************************************\
2+
3+
Module: Symbol utilities
4+
5+
Author: Nathan Phillips, [email protected]
6+
7+
\*******************************************************************/
8+
9+
#ifndef CPROVER_UTIL_SYMBOL_UTILS_H
10+
#define CPROVER_UTIL_SYMBOL_UTILS_H
11+
12+
#include <functional>
13+
#include "namespace.h"
14+
#include "std_expr.h"
15+
16+
// second: true <=> not found
17+
18+
class symbol_utilst
19+
{
20+
private:
21+
bool does_symbol_match(
22+
const exprt &lvalue,
23+
std::function<bool(symbolt)> predicate) const;
24+
const namespacet &ns;
25+
26+
public:
27+
explicit symbol_utilst(const namespacet &_ns):
28+
ns(_ns)
29+
{}
30+
31+
bool is_parameter(const exprt &lvalue) const;
32+
bool is_static(const exprt &lvalue) const;
33+
bool is_auxiliary_variable(const exprt &lvalue) const;
34+
bool is_return_value_auxiliary(const exprt &lvalue) const;
35+
};
36+
37+
#endif

0 commit comments

Comments
 (0)