GCC Middle and Back End API Reference
diagnostics::logical_locations::key Class Reference

#include <logical-locations.h>

Public Member Functions

 key ()
 operator bool () const
template<typename T>
T cast_to () const
bool operator== (const key &other) const
bool operator!= (const key &other) const
bool operator< (const key &other) const

Static Public Member Functions

static key from_ptr (const void *ptr)

Private Member Functions

 key (const void *ptr)

Private Attributes

const void * m_ptr

Detailed Description

We want to efficiently support passing around logical locations in the
diagnostics subsystem, such as:
- "within function 'foo'", or
- "within method 'bar'"

However we want to do this *without* requiring knowledge of trees (or of
libgdiagnostics internals), and without requiring heap allocation of an
interface class when emitting a diagnostic.

To do this, we split the implementation into logical_locations::key, which is
a wrapper around a (const void *), and logical_locations::manager which
is provided by the client and has vfunc hooks for interpreting
key instances.

Every logical_locations::key is associated with a logical_locations::manager
and only has meaning in relation to that manager.

A "nullptr" within a key means "no logical location".

See tree-logical-location.h for concrete subclasses relating to trees,
where the pointer is a const_tree.

See diagnostics/selftest-logical-locations.h for a concrete subclass for
selftests.   
Extrinsic state for identifying a specific logical location.
This will be our logical location type.
This only makes sense with respect to a specific manager.
e.g. for a tree-based one it's a wrapper around "tree".

"nullptr" means "no logical location".

Note that there is no integration with GCC's garbage collector and thus
keys can't be long-lived.   

Constructor & Destructor Documentation

◆ key() [1/2]

diagnostics::logical_locations::key::key ( )
inline

References m_ptr.

Referenced by from_ptr(), operator!=(), operator<(), and operator==().

◆ key() [2/2]

diagnostics::logical_locations::key::key ( const void * ptr)
inlineexplicitprivate

References m_ptr.

Member Function Documentation

◆ cast_to()

template<typename T>
T diagnostics::logical_locations::key::cast_to ( ) const
inline

◆ from_ptr()

key diagnostics::logical_locations::key::from_ptr ( const void * ptr)
inlinestatic

◆ operator bool()

diagnostics::logical_locations::key::operator bool ( ) const
inline

References m_ptr.

◆ operator!=()

bool diagnostics::logical_locations::key::operator!= ( const key & other) const
inline

References key(), and m_ptr.

◆ operator<()

bool diagnostics::logical_locations::key::operator< ( const key & other) const
inline

References key(), and m_ptr.

◆ operator==()

bool diagnostics::logical_locations::key::operator== ( const key & other) const
inline

References key(), and m_ptr.

Field Documentation

◆ m_ptr

const void* diagnostics::logical_locations::key::m_ptr
private

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