Skip to content

Commit 06fcd4f

Browse files
authored
Merge pull request diffblue#202 from diffblue/feature/type_checks
SEC-66 : Added few type-checking is_* functions.
2 parents 2216e08 + 0a4b82c commit 06fcd4f

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/taint-slicer/instrumenter.cpp

+49
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,51 @@ exprt taint_instrumentert::
9999
return fixed_initialiser;
100100
}
101101

102+
static bool is_array_reference(const typet &type)
103+
{
104+
return type.id()==ID_symbol &&
105+
to_symbol_type(type).get_identifier()=="java::array[reference]";
106+
}
107+
108+
static bool is_pointer_to_array_reference(const typet &type)
109+
{
110+
return type.id()==ID_pointer &&
111+
is_array_reference(to_pointer_type(type).subtype());
112+
}
113+
114+
static bool is_binary_expression(const exprt &expr)
115+
{
116+
return expr.id()==ID_lt ||
117+
expr.id()==ID_le ||
118+
expr.id()==ID_gt ||
119+
expr.id()==ID_ge ||
120+
expr.id()==ID_equal ||
121+
expr.id()==ID_notequal ||
122+
expr.id()==ID_plus ||
123+
expr.id()==ID_minus ||
124+
expr.id()==ID_mult ||
125+
expr.id()==ID_div ||
126+
expr.id()==ID_mod ||
127+
expr.id()==ID_rem ||
128+
expr.id()==ID_shr ||
129+
expr.id()==ID_ashr ||
130+
expr.id()==ID_lshr ||
131+
expr.id()==ID_shl ||
132+
expr.id()==ID_rol ||
133+
expr.id()==ID_ror;
134+
}
135+
136+
static bool is_unary_expression(const exprt &expr)
137+
{
138+
return expr.id()==ID_unary_plus || expr.id()==ID_unary_minus;
139+
}
140+
141+
static bool is_unary_or_binary_expression(const exprt &expr)
142+
{
143+
return is_binary_expression(expr) ||
144+
is_unary_expression(expr);
145+
}
146+
102147
void taint_instrumentert::instrument_instructions_with_shadow_variables(
103148
goto_programt::instructionst &instructions_to_be_instrumented,
104149
const taint_instrumentation_propst &props) const
@@ -175,6 +220,10 @@ taint_instrumentert::taint_instrumentert(
175220
, use_data_flow_insensitive_version(
176221
in_props.data_flow_insensitive_version_applied())
177222
{
223+
// The line below contains two dummy statements preventing Travis complain
224+
// about not used functions. These statements will be erased in the next PR
225+
// when the functions will be used.
226+
(void)&is_pointer_to_array_reference; (void)&is_unary_or_binary_expression;
178227
}
179228

180229
/// Builds a new symbol table from the original symbol

0 commit comments

Comments
 (0)