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, 875391728c11339c8a6cd3338bcaa5ec0ffc2496.
This commit is contained in:
David Blaikie 2024-06-07 21:05:42 +00:00
parent 3c8f3b91d8
commit 1c9a81b2bd
3 changed files with 6 additions and 11 deletions

View File

@ -19,8 +19,6 @@ llvm::DenseMap<int, int> DenseMap = {{4, 5}, {6, 7}};
llvm::StringMap<int> StringMap = {{"foo", 123}, {"bar", 456}};
llvm::Expected<int> ExpectedValue(8);
llvm::Expected<int> ExpectedError(llvm::createStringError(""));
std::optional<int> OptionalValue(9);
std::optional<int> OptionalNone(std::nullopt);
llvm::SmallVector<int, 5> SmallVector = {10, 11, 12};
llvm::SmallString<5> SmallString("foo");
llvm::StringRef StringRef = "bar";
@ -69,7 +67,5 @@ int main() {
dont_strip(MutableArrayRef);
dont_strip(ExpectedValue);
dont_strip(ExpectedError);
dont_strip(OptionalValue);
dont_strip(OptionalNone);
return result; // Non-zero return value is OK.
}

View File

@ -22,12 +22,6 @@ p ExpectedValue
# CHECK: llvm::Expected is error
p ExpectedError
# CHECK: llvm::Optional = {value = 9}
p OptionalValue
# CHECK: llvm::Optional is not initialized
p OptionalNone
# CHECK: llvm::SmallVector of Size 3, Capacity 5 = {10, 11, 12}
p SmallVector
@ -37,7 +31,7 @@ p SmallString
# CHECK: "bar"
p StringRef
# CHECK: "foobarbaz"
# CHECK: "{{foo|\(missing .*\)}}barbaz"
p Twine
# CHECK: llvm::StringMap with 2 elements = {["foo"] = 123, ["bar"] = 456}

View File

@ -415,7 +415,12 @@ def get_pointer_int_pair(val):
int_shift = enum_dict[info_name + "::IntShift"]
int_mask = enum_dict[info_name + "::IntMask"]
pair_union = val["Value"]
value_type = pair_union.type.template_argument(0)
value_type_ptr = value_type.pointer()
pair_union = pair_union.address.cast(value_type_ptr).dereference()
pair_union = pair_union.cast(gdb.lookup_type("intptr_t"))
pointer = pair_union & ptr_mask
pointer = pointer.cast(value_type)
value = (pair_union >> int_shift) & int_mask
return (pointer, value)