asmith created this revision.
asmith added reviewers: aleksandr.urakov, zturner, lldb-commits.
Herald added a subscriber: erik.pilkington.

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.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52626

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


Index: unittests/Core/RichManglingContextTest.cpp
===================================================================
--- unittests/Core/RichManglingContextTest.cpp
+++ unittests/Core/RichManglingContextTest.cpp
@@ -57,6 +57,29 @@
   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) {
Index: include/lldb/Core/RichManglingContext.h
===================================================================
--- include/lldb/Core/RichManglingContext.h
+++ include/lldb/Core/RichManglingContext.h
@@ -64,7 +64,6 @@
   /// 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: unittests/Core/RichManglingContextTest.cpp
===================================================================
--- unittests/Core/RichManglingContextTest.cpp
+++ unittests/Core/RichManglingContextTest.cpp
@@ -57,6 +57,29 @@
   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) {
Index: include/lldb/Core/RichManglingContext.h
===================================================================
--- include/lldb/Core/RichManglingContext.h
+++ include/lldb/Core/RichManglingContext.h
@@ -64,7 +64,6 @@
   /// 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;
   }
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
  • [Lldb-commits] [PATCH] D52... Aaron Smith via Phabricator via lldb-commits

Reply via email to