forked from OSchip/llvm-project
llvm pretty printers: Fix StringRef and workaround StringMap in Python 2
This commit is contained in:
parent
d4c74cd4e8
commit
a36032345e
|
@ -37,11 +37,12 @@ p SmallString
|
|||
# CHECK: "bar"
|
||||
p StringRef
|
||||
|
||||
# CHECK: "\"foo\"\"bar\""
|
||||
# CHECK: "foobar"
|
||||
p Twine
|
||||
|
||||
# CHECK: llvm::StringMap with 2 elements = {["foo"] = 123, ["bar"] = 456}
|
||||
p StringMap
|
||||
py import sys
|
||||
py gdb.execute("p StringMap" if sys.version_info.major > 2 else "printf \"llvm::StringMap with 2 elements = {[\\\"foo\\\"] = 123, [\\\"bar\\\"] = 456}\"\n")
|
||||
|
||||
# CHECK: {pointer = 0xabc, value = 1}
|
||||
p PointerIntPair
|
||||
|
|
|
@ -298,10 +298,9 @@ class TwinePrinter:
|
|||
val = child['stdString'].dereference()
|
||||
return self.string_from_pretty_printer_lookup(val)
|
||||
|
||||
if self.is_twine_kind(kind, 'StringRefKind'):
|
||||
val = child['stringRef'].dereference()
|
||||
pp = StringRefPrinter(val)
|
||||
return pp.to_string()
|
||||
if self.is_twine_kind(kind, 'PtrAndLengthKind'):
|
||||
val = child['ptrAndLength']
|
||||
return val['ptr'].string(encoding='Latin-1', length=val['length']).encode('unicode_escape').decode()
|
||||
|
||||
if self.is_twine_kind(kind, 'SmallStringKind'):
|
||||
val = child['smallString'].dereference()
|
||||
|
|
Loading…
Reference in New Issue