Skip to content

Commit 9c5e009

Browse files
author
thk123
committed
Corrected code in base class and removed duplicate code
1 parent ddc9d46 commit 9c5e009

File tree

3 files changed

+11
-80
lines changed

3 files changed

+11
-80
lines changed

src/analyses/ai.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,31 @@ bool ai_domain_baset::ai_simplify_lhs(
5757
if(condition.id()==ID_index)
5858
{
5959
index_exprt ie=to_index_expr(condition);
60-
bool changed=ai_simplify(ie.index(), ns);
61-
if(changed)
60+
bool no_simplification=ai_simplify(ie.index(), ns);
61+
if(!no_simplification)
6262
condition=simplify_expr(ie, ns);
6363

64-
return !changed;
64+
return no_simplification;
6565
}
6666
else if(condition.id()==ID_dereference)
6767
{
6868
dereference_exprt de=to_dereference_expr(condition);
69-
bool changed=ai_simplify(de.pointer(), ns);
70-
if(changed)
69+
bool no_simplification=ai_simplify(de.pointer(), ns);
70+
if(!no_simplification)
7171
condition=simplify_expr(de, ns); // So *(&x) -> x
7272

73-
return !changed;
73+
return no_simplification;
7474
}
7575
else if(condition.id()==ID_member)
7676
{
7777
member_exprt me=to_member_expr(condition);
78-
bool changed=ai_simplify_lhs(me.compound(), ns); // <-- lhs!
79-
if(changed)
78+
// Carry on the RHS since we still require an addressable object for the
79+
// struct
80+
bool no_simplification=ai_simplify_lhs(me.compound(), ns);
81+
if(!no_simplification)
8082
condition=simplify_expr(me, ns);
8183

82-
return !changed;
84+
return no_simplification;
8385
}
8486
else
8587
return true;

src/analyses/variable-sensitivity/variable_sensitivity_domain.cpp

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -350,73 +350,6 @@ bool variable_sensitivity_domaint::is_top() const
350350

351351
/*******************************************************************\
352352
353-
Function: variable_sensitivity_domaint::ai_simplify_lhs
354-
355-
Inputs:
356-
condition - the expression to simplify
357-
ns - the namespace
358-
359-
Outputs: True if condition did not change. False otherwise. condition
360-
will be updated with the simplified condition if it has worked
361-
362-
Purpose: Use the information in the domain to simplify the expression
363-
on the LHS of an assignment. This for example won't simplify symbols
364-
to their values, but does simplify indices in arrays, members of
365-
structs and dereferencing of pointers
366-
367-
\*******************************************************************/
368-
369-
bool variable_sensitivity_domaint::ai_simplify_lhs(
370-
exprt &condition, const namespacet &ns) const
371-
{
372-
// Care must be taken here to give something that is still writable
373-
if(condition.id()==ID_index)
374-
{
375-
index_exprt ie = to_index_expr(condition);
376-
exprt index = ie.index();
377-
bool no_simplification=ai_simplify(index, ns);
378-
if(!no_simplification)
379-
{
380-
ie.index() = index;
381-
condition = simplify_expr(ie, ns);
382-
}
383-
384-
return no_simplification;
385-
}
386-
else if(condition.id()==ID_dereference)
387-
{
388-
dereference_exprt de = to_dereference_expr(condition);
389-
exprt pointer = de.pointer();
390-
bool no_simplification = ai_simplify(pointer, ns);
391-
if(!no_simplification)
392-
{
393-
de.pointer() = pointer;
394-
condition = simplify_expr(de, ns); // So *(&x) -> x
395-
}
396-
397-
return no_simplification;
398-
}
399-
else if(condition.id()==ID_member)
400-
{
401-
member_exprt me = to_member_expr(condition);
402-
exprt compound = me.compound();
403-
// Carry on the RHS since we still require an addressable object for the
404-
// struct
405-
bool no_simplification = ai_simplify_lhs(compound, ns);
406-
if(!no_simplification)
407-
{
408-
me.compound() = compound;
409-
condition = simplify_expr(me, ns);
410-
}
411-
412-
return no_simplification;
413-
}
414-
else
415-
return true;
416-
}
417-
418-
/*******************************************************************\
419-
420353
Function: variable_sensitivity_domaint::transform_function_call
421354
422355
Inputs:

src/analyses/variable-sensitivity/variable_sensitivity_domain.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ class variable_sensitivity_domaint:public ai_domain_baset
104104
bool is_bottom() const override;
105105
bool is_top() const override;
106106

107-
bool ai_simplify_lhs(
108-
exprt &condition,
109-
const namespacet &ns) const override;
110-
111107
private:
112108
void transform_function_call(
113109
locationt from,

0 commit comments

Comments
 (0)