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
 

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
 

Detailed Description

Helper class for deferring path creation until a diagnostic is emitted.
   Copyright (C) 2024 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

Member Function Documentation

◆ generated_p()

bool lazy_diagnostic_path::generated_p ( ) const
inline

References m_inner_path.

◆ 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 i.

◆ 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 diagnostic_event::get_stack_depth(), and i.

◆ 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

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