Skip to content

Commit 6e604ec

Browse files
author
Daniel Kroening
committed
added NODISCARD to simplifier results
The call to these methods is meaningless unless the result is used.
1 parent ed168ac commit 6e604ec

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/util/simplify_expr_class.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Author: Daniel Kroening, [email protected]
1919

2020
#include "expr.h"
2121
#include "mp_arith.h"
22+
#include "nodiscard.h"
2223
#include "type.h"
2324
// #define USE_LOCAL_REPLACE_MAP
2425
#ifdef USE_LOCAL_REPLACE_MAP
@@ -104,20 +105,20 @@ class simplify_exprt
104105
}
105106
};
106107

107-
static resultt<> unchanged(exprt expr)
108+
NODISCARD static resultt<> unchanged(exprt expr)
108109
{
109110
return resultt<>(resultt<>::UNCHANGED, std::move(expr));
110111
}
111112

112-
static resultt<> changed(resultt<> result)
113+
NODISCARD static resultt<> changed(resultt<> result)
113114
{
114115
result.expr_changed = resultt<>::CHANGED;
115116
return result;
116117
}
117118

118119
// These below all return 'true' if the simplification wasn't applicable.
119120
// If false is returned, the expression has changed.
120-
resultt<> simplify_typecast(const typecast_exprt &);
121+
NODISCARD resultt<> simplify_typecast(const typecast_exprt &);
121122
bool simplify_extractbit(exprt &expr);
122123
bool simplify_extractbits(extractbits_exprt &expr);
123124
bool simplify_concatenation(exprt &expr);
@@ -143,8 +144,8 @@ class simplify_exprt
143144
bool simplify_update(exprt &expr);
144145
bool simplify_index(exprt &expr);
145146
bool simplify_member(exprt &expr);
146-
resultt<> simplify_byte_update(const byte_update_exprt &);
147-
resultt<> simplify_byte_extract(const byte_extract_exprt &);
147+
NODISCARD resultt<> simplify_byte_update(const byte_update_exprt &);
148+
NODISCARD resultt<> simplify_byte_extract(const byte_extract_exprt &);
148149
bool simplify_pointer_object(exprt &expr);
149150
bool simplify_object_size(exprt &expr);
150151
bool simplify_dynamic_size(exprt &expr);
@@ -155,21 +156,22 @@ class simplify_exprt
155156
bool simplify_object(exprt &expr);
156157
bool simplify_unary_minus(exprt &expr);
157158
bool simplify_unary_plus(exprt &expr);
158-
resultt<> simplify_dereference(const dereference_exprt &);
159+
NODISCARD resultt<> simplify_dereference(const dereference_exprt &);
159160
bool simplify_address_of(exprt &expr);
160161
bool simplify_pointer_offset(exprt &expr);
161162
bool simplify_bswap(bswap_exprt &expr);
162163
bool simplify_isinf(exprt &expr);
163164
bool simplify_isnan(exprt &expr);
164165
bool simplify_isnormal(exprt &expr);
165-
resultt<> simplify_abs(const abs_exprt &);
166+
NODISCARD resultt<> simplify_abs(const abs_exprt &);
166167
bool simplify_sign(exprt &expr);
167-
resultt<> simplify_popcount(const popcount_exprt &);
168+
NODISCARD resultt<> simplify_popcount(const popcount_exprt &);
168169
bool simplify_complex(exprt &expr);
169170

170171
/// Attempt to simplify mathematical function applications if we have
171172
/// enough information to do so. Currently focused on constant comparisons.
172-
resultt<> simplify_function_application(const function_application_exprt &);
173+
NODISCARD resultt<>
174+
simplify_function_application(const function_application_exprt &);
173175

174176
// auxiliary
175177
bool simplify_if_implies(

0 commit comments

Comments
 (0)