[DataFormatters] Adjusting libc++ std::list formatter to act better with pointers...
authorShafik Yaghmour <syaghmour@apple.com>
Wed, 24 Apr 2019 17:38:40 +0000 (17:38 +0000)
committerShafik Yaghmour <syaghmour@apple.com>
Wed, 24 Apr 2019 17:38:40 +0000 (17:38 +0000)
Summary:
This previous fix https://github.com/llvm-mirror/lldb/commit/5469bda296c183d1b6bf74597c88c9ed667b3145 did not have a test since we did not have a reproducer.

This is related to how formatters deal with pointers and references. The added tests both the new behavior and covers the previous bug fix as well.

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

llvm-svn: 359118

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

index 86248d1..957f2bf 100644 (file)
@@ -162,6 +162,10 @@ class LibcxxListDataFormatterTestCase(TestBase):
                              '[2] = ', '3',
                              '[3] = ', '4'])
 
+        ListPtr = self.frame().FindVariable("list_ptr")
+        self.assertTrue(ListPtr.GetChildAtIndex(
+            0).GetValueAsUnsigned(0) == 1, "[0] = 1")
+
         # check that MightHaveChildren() gets it right
         self.assertTrue(
             self.frame().FindVariable("numbers_list").MightHaveChildren(),
index 5637587..a3ef06b 100644 (file)
@@ -8,7 +8,8 @@ typedef std::list<std::string> string_list;
 int main()
 {
     int_list numbers_list;
-    
+    std::list<int>* list_ptr = &numbers_list;
+
     printf("// Set break point at this line.");
     (numbers_list.push_back(0x12345678));
     (numbers_list.push_back(0x11223344));
index d7232bd..c2a09cb 100644 (file)
@@ -486,7 +486,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
       cpp_category_sp,
       lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator,
       "libc++ std::list synthetic children",
-      ConstString("^std::__[[:alnum:]]+::list<.+>(( )?&)?$"), stl_synth_flags,
+      ConstString("^std::__[[:alnum:]]+::list<.+>(( )?&)?$"), stl_deref_flags,
       true);
   AddCXXSynthetic(
       cpp_category_sp,