Skip to content

Commit 2dad5d8

Browse files
Merge pull request diffblue#405 from diffblue/feature/remove-find_or_create_symbol_expr
Don't use find_or_create_symbol_expr for symbols that must already exist
2 parents 6fa4987 + 9c188f4 commit 2dad5d8

File tree

2 files changed

+7
-38
lines changed

2 files changed

+7
-38
lines changed

src/taint-analysis/taint_program.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016-2017 Diffblue Limited. All Rights Reserved.
1+
// Copyright 2016-2018 Diffblue Limited. All Rights Reserved.
22

33
/// \file
44
/// taint_programt
@@ -12,11 +12,6 @@
1212
#include <analyses/call_graph_helpers.h>
1313
#include <unordered_set>
1414

15-
extern symbol_exprt find_or_create_symbol_expr(
16-
const namespacet &ns,
17-
const irep_idt &symbol_name,
18-
const typet &symbol_type);
19-
2015
static void build_NONDET_retvals_replacements(
2116
const goto_modelt &model,
2217
const namespacet &ns,
@@ -98,9 +93,6 @@ static void build_NONDET_retvals_replacements(
9893
const irep_idt &callee_ident=
9994
to_symbol_expr(fn_call.function()).get_identifier();
10095

101-
const code_typet &fn_type=
102-
model.goto_functions.function_map.at(callee_ident).type;
103-
10496
const code_assignt &asgn=to_code_assign(next_instr_it->code);
10597
if(asgn.rhs().id()!=ID_side_effect)
10698
continue;
@@ -110,10 +102,7 @@ static void build_NONDET_retvals_replacements(
110102
replacements.insert(
111103
{
112104
next_instr_it,
113-
find_or_create_symbol_expr(
114-
ns,
115-
as_string(callee_ident)+RETURN_VALUE_SUFFIX,
116-
fn_type.return_type())
105+
ns.lookup(id2string(callee_ident) + RETURN_VALUE_SUFFIX).symbol_expr()
117106
});
118107
}
119108
}

src/taint-analysis/taint_summary.cpp

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -342,22 +342,6 @@ std::string taint_summaryt::description() const noexcept
342342
///
343343
////////////////////////////////////////////////////////////////////////////////
344344

345-
346-
symbol_exprt find_or_create_symbol_expr(
347-
const namespacet &ns,
348-
const irep_idt &symbol_name,
349-
const typet &symbol_type)
350-
{
351-
const symbolt *symbol_ptr;
352-
if(ns.lookup(symbol_name, symbol_ptr))
353-
{
354-
assert(false);
355-
return symbol_exprt(symbol_name, symbol_type);
356-
}
357-
assert(symbol_ptr!=nullptr);
358-
return symbol_ptr->symbol_expr();
359-
}
360-
361345
/// \brief If the passed expression in a non-null pointer expression, then
362346
/// the dereference expression is returned. Otherwise the original expression
363347
/// is returned.
@@ -1096,7 +1080,7 @@ numbered_lvalue_to_taint_mapt taint_algorithm_computing_summary_of_functiont::
10961080
if(callee_expr.id()==ID_symbol)
10971081
{
10981082
irep_idt callee_id = to_symbol_expr(callee_expr).get_identifier();
1099-
const std::string callee_ident = as_string(callee_id);
1083+
const std::string &callee_ident = as_string(callee_id);
11001084
const code_typet &fn_type =
11011085
program->get_functions().function_map.at(callee_id).type;
11021086
if(database.contains(callee_id))
@@ -1187,10 +1171,8 @@ numbered_lvalue_to_taint_mapt taint_algorithm_computing_summary_of_functiont::
11871171
&result_location))
11881172
{
11891173
// Update of return_value of the callee.
1190-
result_lvalue = find_or_create_symbol_expr(
1191-
program->get_namespace(),
1192-
callee_ident + RETURN_VALUE_SUFFIX,
1193-
fn_type.return_type());
1174+
result_lvalue = program->get_namespace()
1175+
.lookup(callee_ident + RETURN_VALUE_SUFFIX).symbol_expr();
11941176
}
11951177
else if(
11961178
const taintable_location_argumentt *result_argument =
@@ -1253,10 +1235,8 @@ numbered_lvalue_to_taint_mapt taint_algorithm_computing_summary_of_functiont::
12531235
&sanitized_location))
12541236
{
12551237
// Update of return_value of the callee.
1256-
result_lvalue = find_or_create_symbol_expr(
1257-
program->get_namespace(),
1258-
callee_ident + RETURN_VALUE_SUFFIX,
1259-
fn_type.return_type());
1238+
result_lvalue = program->get_namespace()
1239+
.lookup(callee_ident + RETURN_VALUE_SUFFIX).symbol_expr();
12601240
}
12611241
else if(
12621242
const taintable_location_argumentt *sanitized_argument =

0 commit comments

Comments
 (0)