/* Handle the on_call_pre part of "alloca". */
-bool
+void
region_model::impl_call_alloca (const call_details &cd)
{
const svalue *size_sval = cd.get_arg_svalue (0);
const svalue *ptr_sval
= m_mgr->get_ptr_svalue (cd.get_lhs_type (), new_reg);
cd.maybe_set_lhs (ptr_sval);
- return true;
}
/* Handle a call to "__analyzer_describe".
/* Handle the on_call_pre part of "__builtin_expect" etc. */
-bool
+void
region_model::impl_call_builtin_expect (const call_details &cd)
{
/* __builtin_expect's return value is its initial argument. */
const svalue *sval = cd.get_arg_svalue (0);
cd.maybe_set_lhs (sval);
- return false;
}
/* Handle the on_call_pre part of "calloc". */
-bool
+void
region_model::impl_call_calloc (const call_details &cd)
{
const svalue *nmemb_sval = cd.get_arg_svalue (0);
= m_mgr->get_ptr_svalue (cd.get_lhs_type (), new_reg);
cd.maybe_set_lhs (ptr_sval);
}
- return true;
}
/* Handle the on_call_pre part of "error" and "error_at_line" from
/* Handle the on_call_pre part of "malloc". */
-bool
+void
region_model::impl_call_malloc (const call_details &cd)
{
const svalue *size_sval = cd.get_arg_svalue (0);
= m_mgr->get_ptr_svalue (cd.get_lhs_type (), new_reg);
cd.maybe_set_lhs (ptr_sval);
}
- return true;
}
/* Handle the on_call_pre part of "memcpy" and "__builtin_memcpy". */
/* Handle the on_call_pre part of "memset" and "__builtin_memset". */
-bool
+void
region_model::impl_call_memset (const call_details &cd)
{
const svalue *dest_sval = cd.get_arg_svalue (0);
num_bytes_sval);
check_region_for_write (sized_dest_reg, cd.get_ctxt ());
fill_region (sized_dest_reg, fill_value_u8);
- return true;
}
/* Handle the on_call_pre part of "operator new". */
-bool
+void
region_model::impl_call_operator_new (const call_details &cd)
{
const svalue *size_sval = cd.get_arg_svalue (0);
= m_mgr->get_ptr_svalue (cd.get_lhs_type (), new_reg);
cd.maybe_set_lhs (ptr_sval);
}
- return false;
}
/* Handle the on_call_pre part of "operator delete", which comes in
both sized and unsized variants (2 arguments and 1 argument
respectively). */
-bool
+void
region_model::impl_call_operator_delete (const call_details &cd)
{
const svalue *ptr_sval = cd.get_arg_svalue (0);
poisoning pointers. */
unbind_region_and_descendents (freed_reg, POISON_KIND_FREED);
}
- return false;
}
/* Handle the on_call_pre part of "realloc". */
mark_region_as_unknown (dest_reg, cd.get_uncertainty ());
}
-/* Handle the on_call_pre part of "strlen".
- Return true if the LHS is updated. */
+/* Handle the on_call_pre part of "strlen". */
-bool
+void
region_model::impl_call_strlen (const call_details &cd)
{
region_model_context *ctxt = cd.get_ctxt ();
const svalue *result_sval
= m_mgr->get_or_create_constant_svalue (t_cst);
cd.maybe_set_lhs (result_sval);
- return true;
+ return;
}
}
- /* Otherwise an unknown value. */
- return true;
+ /* Otherwise a conjured value. */
}
/* Handle calls to functions referenced by
default:
break;
case IFN_BUILTIN_EXPECT:
- return impl_call_builtin_expect (cd);
+ impl_call_builtin_expect (cd);
+ return false;
}
}
break;
case BUILT_IN_ALLOCA:
case BUILT_IN_ALLOCA_WITH_ALIGN:
- return impl_call_alloca (cd);
+ impl_call_alloca (cd);
+ return false;
case BUILT_IN_CALLOC:
- return impl_call_calloc (cd);
+ impl_call_calloc (cd);
+ return false;
case BUILT_IN_EXPECT:
case BUILT_IN_EXPECT_WITH_PROBABILITY:
- return impl_call_builtin_expect (cd);
+ impl_call_builtin_expect (cd);
+ return false;
case BUILT_IN_FREE:
/* Handle in "on_call_post". */
break;
case BUILT_IN_MALLOC:
- return impl_call_malloc (cd);
+ impl_call_malloc (cd);
+ return false;
case BUILT_IN_MEMCPY:
case BUILT_IN_MEMCPY_CHK:
impl_call_memcpy (cd);
impl_call_strcpy (cd);
return false;
case BUILT_IN_STRLEN:
- if (impl_call_strlen (cd))
- return false;
- break;
+ impl_call_strlen (cd);
+ return false;
/* Stdio builtins. */
case BUILT_IN_FPRINTF:
break;
}
else if (is_named_call_p (callee_fndecl, "malloc", call, 1))
- return impl_call_malloc (cd);
+ {
+ impl_call_malloc (cd);
+ return false;
+ }
else if (is_named_call_p (callee_fndecl, "calloc", call, 2))
- return impl_call_calloc (cd);
+ {
+ impl_call_calloc (cd);
+ return false;
+ }
else if (is_named_call_p (callee_fndecl, "alloca", call, 1))
- return impl_call_alloca (cd);
+ {
+ impl_call_alloca (cd);
+ return false;
+ }
else if (is_named_call_p (callee_fndecl, "realloc", call, 2))
{
impl_call_realloc (cd);
else if (is_named_call_p (callee_fndecl, "strlen", call, 1)
&& POINTER_TYPE_P (cd.get_arg_type (0)))
{
- if (impl_call_strlen (cd))
- return false;
+ impl_call_strlen (cd);
+ return false;
}
else if (is_named_call_p (callee_fndecl, "operator new", call, 1))
- return impl_call_operator_new (cd);
+ {
+ impl_call_operator_new (cd);
+ return false;
+ }
else if (is_named_call_p (callee_fndecl, "operator new []", call, 1))
- return impl_call_operator_new (cd);
+ {
+ impl_call_operator_new (cd);
+ return false;
+ }
else if (is_named_call_p (callee_fndecl, "operator delete", call, 1)
|| is_named_call_p (callee_fndecl, "operator delete", call, 2)
|| is_named_call_p (callee_fndecl, "operator delete []", call, 1))
void purge_state_involving (const svalue *sval, region_model_context *ctxt);
/* Specific handling for on_call_pre. */
- bool impl_call_alloca (const call_details &cd);
+ void impl_call_alloca (const call_details &cd);
void impl_call_analyzer_describe (const gcall *call,
region_model_context *ctxt);
void impl_call_analyzer_dump_capacity (const gcall *call,
region_model_context *ctxt);
void impl_call_analyzer_eval (const gcall *call,
region_model_context *ctxt);
- bool impl_call_builtin_expect (const call_details &cd);
- bool impl_call_calloc (const call_details &cd);
+ void impl_call_builtin_expect (const call_details &cd);
+ void impl_call_calloc (const call_details &cd);
bool impl_call_error (const call_details &cd, unsigned min_args,
bool *out_terminate_path);
void impl_call_fgets (const call_details &cd);
void impl_call_fread (const call_details &cd);
void impl_call_free (const call_details &cd);
- bool impl_call_malloc (const call_details &cd);
+ void impl_call_malloc (const call_details &cd);
void impl_call_memcpy (const call_details &cd);
- bool impl_call_memset (const call_details &cd);
+ void impl_call_memset (const call_details &cd);
void impl_call_realloc (const call_details &cd);
void impl_call_strcpy (const call_details &cd);
- bool impl_call_strlen (const call_details &cd);
- bool impl_call_operator_new (const call_details &cd);
- bool impl_call_operator_delete (const call_details &cd);
+ void impl_call_strlen (const call_details &cd);
+ void impl_call_operator_new (const call_details &cd);
+ void impl_call_operator_delete (const call_details &cd);
void impl_deallocation_call (const call_details &cd);
void handle_unrecognized_call (const gcall *call,