diff options
Diffstat (limited to 'lldb/include/lldb/Core/RichManglingContext.h')
-rw-r--r-- | lldb/include/lldb/Core/RichManglingContext.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lldb/include/lldb/Core/RichManglingContext.h b/lldb/include/lldb/Core/RichManglingContext.h index 68f80e73b724..48102ec0b1cf 100644 --- a/lldb/include/lldb/Core/RichManglingContext.h +++ b/lldb/include/lldb/Core/RichManglingContext.h @@ -24,12 +24,12 @@ namespace lldb_private { /// providers. See Mangled::DemangleWithRichManglingInfo() class RichManglingContext { public: - RichManglingContext() : m_provider(None), m_ipd_buf_size(2048) { + RichManglingContext() { m_ipd_buf = static_cast<char *>(std::malloc(m_ipd_buf_size)); m_ipd_buf[0] = '\0'; } - ~RichManglingContext() { std::free(m_ipd_buf); } + ~RichManglingContext(); /// Use the ItaniumPartialDemangler to obtain rich mangling information from /// the given mangled name. @@ -70,15 +70,18 @@ private: enum InfoProvider { None, ItaniumPartialDemangler, PluginCxxLanguage }; /// Selects the rich mangling info provider. - InfoProvider m_provider; + InfoProvider m_provider = None; /// Reference to the buffer used for results of ParseXy() operations. llvm::StringRef m_buffer; /// Members for ItaniumPartialDemangler llvm::ItaniumPartialDemangler m_ipd; + /// 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. char *m_ipd_buf; - size_t m_ipd_buf_size; + size_t m_ipd_buf_size = 2048; /// Members for PluginCxxLanguage /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The @@ -86,6 +89,9 @@ private: /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp. llvm::Any m_cxx_method_parser; + /// Clean up memory when using PluginCxxLanguage + void ResetCxxMethodParser(); + /// Clean up memory and set a new info provider for this instance. void ResetProvider(InfoProvider new_provider); |