rupprecht updated this revision to Diff 338665. rupprecht added a comment. - Refactor cleanup of m_cxx_method_parser
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100795/new/ https://reviews.llvm.org/D100795 Files: lldb/include/lldb/Core/RichManglingContext.h lldb/source/Core/RichManglingContext.cpp Index: lldb/source/Core/RichManglingContext.cpp =================================================================== --- lldb/source/Core/RichManglingContext.cpp +++ lldb/source/Core/RichManglingContext.cpp @@ -19,14 +19,23 @@ using namespace lldb_private; // RichManglingContext -void RichManglingContext::ResetProvider(InfoProvider new_provider) { - // If we want to support parsers for other languages some day, we need a - // switch here to delete the correct parser type. +RichManglingContext::~RichManglingContext() { + std::free(m_ipd_buf); + ResetCxxMethodParser(); +} + +void RichManglingContext::ResetCxxMethodParser() { if (m_cxx_method_parser.hasValue()) { assert(m_provider == PluginCxxLanguage); delete get<CPlusPlusLanguage::MethodName>(m_cxx_method_parser); m_cxx_method_parser.reset(); } +} + +void RichManglingContext::ResetProvider(InfoProvider new_provider) { + // If we want to support parsers for other languages some day, we need a + // switch here to delete the correct parser type. + ResetCxxMethodParser(); assert(new_provider != None && "Only reset to a valid provider"); m_provider = new_provider; Index: lldb/include/lldb/Core/RichManglingContext.h =================================================================== --- lldb/include/lldb/Core/RichManglingContext.h +++ lldb/include/lldb/Core/RichManglingContext.h @@ -29,7 +29,7 @@ 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. @@ -86,6 +86,9 @@ /// 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);
Index: lldb/source/Core/RichManglingContext.cpp =================================================================== --- lldb/source/Core/RichManglingContext.cpp +++ lldb/source/Core/RichManglingContext.cpp @@ -19,14 +19,23 @@ using namespace lldb_private; // RichManglingContext -void RichManglingContext::ResetProvider(InfoProvider new_provider) { - // If we want to support parsers for other languages some day, we need a - // switch here to delete the correct parser type. +RichManglingContext::~RichManglingContext() { + std::free(m_ipd_buf); + ResetCxxMethodParser(); +} + +void RichManglingContext::ResetCxxMethodParser() { if (m_cxx_method_parser.hasValue()) { assert(m_provider == PluginCxxLanguage); delete get<CPlusPlusLanguage::MethodName>(m_cxx_method_parser); m_cxx_method_parser.reset(); } +} + +void RichManglingContext::ResetProvider(InfoProvider new_provider) { + // If we want to support parsers for other languages some day, we need a + // switch here to delete the correct parser type. + ResetCxxMethodParser(); assert(new_provider != None && "Only reset to a valid provider"); m_provider = new_provider; Index: lldb/include/lldb/Core/RichManglingContext.h =================================================================== --- lldb/include/lldb/Core/RichManglingContext.h +++ lldb/include/lldb/Core/RichManglingContext.h @@ -29,7 +29,7 @@ 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. @@ -86,6 +86,9 @@ /// 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);
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits