rupprecht created this revision.
rupprecht requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

`RichManglingContext::FromCxxMethodName` allocates a m_cxx_method_parser, but 
never deletes it.

This fixes a `-DLLVM_USE_SANITIZER=Leaks` failure.


Repository:
  rG LLVM Github Monorepo

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,6 +19,15 @@
 using namespace lldb_private;
 
 // RichManglingContext
+RichManglingContext::~RichManglingContext() {
+  std::free(m_ipd_buf);
+  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.
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.


Index: lldb/source/Core/RichManglingContext.cpp
===================================================================
--- lldb/source/Core/RichManglingContext.cpp
+++ lldb/source/Core/RichManglingContext.cpp
@@ -19,6 +19,15 @@
 using namespace lldb_private;
 
 // RichManglingContext
+RichManglingContext::~RichManglingContext() {
+  std::free(m_ipd_buf);
+  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.
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.
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to