aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-path.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2025-04-28 18:21:25 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2025-04-28 18:21:25 -0400
commita1922f0252b3b09016df76bd5b10119206935e37 (patch)
treee17e22b521755bf82b78e832172ea6f0071eeee1 /gcc/rust/ast/rust-path.h
parent2a63dc8c65d469e1d7ac3d764179653bf0ec843f (diff)
downloadgcc-a1922f0252b3b09016df76bd5b10119206935e37.zip
gcc-a1922f0252b3b09016df76bd5b10119206935e37.tar.gz
gcc-a1922f0252b3b09016df76bd5b10119206935e37.tar.bz2
analyzer: handle NRVO and DECL_BY_REFERENCE [PR111536]
The analyzer was issuing false warnings about uninitialized variables in C++ in places where NRVO was marking DECL_RESULT with DECL_BY_REFERENCE. Fixed thusly. gcc/analyzer/ChangeLog: PR analyzer/111536 * engine.cc (maybe_update_for_edge): Update for new call_stmt param to region_model::push_frame. * program-state.cc (program_state::push_frame): Likewise. * region-model.cc (region_model::update_for_gcall): Likewise. (region_model::push_frame): Add "call_stmt" param. Handle DECL_RESULT with DECL_BY_REFERENCE set on it by stashing the region of the lhs of the call_stmt in the caller frame, and writing a reference to it within the "result" in the callee frame. (region_model::pop_frame): Don't write back to the LHS for DECL_BY_REFERENCE results. (selftest::test_stack_frames): Update for new call_stmt param to region_model::push_frame. (selftest::test_get_representative_path_var): Likewise. (selftest::test_state_merging): Likewise. (selftest::test_alloca): Likewise. * region-model.h (region_model::push_frame): Add "call_stmt" param. * region.cc: Include "tree-ssa.h". (region::can_have_initial_svalue_p): Use ssa_defined_default_def_p for ssa names, rather than special-casing it for just parameters. This should now also cover DECL_RESULT with DECL_BY_REFERENCE and hard registers. * sm-signal.cc (update_model_for_signal_handler): Update for new call_stmt param to region_model::push_frame. * state-purge.cc (state_purge_per_decl::process_worklists): Likewise. gcc/testsuite/ChangeLog: PR analyzer/111536 * c-c++-common/analyzer/hard-reg-1.c: New test. * g++.dg/analyzer/nrvo-1.C: New test. * g++.dg/analyzer/nrvo-2.C: New test. * g++.dg/analyzer/nrvo-pr111536-1.C: New test. * g++.dg/analyzer/nrvo-pr111536-1b.C: New test. * g++.dg/analyzer/nrvo-pr111536-2.C: New test. * g++.dg/analyzer/nrvo-pr111536-2b.C: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/rust/ast/rust-path.h')
0 files changed, 0 insertions, 0 deletions