[Lldb-commits] [lldb] ef7adbe - Reland "[lldb][TypeSystemClang] Format pointers to member functions as eFormatHex"

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 7 11:46:12 PST 2023


Author: Michael Buch
Date: 2023-03-07T19:45:49Z
New Revision: ef7adbe2b7bcdb1fca88f77a7d4da2a8dea63699

URL: https://github.com/llvm/llvm-project/commit/ef7adbe2b7bcdb1fca88f77a7d4da2a8dea63699
DIFF: https://github.com/llvm/llvm-project/commit/ef7adbe2b7bcdb1fca88f77a7d4da2a8dea63699.diff

LOG: Reland "[lldb][TypeSystemClang] Format pointers to member functions as eFormatHex"

Before this patch, LLDB used to format pointers to members, such as,
```
void (Foo::*pointer_to_member_func)() = &Foo::member_func;
```
as `eFormatBytes`. E.g.,
```
(lldb) v pointer_to_member_func
(void (Foo::*)()) $1 = 94 3f 00 00 01 00 00 00 00 00 00 00 00 00 00 00
```

This patch makes sure we format pointers to member functions the same
way we do regular function pointers.

After this patch we format member pointers as:
```
(lldb) v pointer_to_member_func
(void (Foo::*)()) ::pointer_to_member_func = 0x00000000000000000000000100003f94
```

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

Added: 
    

Modified: 
    lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
    lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
    lldb/test/Shell/SymbolFile/NativePDB/ast-types.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 4a2ab70c90da4..fa1984b50a586 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5277,7 +5277,7 @@ lldb::Format TypeSystemClang::GetFormat(lldb::opaque_compiler_type_t type) {
   case clang::Type::RValueReference:
     return lldb::eFormatHex;
   case clang::Type::MemberPointer:
-    break;
+    return lldb::eFormatHex;
   case clang::Type::Complex: {
     if (qual_type->isComplexType())
       return lldb::eFormatComplex;

diff  --git a/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py b/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
index ee9057ba715db..84d4a4c0ae5a8 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
@@ -294,13 +294,13 @@ def test_mem_func_ptr_formats(self):
         # FIXME: don't format pointer to members as bytes, but rather as regular pointers
         self.expect(
             "frame variable member_ptr",
-            patterns=['member_ptr = [0-9a-z]{2}\s'])
+            patterns=['member_ptr = 0x[0-9a-z]+'])
         self.expect(
             "frame variable member_func_ptr",
-            patterns=['member_func_ptr = [0-9a-z]{2}\s'])
+            patterns=['member_func_ptr = 0x[0-9a-z]+'])
         self.expect(
             "frame variable ref_to_member_func_ptr",
-            patterns=['ref_to_member_func_ptr = [0-9a-z]{2}\s'])
+            patterns=['ref_to_member_func_ptr = 0x[0-9a-z]+'])
         self.expect(
             "frame variable virt_member_func_ptr",
-            patterns=['virt_member_func_ptr = [0-9a-z]{2}\s'])
+            patterns=['virt_member_func_ptr = 0x[0-9a-z]+'])

diff  --git a/lldb/test/Shell/SymbolFile/NativePDB/ast-types.cpp b/lldb/test/Shell/SymbolFile/NativePDB/ast-types.cpp
index a210ce0451047..5554881716184 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/ast-types.cpp
+++ b/lldb/test/Shell/SymbolFile/NativePDB/ast-types.cpp
@@ -131,15 +131,15 @@ int SI::*mp9 = nullptr;
 // CHECK: (Anonymous<int>) AnonInt = (AnonymousMember = 0)
 // CHECK: (Anonymous<A::B::C<void>>) AnonABCVoid = (AnonymousMember = 0)
 // CHECK: (Anonymous<A::B::C<void>>::D) AnonABCVoidD = (AnonymousDMember = 0)
-// CHECK: (void (SI::*)()) mp1 = 00 00 00 00 00 00 00 00
-// CHECK: (void (MI::*)()) mp2 = 00 00 00 00 00 00 00 00
-// CHECK: (void (MI2::*)()) mp3 = 00 00 00 00 00 00 00 00
-// CHECK: (void (VI::*)()) mp4 = 00 00 00 00 00 00 00 00
-// CHECK: (void (VI2::*)()) mp5 = 00 00 00 00 00 00 00 00
-// CHECK: (void (UI::*)()) mp6 = 00 00 00 00 00 00 00 00
+// CHECK: (void (SI::*)()) mp1 = 0x0000000000000000
+// CHECK: (void (MI::*)()) mp2 = 0x0000000000000000
+// CHECK: (void (MI2::*)()) mp3 = 0x0000000000000000
+// CHECK: (void (VI::*)()) mp4 = 0x0000000000000000
+// CHECK: (void (VI2::*)()) mp5 = 0x0000000000000000
+// CHECK: (void (UI::*)()) mp6 = 0x0000000000000000
 // CHECK: (void (MI::**)()) mp7 = 0x0000000000000000
 // CHECK: (void (VI2::**)()) mp8 = 0x0000000000000000
-// CHECK: (int SI::*) mp9 = ff ff ff ff
+// CHECK: (int SI::*) mp9 = 0xffffffff
 // CHECK: Dumping clang ast for 1 modules.
 // CHECK: TranslationUnitDecl {{.*}}
 // CHECK: |-CXXRecordDecl {{.*}} class TrivialC definition


        


More information about the lldb-commits mailing list