diff options
author | David Malcolm <dmalcolm@redhat.com> | 2020-03-05 12:06:58 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2020-03-06 16:37:36 -0500 |
commit | 41f99ba6c576b84ca0f2de7d66ebc087454e93cf (patch) | |
tree | d154bf8465be154a7a5df5673bf4925b8161ff52 /gcc/analyzer/program-state.h | |
parent | 191bcd0f30dd37dec773efb0125afdcae9bd90ef (diff) | |
download | gcc-41f99ba6c576b84ca0f2de7d66ebc087454e93cf.zip gcc-41f99ba6c576b84ca0f2de7d66ebc087454e93cf.tar.gz gcc-41f99ba6c576b84ca0f2de7d66ebc087454e93cf.tar.bz2 |
analyzer: improvements to state dumping
This patch fixes a bug in which summarized state dumps involving a
non-NULL pointer to a region for which get_representative_path_var
returned NULL were erroneously dumped as "NULL".
It also extends sm-state dumps so that they show representative tree
values, where available.
Finally, it adds some selftest coverage for such dumps. Doing so
requires replacing some %qE with a dump_quoted_tree, to avoid
C vs C++ differences between "make selftest-c" and "make selftest-c++".
gcc/analyzer/ChangeLog:
* analyzer.h (dump_quoted_tree): New decl.
* engine.cc (exploded_node::dump_dot): Pass region model to
sm_state_map::print.
* program-state.cc: Include diagnostic-core.h.
(sm_state_map::print): Add "model" param and use it to print
representative trees. Only print origin information if non-null.
(sm_state_map::dump): Pass NULL for model to print call.
(program_state::print): Pass region model to sm_state_map::print.
(program_state::dump_to_pp): Use spaces rather than newlines when
summarizing. Pass region_model to sm_state_map::print.
(ana::selftest::assert_dump_eq): New function.
(ASSERT_DUMP_EQ): New macro.
(ana::selftest::test_program_state_dumping): New function.
(ana::selftest::analyzer_program_state_cc_tests): Call it.
* program-state.h (program_state::print): Add model param.
* region-model.cc (dump_quoted_tree): New function.
(map_region::print_fields): Use dump_quoted_tree rather than
%qE to avoid lang-dependent output.
(map_region::dump_child_label): Likewise.
(region_model::dump_summary_of_map): For SK_REGION, when
get_representative_path_var fails, print the region id rather than
erroneously printing NULL.
* sm.cc (state_machine::get_state_by_name): New function.
* sm.h (state_machine::get_state_by_name): New decl.
Diffstat (limited to 'gcc/analyzer/program-state.h')
-rw-r--r-- | gcc/analyzer/program-state.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/analyzer/program-state.h b/gcc/analyzer/program-state.h index 2c778cc..3637516 100644 --- a/gcc/analyzer/program-state.h +++ b/gcc/analyzer/program-state.h @@ -146,7 +146,8 @@ public: sm_state_map * clone_with_remapping (const one_way_svalue_id_map &id_map) const; - void print (const state_machine &sm, pretty_printer *pp) const; + void print (const state_machine &sm, const region_model *model, + pretty_printer *pp) const; void dump (const state_machine &sm) const; bool is_empty_p () const; |