[lldb] Remove an assertion in RichManglingContext::GetBufferRef() hit when debugging...
authorAaron Smith <aaron.smith@microsoft.com>
Fri, 28 Sep 2018 02:33:51 +0000 (02:33 +0000)
committerAaron Smith <aaron.smith@microsoft.com>
Fri, 28 Sep 2018 02:33:51 +0000 (02:33 +0000)
Summary: A RichManglingContext constructed with an invalid demangled name or with a demangled function name without any context will have an empty context. This triggers an assertion in RichManglingContext::GetBufferRef() when debugging a native Windows process on x86 when it shouldn't. Remove the assertion.

Reviewers: aleksandr.urakov, zturner, lldb-commits

Reviewed By: zturner

Subscribers: erik.pilkington

Differential Revision: https://reviews.llvm.org/D52626

llvm-svn: 343292

lldb/include/lldb/Core/RichManglingContext.h
lldb/unittests/Core/RichManglingContextTest.cpp

index 393305c..30841bf 100644 (file)
@@ -64,7 +64,6 @@ public:
   /// most recent ParseXy() operation. The next ParseXy() call invalidates it.
   llvm::StringRef GetBufferRef() const {
     assert(m_provider != None && "Initialize a provider first");
-    assert(m_buffer.data() != nullptr && "Parse first");
     return m_buffer;
   }
 
index 19329ac..3bb0aae 100644 (file)
@@ -57,6 +57,29 @@ TEST(RichManglingContextTest, FromCxxMethodName) {
   ItaniumRMC.ParseFullName();
   CxxMethodRMC.ParseFullName();
   EXPECT_TRUE(ItaniumRMC.GetBufferRef() == CxxMethodRMC.GetBufferRef());
+
+  // Construct with a random name.
+  {
+    RichManglingContext CxxMethodRMC;
+    EXPECT_TRUE(CxxMethodRMC.FromCxxMethodName(ConstString("X")));
+
+    // We expect it is not a function.
+    EXPECT_FALSE(CxxMethodRMC.IsFunction());
+  }
+
+  // Construct with a function without a context.
+  {
+    RichManglingContext CxxMethodRMC;
+    EXPECT_TRUE(CxxMethodRMC.FromCxxMethodName(
+        ConstString("void * operator new(unsigned __int64)")));
+
+    // We expect it is a function.
+    EXPECT_TRUE(CxxMethodRMC.IsFunction());
+
+    // We expect its context is empty.
+    CxxMethodRMC.ParseFunctionDeclContextName();
+    EXPECT_TRUE(CxxMethodRMC.GetBufferRef().empty());
+  }
 }
 
 TEST(RichManglingContextTest, SwitchProvider) {