GCC Middle and Back End API Reference
lazy_diagnostic_path Class Referenceabstract

#include <lazy-diagnostic-path.h>

Inheritance diagram for lazy_diagnostic_path:
Collaboration diagram for lazy_diagnostic_path:

Public Member Functions

virtual ~lazy_diagnostic_path ()
unsigned num_events () const final override
const diagnostic_eventget_event (int idx) const final override
unsigned num_threads () const final override
const diagnostic_threadget_thread (diagnostic_thread_id_t) const final override
bool same_function_p (int event_idx_a, int event_idx_b) const final override
bool generated_p () const
bool interprocedural_p () const
bool multithreaded_p () const
const logical_location_managerget_logical_location_manager () const

Protected Member Functions

 lazy_diagnostic_path (const logical_location_manager &logical_loc_mgr)

Private Member Functions

void lazily_generate_path () const
virtual std::unique_ptr< diagnostic_pathmake_inner_path () const =0
bool get_first_event_in_a_function (unsigned *out_idx) const

Private Attributes

std::unique_ptr< diagnostic_pathm_inner_path
const logical_location_managerm_logical_loc_mgr

Detailed Description

Helper class for deferring path creation until a diagnostic is emitted. Copyright (C) 2024-2025 Free Software Foundation, Inc. Contributed by David Malcolm <dmalcolm@redhat.com> This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
An implementation of diagnostic_path which has a trivial ctor and lazily creates another diagnostic_path the first time the path is queried, deferring to this inner path for all queries. Use this to avoid expensive path creation logic when creating rich_location instances, so that expense can be deferred until the path is actually used by a diagnostic, and thus avoided for warnings that are disabled.

Constructor & Destructor Documentation

◆ ~lazy_diagnostic_path()

virtual lazy_diagnostic_path::~lazy_diagnostic_path ( )
inlinevirtual

◆ lazy_diagnostic_path()

lazy_diagnostic_path::lazy_diagnostic_path ( const logical_location_manager & logical_loc_mgr)
inlineprotected

Member Function Documentation

◆ generated_p()

bool lazy_diagnostic_path::generated_p ( ) const
inline

References generated_p(), and m_inner_path.

Referenced by generated_p().

◆ get_event()

const diagnostic_event & lazy_diagnostic_path::get_event ( int idx) const
finaloverridevirtual

Implements diagnostic_path.

References lazily_generate_path(), and m_inner_path.

◆ get_first_event_in_a_function()

bool diagnostic_path::get_first_event_in_a_function ( unsigned * out_idx) const
privateinherited
class diagnostic_path.
Subroutine of diagnostic_path::interprocedural_p. Look for the first event in this path that is within a function i.e. has a non-null logical location for which function_p is true. If found, write its index to *OUT_IDX and return true. Otherwise return false.

References get_event(), i, m_logical_loc_mgr, and num_events().

Referenced by interprocedural_p().

◆ get_logical_location_manager()

const logical_location_manager & diagnostic_path::get_logical_location_manager ( ) const
inlineinherited

References m_logical_loc_mgr.

◆ get_thread()

const diagnostic_thread & lazy_diagnostic_path::get_thread ( diagnostic_thread_id_t idx) const
finaloverridevirtual

Implements diagnostic_path.

References lazily_generate_path(), and m_inner_path.

◆ interprocedural_p()

bool diagnostic_path::interprocedural_p ( ) const
inherited
Return true if the events in this path involve more than one function, or false if it is purely intraprocedural.

References get_event(), get_first_event_in_a_function(), diagnostic_event::get_stack_depth(), i, num_events(), and same_function_p().

◆ lazily_generate_path()

void lazy_diagnostic_path::lazily_generate_path ( ) const
private

◆ make_inner_path()

virtual std::unique_ptr< diagnostic_path > lazy_diagnostic_path::make_inner_path ( ) const
privatepure virtual

Referenced by lazily_generate_path().

◆ multithreaded_p()

bool diagnostic_path::multithreaded_p ( ) const
inherited

◆ num_events()

unsigned lazy_diagnostic_path::num_events ( ) const
finaloverridevirtual
class lazy_diagnostic_path : public diagnostic_path.
Implementation of diagnostic_path vfuncs in terms of a lazily-generated path.

Implements diagnostic_path.

References lazily_generate_path(), and m_inner_path.

◆ num_threads()

unsigned lazy_diagnostic_path::num_threads ( ) const
finaloverridevirtual

Implements diagnostic_path.

References lazily_generate_path(), and m_inner_path.

◆ same_function_p()

bool lazy_diagnostic_path::same_function_p ( int event_idx_a,
int event_idx_b ) const
finaloverridevirtual

Implements diagnostic_path.

References lazily_generate_path(), and m_inner_path.

Field Documentation

◆ m_inner_path

std::unique_ptr<diagnostic_path> lazy_diagnostic_path::m_inner_path
mutableprivate

◆ m_logical_loc_mgr

const logical_location_manager& diagnostic_path::m_logical_loc_mgr
privateinherited

The documentation for this class was generated from the following files: