diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index 3b891cecb1c8b..e53685ac511b6 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -222,8 +222,9 @@ void FormatManager::GetPossibleMatches( if (compiler_type.IsPointerType()) { CompilerType non_ptr_type = compiler_type.GetPointeeType(); - GetPossibleMatches(valobj, non_ptr_type, use_dynamic, entries, - current_flags.WithStrippedPointer()); + if (!current_flags.stripped_pointer) + GetPossibleMatches(valobj, non_ptr_type, use_dynamic, entries, + current_flags.WithStrippedPointer(), false); if (non_ptr_type.IsTypedefType()) { CompilerType deffed_pointed_type = non_ptr_type.GetTypedefedType().GetPointerType(); diff --git a/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py b/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py index f70162bf28583..fea40252a2a75 100644 --- a/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py +++ b/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/TestPtrRef2Typedef.py @@ -53,3 +53,15 @@ def cleanup(): # the match. self.expect("frame variable y", substrs=["(Foo &", ") y = 0x", "IntLRef"]) self.expect("frame variable z", substrs=["(Foo &&", ") z = 0x", "IntRRef"]) + + # Test lldb doesn't dereference pointer more than once. + # xp has type Foo**, so it can only uses summary for Foo* or int*, not + # summary for Foo or int. + self.expect("frame variable xp", substrs=["(Foo **) xp = 0x", "IntPointer"]) + + self.runCmd('type summary delete "int *"') + self.runCmd('type summary add --cascade true -s "MyInt" "int"') + self.expect("frame variable xp", substrs=["(Foo **) xp = 0x"]) + + self.runCmd('type summary add --cascade true -s "FooPointer" "Foo *"') + self.expect("frame variable xp", substrs=["(Foo **) xp = 0x", "FooPointer"]) diff --git a/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/main.cpp b/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/main.cpp index 1310210655108..a2f235a48dc44 100644 --- a/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/ptr_ref_typedef/main.cpp @@ -1,10 +1,12 @@ typedef int Foo; int main() { - int lval = 1; - Foo* x = &lval; - Foo& y = lval; - Foo&& z = 1; - return 0; // Set breakpoint here -} + int lval = 1; + Foo *x = &lval; + Foo &y = lval; + Foo &&z = 1; + // Test lldb doesn't dereference pointer more than once. + Foo **xp = &x; + return 0; // Set breakpoint here +}