Skip to content

Commit 9ff9a85

Browse files
NathanJPhillipssmowton
authored andcommitted
Merge pull request diffblue#107 from trtikm/feature/removed-suppression
Removed suppression
1 parent 0b543e5 commit 9ff9a85

File tree

5 files changed

+23
-285
lines changed

5 files changed

+23
-285
lines changed

src/goto-analyzer/taint_summary.cpp

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,47 +1142,16 @@ taint_numbered_lvalue_svalue_mapt transform(
11421142
else if (I.code.get_statement() == "clear_may")
11431143
{
11441144
assert(I.code.operands().size() == 2UL);
1145-
auto const taint_name = find_taint_value(I.code.op1(),taint_spec_names);
1146-
if (taint_name!=invalid_taint)
1145+
const taint_lvaluet lvalue = I.code.op0();
1146+
// simplify_expr(find_taint_expression(I.code.op0()), ns);
1147+
if (lvsa == nullptr)
1148+
assign(result,taint_object_numbering.number(lvalue),taint_make_bottom());
1149+
else
11471150
{
1148-
taint_lvaluet const lvalue =I.code.op0();
1149-
// simplify_expr(find_taint_expression(I.code.op0()), ns);
1150-
if (lvsa == nullptr)
1151-
{
1152-
auto lvalue_number=taint_object_numbering.number(lvalue);
1153-
taint_svaluet rvalue = taint_make_bottom();
1154-
{
1155-
auto const it = a.find(lvalue_number);
1156-
if (it != a.end())
1157-
{
1158-
taint_set_of_svarst symbols = it->second.get_vars();
1159-
symbols.erase(taint_name);
1160-
if (!symbols.empty())
1161-
rvalue = taint_make_bottom();//taint_svaluet(symbols,{taint_name},false,false);
1162-
}
1163-
}
1164-
assign(result,lvalue_number,rvalue);
1165-
}
1166-
else
1167-
{
1168-
taint_numbered_lvalues_sett lhs;
1169-
collect_lvsa_access_paths(lvalue,ns,lhs,*lvsa,Iit,taint_object_numbering);
1170-
if (lhs.size() == 1UL)
1171-
{
1172-
taint_svaluet rvalue = taint_make_bottom();
1173-
{
1174-
auto const it = a.find(*lhs.cbegin());
1175-
if (it != a.end())
1176-
{
1177-
taint_set_of_svarst symbols = it->second.get_vars();
1178-
symbols.erase(taint_name);
1179-
if (!symbols.empty())
1180-
rvalue = taint_make_bottom();//taint_svaluet(symbols,{taint_name},false,false);
1181-
}
1182-
}
1183-
assign(result,*lhs.cbegin(),rvalue);
1184-
}
1185-
}
1151+
taint_numbered_lvalues_sett lhs;
1152+
collect_lvsa_access_paths(lvalue,ns,lhs,*lvsa,Iit,taint_object_numbering);
1153+
if (lhs.size() == 1UL)
1154+
assign(result,*lhs.cbegin(),taint_make_bottom());
11861155
}
11871156
}
11881157
else if(I.code.get_statement()==ID_array_set)

src/goto-analyzer/taint_summary_dump.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,6 @@ void taint_dump_svalue_in_html(
5252
ostr << "T" << symbol;
5353
first = false;
5454
}
55-
if (!svalue.get_suppressions().empty())
56-
{
57-
ostr << " <b>\\</b> ";
58-
//first = true;
59-
for (auto const& token_sets : svalue.get_suppressions())
60-
{
61-
//ostr << (first ? "" : " <b>&#x2210;</b> ");
62-
ostr << "X" << token_sets.first << " ";
63-
//first = false;
64-
}
65-
}
6655
}
6756
}
6857

src/goto-analyzer/taint_svalue.cpp

Lines changed: 11 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,20 @@ to the summary based taint analysis.
1818
#include <algorithm>
1919

2020

21-
cond_suppression_idt get_fresh_cond_suppression_id()
22-
{
23-
static cond_suppression_idt id = 0ULL;
24-
return ++id;
25-
}
26-
27-
taint_token_suppressiont::taint_token_suppressiont(
28-
const taint_set_of_svarst &in_vars,
29-
const cond_suppression_idt in_cond_suppression_id
30-
)
31-
: vars(in_vars)
32-
, cond_suppression_id(in_cond_suppression_id)
33-
{}
34-
35-
void taint_token_suppressiont::insert(const taint_set_of_svarst &in_vars)
36-
{
37-
vars.insert(in_vars.cbegin(),in_vars.cend());
38-
}
39-
40-
4121
taint_svaluet::taint_svaluet(
4222
const taint_set_of_tokenst &in_tokens,
4323
const taint_set_of_svarst &in_vars,
44-
const taint_set_of_condst &in_conds,
45-
const taint_set_of_token_suppressionst &in_suppressions
46-
)
47-
: tokens(in_tokens)
48-
, vars(in_vars)
49-
, conds(in_conds.cbegin(),in_conds.cend())
50-
, suppressions(in_suppressions)
24+
const taint_set_of_condst &in_conds)
25+
: tokens(in_tokens), vars(in_vars), conds(in_conds.cbegin(),in_conds.cend())
5126
{}
5227

5328
taint_svaluet::taint_svaluet()
54-
: tokens()
55-
, vars()
56-
, conds()
57-
, suppressions()
29+
: tokens(), vars(), conds()
5830
{}
5931

6032
taint_svaluet::taint_svaluet(const taint_svaluet &other)
61-
: tokens(other.get_tokens())
62-
, vars(other.get_vars())
63-
, conds(other.get_conds().cbegin(),other.get_conds().cend())
64-
, suppressions(other.get_suppressions())
33+
: tokens(other.get_tokens()), vars(other.get_vars()),
34+
conds(other.get_conds().cbegin(),other.get_conds().cend())
6535
{
6636
}
6737

@@ -71,49 +41,14 @@ void taint_svaluet::join(const taint_svaluet &other)
7141
tokens.insert(other.get_tokens().cbegin(),other.get_tokens().cend());
7242
vars.insert(other.get_vars().cbegin(),other.get_vars().cend());
7343
conds.insert(conds.end(),other.get_conds().cbegin(),other.get_conds().cend());
74-
suppressions.insert(other.get_suppressions().cbegin(),
75-
other.get_suppressions().cend());
76-
}
77-
78-
void taint_svaluet::suppress(const taint_tokent token)
79-
{
80-
tokens.erase(token);
81-
82-
cond_suppression_idt cond_suppression_id;
83-
auto it = suppressions.find(token);
84-
if (it == suppressions.end())
85-
{
86-
cond_suppression_id = get_fresh_cond_suppression_id();
87-
it = suppressions.insert({token,{get_vars(),cond_suppression_id}}).first;
88-
}
89-
else
90-
{
91-
cond_suppression_id = it->second.get_cond_suppression_id();
92-
it->second.insert(get_vars());
93-
}
94-
95-
taint_set_of_condst new_conds;
96-
for (auto& cond : conds)
97-
{
98-
taint_condt tmp = cond;
99-
tmp.insert(cond_suppression_id);
100-
new_conds.push_back(tmp);
101-
}
102-
using std::swap;
103-
swap(new_conds,conds);
10444
}
10545

10646

10747
taint_condt::taint_condt(
10848
const std::vector<taint_tokent> &in_tested_symbols,
10949
const std::vector<taint_svaluet> &in_conditionals,
110-
const taint_svaluet &in_result,
111-
const taint_set_of_cond_suppression_idst in_suppression_ids
112-
)
113-
: tested_symbols(in_tested_symbols)
114-
, conditionals(in_conditionals)
115-
, result(in_result)
116-
, suppression_ids(in_suppression_ids)
50+
const taint_svaluet &in_result)
51+
: tested_symbols(in_tested_symbols), conditionals(in_conditionals), result(in_result)
11752
{}
11853

11954

@@ -125,22 +60,20 @@ taint_svaluet taint_make_symbol()
12560

12661
taint_svaluet taint_make_symbol(const taint_symbolic_variablet svar)
12762
{
128-
return {{},{svar},{},{}};
63+
return {{},{svar},{}};
12964
}
13065

13166

13267
taint_svaluet taint_make_bottom()
13368
{
134-
return {{},{},{},{}};
69+
return {{},{},{}};
13570
}
13671

13772
bool equal(const taint_svaluet &a, const taint_svaluet &b)
13873
{
13974
return a.get_tokens() == b.get_tokens() &&
14075
a.get_vars() == b.get_vars() &&
141-
a.get_conds() == b.get_conds() &&
142-
a.get_suppressions() == b.get_suppressions()
143-
;
76+
a.get_conds() == b.get_conds();
14477
}
14578

14679
bool proper_subset(const taint_svaluet &a, const taint_svaluet &b)
@@ -171,10 +104,6 @@ bool proper_subset(const taint_svaluet &a, const taint_svaluet &b)
171104
if (find(b.get_conds().begin(),b.get_conds().end(),elem) == b.get_conds().end())
172105
return false;
173106

174-
// TODO: this condition should be improved!
175-
if (!(a.get_suppressions() == b.get_suppressions()))
176-
return false;
177-
178107
return true;
179108
}
180109

@@ -185,80 +114,18 @@ taint_svaluet join(const taint_svaluet &a, const taint_svaluet &b)
185114
return result;
186115
}
187116

188-
taint_svaluet suppress(const taint_svaluet &a, const taint_tokent token)
189-
{
190-
taint_svaluet result=a;
191-
result.suppress(token);
192-
return result;
193-
}
194-
195-
196117
bool operator==(const taint_condt &a, const taint_condt &b)
197118
{
198119
return a.get_tested_symbols() == b.get_tested_symbols() &&
199120
a.get_conditionals() == b.get_conditionals() &&
200-
a.get_result_expression() == b.get_result_expression() &&
201-
a.get_suppression_ids() == b.get_suppression_ids()
202-
;
203-
}
204-
205-
bool operator==(const taint_token_suppressiont &a,
206-
const taint_token_suppressiont &b)
207-
{
208-
return a.get_cond_suppression_id() == b.get_cond_suppression_id() &&
209-
a.get_vars() == a.get_vars();
121+
a.get_result_expression() == b.get_result_expression();
210122
}
211123

212-
213-
//taint_svaluet suppression(
214-
// taint_svaluet const& a,
215-
// taint_svaluet::supressiont const& sub)
216-
//{
217-
// if (a.is_bottom() || a.is_top() || sub.empty())
218-
// return a;
219-
220-
// taint_set_of_svarst result_set;
221-
// std::vector<taint_symbolic_variablet> result_vector;
222-
// std::set_difference(
223-
// a.get_vars().cbegin(),a.get_vars().cend(),
224-
// sub.cbegin(),sub.cend(),
225-
// std::inserter(result_vector,result_vector.end())
226-
// );
227-
//#ifdef USE_BOOST
228-
// result_set.insert(boost::container::ordered_unique_range_t(),result_vector.begin(),result_vector.end());
229-
//#else
230-
// result.insert(result_vector.begin(),result_vector.end());
231-
//#endif
232-
233-
// if (result_set.empty())
234-
// return taint_make_bottom();
235-
236-
// taint_svaluet::supressiont result_suppression;
237-
// std::set_union(
238-
// a.suppression().cbegin(),a.suppression().cend(),
239-
// sub.cbegin(),sub.cend(),
240-
// std::inserter(result_suppression,result_suppression.end())
241-
// );
242-
243-
// return {result_set,result_suppression,false,false};
244-
//}
245-
246124
//void taint_svaluet::add_all(const taint_svaluet& other)
247125
//{
248126
// if(m_is_top)
249127
// return;
250128
// if(other.m_expression.size())
251129
// m_is_bottom=false;
252-
//#ifdef USE_BOOST
253-
// m_expression.insert(boost::container::ordered_unique_range_t(),other.m_expression.begin(),other.m_expression.end());
254-
//#else
255130
// m_expression.insert(other.m_expression.begin(),other.m_expression.end());
256-
//#endif
257-
// taint_svaluet::supressiont result_suppression;
258-
// std::set_intersection(
259-
// suppression().cbegin(),suppression().cend(),
260-
// other.suppression().cbegin(),other.suppression().cend(),
261-
// std::inserter(result_suppression,result_suppression.end())
262-
// );
263-
// m_suppression=std::move(result_suppression);
264131
//}

0 commit comments

Comments
 (0)