Skip to content

Commit 7bddbb0

Browse files
tautschnigDaniel Kroening
authored and
Daniel Kroening
committed
Code cleanup in local_safe_pointers
1) Inline (now trivial) comparision function. 2) Use skip_typecast.
1 parent efbbfc8 commit 7bddbb0

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

src/analyses/local_safe_pointers.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,17 +271,6 @@ bool local_safe_pointerst::is_non_null_at_program_point(
271271
auto findit = non_null_expressions.find(program_point->location_number);
272272
if(findit == non_null_expressions.end())
273273
return false;
274-
const exprt *tocheck = &expr;
275-
while(tocheck->id() == ID_typecast)
276-
tocheck = &tocheck->op0();
277-
return findit->second.count(*tocheck) != 0;
278-
}
279274

280-
bool local_safe_pointerst::type_comparet::
281-
operator()(const exprt &e1, const exprt &e2) const
282-
{
283-
if(e1.type() == e2.type())
284-
return false;
285-
else
286-
return e1 < e2;
275+
return findit->second.count(skip_typecast(expr)) != 0;
287276
}

src/analyses/local_safe_pointers.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ class local_safe_pointerst
2525
{
2626
/// Comparator that regards type-equal expressions as equal, and otherwise
2727
/// uses the natural (operator<) ordering on irept.
28-
class type_comparet
28+
struct type_comparet
2929
{
30-
public:
31-
bool operator()(const exprt &e1, const exprt &e2) const;
30+
bool operator()(const exprt &e1, const exprt &e2) const
31+
{
32+
return e1.type() != e2.type() && e1 < e2;
33+
}
3234
};
3335

3436
std::map<unsigned, std::set<exprt, type_comparet>> non_null_expressions;

0 commit comments

Comments
 (0)