From 3805d1c61956328720c1165c50c0d3b04baeacae Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 21 May 2020 12:31:49 -0400 Subject: [PATCH 171/179] FIXME: introduce impl_call_analyzer_eval --- gcc/analyzer/engine.cc | 14 +------------- gcc/analyzer/region-model2.cc | 17 +++++++++++++++++ gcc/analyzer/region-model2.h | 2 ++ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index 63eddb1c725..1ca2a5ab0a1 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -1682,19 +1682,7 @@ exploded_node::on_stmt2 (exploded_graph &eg, state->m_region_model->dump (false); } else if (is_special_named_call_p (call, "__analyzer_eval", 1)) - { - /* Handle the builtin "__analyzer_eval" by evaluating the input - and dumping as a dummy warning, so that test cases can use - dg-warning to validate the result (and so unexpected warnings will - lead to DejaGnu failures). */ - tree t_arg = gimple_call_arg (call, 0); - tristate t - = state->m_region_model2->eval_condition (t_arg, - NE_EXPR, - integer_zero_node, - NULL /* &ctxt*/); - warning_at (call->location, 0, "%s", t.as_string ()); - } + state->m_region_model2->impl_call_analyzer_eval (call, &ctxt); else if (is_special_named_call_p (call, "__analyzer_break", 0)) { /* Handle the builtin "__analyzer_break" by triggering a diff --git a/gcc/analyzer/region-model2.cc b/gcc/analyzer/region-model2.cc index f5a2656c190..a0ed2078451 100644 --- a/gcc/analyzer/region-model2.cc +++ b/gcc/analyzer/region-model2.cc @@ -4444,6 +4444,23 @@ region_model2::impl_call_alloca (const call_details &cd) return true; } +/* Handle the "__analyzer_eval" by evaluating the input + and dumping as a dummy warning, so that test cases can use + dg-warning to validate the result (and so unexpected warnings will + lead to DejaGnu failures). + Broken out as a subroutine to make it easier to put a breakpoint on it + - though typically this doesn't help, as we have an SSA name as the arg, + and what's more interesting is usually the def stmt for that name. */ + +void +region_model2::impl_call_analyzer_eval (const gcall *call, + region_model2_context *ctxt) +{ + tree t_arg = gimple_call_arg (call, 0); + tristate t = eval_condition (t_arg, NE_EXPR, integer_zero_node, ctxt); + warning_at (call->location, 0, "%s", t.as_string ()); +} + /* Handle the on_call_pre part of "__builtin_expect" etc. */ bool diff --git a/gcc/analyzer/region-model2.h b/gcc/analyzer/region-model2.h index 8d5c483dded..cec326000cd 100644 --- a/gcc/analyzer/region-model2.h +++ b/gcc/analyzer/region-model2.h @@ -1819,6 +1819,8 @@ class region_model2 /* Specific handling for on_call_pre. */ bool impl_call_alloca (const call_details &cd); + void impl_call_analyzer_eval (const gcall *call, + region_model2_context *ctxt); bool impl_call_builtin_expect (const call_details &cd); bool impl_call_calloc (const call_details &cd); bool impl_call_malloc (const call_details &cd); -- 2.21.0