LLDB mainline
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
lldb_private::RichManglingContext Class Reference

Uniform wrapper for access to rich mangling information from different providers. More...

#include <RichManglingContext.h>

Public Member Functions

 RichManglingContext ()
 
 ~RichManglingContext ()
 
bool FromItaniumName (ConstString mangled)
 Use the ItaniumPartialDemangler to obtain rich mangling information from the given mangled name.
 
bool FromCxxMethodName (ConstString demangled)
 Use the legacy language parser implementation to obtain rich mangling information from the given demangled name.
 
bool IsCtorOrDtor () const
 If this symbol describes a constructor or destructor.
 
llvm::StringRef ParseFunctionBaseName ()
 Get the base name of a function.
 
llvm::StringRef ParseFunctionDeclContextName ()
 Get the context name for a function.
 
llvm::StringRef ParseFullName ()
 Get the entire demangled name.
 

Private Types

enum  InfoProvider { None , ItaniumPartialDemangler , PluginCxxLanguage }
 

Private Member Functions

void ResetCxxMethodParser ()
 Clean up memory when using PluginCxxLanguage.
 
void ResetProvider (InfoProvider new_provider)
 Clean up memory and set a new info provider for this instance.
 
llvm::StringRef processIPDStrResult (char *ipd_res, size_t res_len)
 Uniform handling of string buffers for ItaniumPartialDemangler.
 

Static Private Member Functions

template<class ParserT >
static ParserT * get (llvm::Any parser)
 Cast the given parser to the given type.
 

Private Attributes

InfoProvider m_provider = None
 Selects the rich mangling info provider.
 
llvm::ItaniumPartialDemangler m_ipd
 Members for ItaniumPartialDemangler.
 
char * m_ipd_buf
 Note: m_ipd_buf is a raw pointer due to being resized by realloc via ItaniumPartialDemangler.
 
size_t m_ipd_buf_size = 2048
 
llvm::Any m_cxx_method_parser
 Members for PluginCxxLanguage Cannot forward declare inner class CPlusPlusLanguage::MethodName.
 

Detailed Description

Uniform wrapper for access to rich mangling information from different providers.

See Mangled::DemangleWithRichManglingInfo()

Definition at line 25 of file RichManglingContext.h.

Member Enumeration Documentation

◆ InfoProvider

Enumerator
None 
ItaniumPartialDemangler 
PluginCxxLanguage 

Definition at line 57 of file RichManglingContext.h.

Constructor & Destructor Documentation

◆ RichManglingContext()

lldb_private::RichManglingContext::RichManglingContext ( )
inline

Definition at line 27 of file RichManglingContext.h.

References m_ipd_buf, and m_ipd_buf_size.

◆ ~RichManglingContext()

RichManglingContext::~RichManglingContext ( )

Definition at line 19 of file RichManglingContext.cpp.

References m_ipd_buf, and ResetCxxMethodParser().

Member Function Documentation

◆ FromCxxMethodName()

bool RichManglingContext::FromCxxMethodName ( ConstString  demangled)

Use the legacy language parser implementation to obtain rich mangling information from the given demangled name.

Definition at line 60 of file RichManglingContext.cpp.

References m_cxx_method_parser, PluginCxxLanguage, and ResetProvider().

Referenced by lldb_private::Mangled::GetRichManglingInfo().

◆ FromItaniumName()

bool RichManglingContext::FromItaniumName ( ConstString  mangled)

Use the ItaniumPartialDemangler to obtain rich mangling information from the given mangled name.

Definition at line 41 of file RichManglingContext.cpp.

References lldb_private::Demangle, lldb_private::ConstString::GetCString(), lldb_private::GetLog(), ItaniumPartialDemangler, LLDB_LOG, m_ipd, m_ipd_buf, ParseFullName(), and ResetProvider().

Referenced by lldb_private::Mangled::GetRichManglingInfo().

◆ get()

template<class ParserT >
static ParserT * lldb_private::RichManglingContext::get ( llvm::Any  parser)
inlinestaticprivate

Cast the given parser to the given type.

Ideally we would have a type trait to deduce ParserT from a given InfoProvider, but unfortunately we can't access CPlusPlusLanguage::MethodName from within the header.

Definition at line 88 of file RichManglingContext.h.

◆ IsCtorOrDtor()

bool RichManglingContext::IsCtorOrDtor ( ) const

If this symbol describes a constructor or destructor.

Definition at line 66 of file RichManglingContext.cpp.

References ItaniumPartialDemangler, m_cxx_method_parser, m_ipd, m_provider, None, and PluginCxxLanguage.

Referenced by lldb_private::Symtab::RegisterMangledNameEntry().

◆ ParseFullName()

llvm::StringRef RichManglingContext::ParseFullName ( )

Get the entire demangled name.

Definition at line 146 of file RichManglingContext.cpp.

References ItaniumPartialDemangler, m_cxx_method_parser, m_ipd, m_ipd_buf, m_ipd_buf_size, m_provider, None, PluginCxxLanguage, and processIPDStrResult().

Referenced by FromItaniumName().

◆ ParseFunctionBaseName()

llvm::StringRef RichManglingContext::ParseFunctionBaseName ( )

Get the base name of a function.

This doesn't include trailing template arguments, ie "a::b<int>" gives "b".

Definition at line 112 of file RichManglingContext.cpp.

References ItaniumPartialDemangler, m_cxx_method_parser, m_ipd, m_ipd_buf, m_ipd_buf_size, m_provider, None, PluginCxxLanguage, and processIPDStrResult().

Referenced by lldb_private::Symtab::RegisterMangledNameEntry().

◆ ParseFunctionDeclContextName()

llvm::StringRef RichManglingContext::ParseFunctionDeclContextName ( )

Get the context name for a function.

For "a::b::c", this function returns "a::b".

Definition at line 129 of file RichManglingContext.cpp.

References ItaniumPartialDemangler, m_cxx_method_parser, m_ipd, m_ipd_buf, m_ipd_buf_size, m_provider, None, PluginCxxLanguage, and processIPDStrResult().

Referenced by lldb_private::Symtab::RegisterMangledNameEntry().

◆ processIPDStrResult()

llvm::StringRef RichManglingContext::processIPDStrResult ( char *  ipd_res,
size_t  res_len 
)
private

Uniform handling of string buffers for ItaniumPartialDemangler.

Definition at line 83 of file RichManglingContext.cpp.

References lldb_private::Demangle, lldb_private::GetLog(), LLDB_LOG, m_ipd_buf, and m_ipd_buf_size.

Referenced by ParseFullName(), ParseFunctionBaseName(), and ParseFunctionDeclContextName().

◆ ResetCxxMethodParser()

void RichManglingContext::ResetCxxMethodParser ( )
private

Clean up memory when using PluginCxxLanguage.

Definition at line 24 of file RichManglingContext.cpp.

References m_cxx_method_parser, m_provider, and PluginCxxLanguage.

Referenced by ResetProvider(), and ~RichManglingContext().

◆ ResetProvider()

void RichManglingContext::ResetProvider ( InfoProvider  new_provider)
private

Clean up memory and set a new info provider for this instance.

Definition at line 34 of file RichManglingContext.cpp.

References m_provider, None, and ResetCxxMethodParser().

Referenced by FromCxxMethodName(), and FromItaniumName().

Member Data Documentation

◆ m_cxx_method_parser

llvm::Any lldb_private::RichManglingContext::m_cxx_method_parser
private

Members for PluginCxxLanguage Cannot forward declare inner class CPlusPlusLanguage::MethodName.

The respective header is in Plugins and including it from here causes cyclic dependency. Instead keep a llvm::Any and cast it on-access in the cpp.

Definition at line 74 of file RichManglingContext.h.

Referenced by FromCxxMethodName(), IsCtorOrDtor(), ParseFullName(), ParseFunctionBaseName(), ParseFunctionDeclContextName(), and ResetCxxMethodParser().

◆ m_ipd

llvm::ItaniumPartialDemangler lldb_private::RichManglingContext::m_ipd
private

Members for ItaniumPartialDemangler.

Definition at line 63 of file RichManglingContext.h.

Referenced by FromItaniumName(), IsCtorOrDtor(), ParseFullName(), ParseFunctionBaseName(), and ParseFunctionDeclContextName().

◆ m_ipd_buf

char* lldb_private::RichManglingContext::m_ipd_buf
private

Note: m_ipd_buf is a raw pointer due to being resized by realloc via ItaniumPartialDemangler.

It should be managed with malloc/free, not new/delete.

Definition at line 67 of file RichManglingContext.h.

Referenced by FromItaniumName(), ParseFullName(), ParseFunctionBaseName(), ParseFunctionDeclContextName(), processIPDStrResult(), RichManglingContext(), and ~RichManglingContext().

◆ m_ipd_buf_size

size_t lldb_private::RichManglingContext::m_ipd_buf_size = 2048
private

◆ m_provider

InfoProvider lldb_private::RichManglingContext::m_provider = None
private

Selects the rich mangling info provider.

Definition at line 60 of file RichManglingContext.h.

Referenced by IsCtorOrDtor(), ParseFullName(), ParseFunctionBaseName(), ParseFunctionDeclContextName(), ResetCxxMethodParser(), and ResetProvider().


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