LLDB mainline
lldb_private::CompilerDeclContext Class Reference

Represents a generic declaration context in a program. More...

#include <CompilerDeclContext.h>

Public Member Functions

 CompilerDeclContext ()=default
 Constructs an invalid CompilerDeclContext.
 CompilerDeclContext (TypeSystem *type_system, void *decl_ctx)
 Constructs a CompilerDeclContext with the given opaque decl context and its respective TypeSystem instance.
 operator bool () const
bool operator< (const CompilerDeclContext &rhs) const
bool IsValid () const
std::vector< lldb_private::CompilerContextGetCompilerContext () const
 Populate a valid compiler context from the current decl context.
std::vector< CompilerDeclFindDeclByName (ConstString name, const bool ignore_using_decls)
bool IsClassMethod ()
 Checks if this decl context represents a method of a class.
lldb::LanguageType GetLanguage ()
 Determines the original language of the decl context.
bool IsContainedInLookup (CompilerDeclContext other) const
 Check if the given other decl context is contained in the lookup of this decl context (for example because the other context is a nested inline namespace).
TypeSystemGetTypeSystem () const
void * GetOpaqueDeclContext () const
void SetDeclContext (TypeSystem *type_system, void *decl_ctx)
void Clear ()
ConstString GetName () const
ConstString GetScopeQualifiedName () const

Private Attributes

TypeSystemm_type_system = nullptr
void * m_opaque_decl_ctx = nullptr

Detailed Description

Represents a generic declaration context in a program.

A declaration context is data structure that contains declarations (e.g. namespaces).

This class serves as an abstraction for a declaration context inside one of the TypeSystems implemented by the language plugins. It does not have any actual logic in it but only stores an opaque pointer and a pointer to the TypeSystem that gives meaning to this opaque pointer. All methods of this class should call their respective method in the TypeSystem interface and pass the opaque pointer along.

See also
lldb_private::TypeSystem

Definition at line 31 of file CompilerDeclContext.h.

Constructor & Destructor Documentation

◆ CompilerDeclContext() [1/2]

lldb_private::CompilerDeclContext::CompilerDeclContext ( )
default

Constructs an invalid CompilerDeclContext.

Referenced by IsContainedInLookup(), and operator<().

◆ CompilerDeclContext() [2/2]

lldb_private::CompilerDeclContext::CompilerDeclContext ( TypeSystem * type_system,
void * decl_ctx )
inline

Constructs a CompilerDeclContext with the given opaque decl context and its respective TypeSystem instance.

This constructor should only be called from the respective TypeSystem implementation.

See also
lldb_private::TypeSystemClang::CreateDeclContext(clang::DeclContext*)

Definition at line 43 of file CompilerDeclContext.h.

References m_opaque_decl_ctx, and m_type_system.

Member Function Documentation

◆ Clear()

void lldb_private::CompilerDeclContext::Clear ( )
inline

Definition at line 103 of file CompilerDeclContext.h.

References m_opaque_decl_ctx, and m_type_system.

◆ FindDeclByName()

std::vector< CompilerDecl > CompilerDeclContext::FindDeclByName ( ConstString name,
const bool ignore_using_decls )

◆ GetCompilerContext()

std::vector< lldb_private::CompilerContext > CompilerDeclContext::GetCompilerContext ( ) const

Populate a valid compiler context from the current decl context.

Returns
A valid vector of CompilerContext entries that describes this declaration context. The first entry in the vector is the parent of the subsequent entry, so the topmost entry is the global namespace.

Definition at line 63 of file CompilerDeclContext.cpp.

References IsValid(), m_opaque_decl_ctx, and m_type_system.

Referenced by lldb_private::plugin::dwarf::DebugNamesDWARFIndex::GetNamespacesWithParents(), and lldb_private::TypeQuery::TypeQuery().

◆ GetLanguage()

lldb::LanguageType CompilerDeclContext::GetLanguage ( )

Determines the original language of the decl context.

Definition at line 43 of file CompilerDeclContext.cpp.

References IsValid(), m_opaque_decl_ctx, and m_type_system.

◆ GetName()

◆ GetOpaqueDeclContext()

◆ GetScopeQualifiedName()

ConstString CompilerDeclContext::GetScopeQualifiedName ( ) const

◆ GetTypeSystem()

◆ IsClassMethod()

bool CompilerDeclContext::IsClassMethod ( )

Checks if this decl context represents a method of a class.

Returns
Returns true if this is a decl context that represents a method in a struct, union or class.

Definition at line 37 of file CompilerDeclContext.cpp.

References IsValid(), m_opaque_decl_ctx, and m_type_system.

Referenced by lldb_private::ClangExpressionDeclMap::LookupFunction(), and lldb_private::ClangExpressionDeclMap::SearchFunctionsInSymbolContexts().

◆ IsContainedInLookup()

bool CompilerDeclContext::IsContainedInLookup ( CompilerDeclContext other) const

Check if the given other decl context is contained in the lookup of this decl context (for example because the other context is a nested inline namespace).

Parameters
[in]otherThe other decl context for which we should check if it is contained in the lookoup of this context.
Returns
Returns true iff the other decl context is contained in the lookup of this decl context.

Definition at line 49 of file CompilerDeclContext.cpp.

References CompilerDeclContext(), IsValid(), m_opaque_decl_ctx, and m_type_system.

Referenced by lldb_private::plugin::dwarf::SymbolFileDWARF::DIEInDeclContext(), and lldb_private::plugin::dwarf::SymbolFileDWARF::FindGlobalVariables().

◆ IsValid()

◆ operator bool()

lldb_private::CompilerDeclContext::operator bool ( ) const
inlineexplicit

Definition at line 48 of file CompilerDeclContext.h.

References IsValid().

◆ operator<()

bool lldb_private::CompilerDeclContext::operator< ( const CompilerDeclContext & rhs) const
inline

Definition at line 50 of file CompilerDeclContext.h.

References CompilerDeclContext(), m_opaque_decl_ctx, and m_type_system.

◆ SetDeclContext()

void lldb_private::CompilerDeclContext::SetDeclContext ( TypeSystem * type_system,
void * decl_ctx )
inline

Definition at line 98 of file CompilerDeclContext.h.

References m_opaque_decl_ctx, and m_type_system.

Member Data Documentation

◆ m_opaque_decl_ctx

void* lldb_private::CompilerDeclContext::m_opaque_decl_ctx = nullptr
private

◆ m_type_system


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