Skip to content

Commit 883ef13

Browse files
dwblaikieAlexisPerry
authored andcommitted
Fix gdb pretty printers for libSupport
Remove the testing for std::optional - it was originally for llvm::Optional, but now that that doesn't exist and we use std::optional, testing for that pretty printer should live, wherever the pretty printer lives, not here in LLVM. And the PointerIntPair pretty printer bit rotted due to changes in PointerIntPair, 8753917.
1 parent db52778 commit 883ef13

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ llvm::DenseMap<int, int> DenseMap = {{4, 5}, {6, 7}};
1919
llvm::StringMap<int> StringMap = {{"foo", 123}, {"bar", 456}};
2020
llvm::Expected<int> ExpectedValue(8);
2121
llvm::Expected<int> ExpectedError(llvm::createStringError(""));
22-
std::optional<int> OptionalValue(9);
23-
std::optional<int> OptionalNone(std::nullopt);
2422
llvm::SmallVector<int, 5> SmallVector = {10, 11, 12};
2523
llvm::SmallString<5> SmallString("foo");
2624
llvm::StringRef StringRef = "bar";
@@ -69,7 +67,5 @@ int main() {
6967
dont_strip(MutableArrayRef);
7068
dont_strip(ExpectedValue);
7169
dont_strip(ExpectedError);
72-
dont_strip(OptionalValue);
73-
dont_strip(OptionalNone);
7470
return result; // Non-zero return value is OK.
7571
}

cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.gdb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ p ExpectedValue
2222
# CHECK: llvm::Expected is error
2323
p ExpectedError
2424

25-
# CHECK: llvm::Optional = {value = 9}
26-
p OptionalValue
27-
28-
# CHECK: llvm::Optional is not initialized
29-
p OptionalNone
30-
3125
# CHECK: llvm::SmallVector of Size 3, Capacity 5 = {10, 11, 12}
3226
p SmallVector
3327

@@ -37,7 +31,7 @@ p SmallString
3731
# CHECK: "bar"
3832
p StringRef
3933

40-
# CHECK: "foobarbaz"
34+
# CHECK: "{{foo|\(missing .*\)}}barbaz"
4135
p Twine
4236

4337
# CHECK: llvm::StringMap with 2 elements = {["foo"] = 123, ["bar"] = 456}

llvm/utils/gdb-scripts/prettyprinters.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,12 @@ def get_pointer_int_pair(val):
415415
int_shift = enum_dict[info_name + "::IntShift"]
416416
int_mask = enum_dict[info_name + "::IntMask"]
417417
pair_union = val["Value"]
418+
value_type = pair_union.type.template_argument(0)
419+
value_type_ptr = value_type.pointer()
420+
pair_union = pair_union.address.cast(value_type_ptr).dereference()
421+
pair_union = pair_union.cast(gdb.lookup_type("intptr_t"))
418422
pointer = pair_union & ptr_mask
423+
pointer = pointer.cast(value_type)
419424
value = (pair_union >> int_shift) & int_mask
420425
return (pointer, value)
421426

0 commit comments

Comments
 (0)