@@ -16,18 +16,19 @@ def next(self):
16
16
def children (self ):
17
17
return self
18
18
19
- def escape_bytes (val , l ):
20
- return '"' + val .string (encoding = 'Latin-1' , length = l ).encode ('unicode_escape' ).decode () + '"'
21
-
22
19
class SmallStringPrinter :
23
20
"""Print an llvm::SmallString object."""
24
21
25
22
def __init__ (self , val ):
26
23
self .val = val
27
24
28
25
def to_string (self ):
29
- begin = self .val ['BeginX' ]
30
- return escape_bytes (begin .cast (gdb .lookup_type ('char' ).pointer ()), self .val ['Size' ])
26
+ data = self .val ['BeginX' ].cast (gdb .lookup_type ('char' ).pointer ())
27
+ length = self .val ['Size' ]
28
+ return data .lazy_string (length = length )
29
+
30
+ def display_hint (self ):
31
+ return 'string'
31
32
32
33
class StringRefPrinter :
33
34
"""Print an llvm::StringRef object."""
@@ -36,7 +37,12 @@ def __init__(self, val):
36
37
self .val = val
37
38
38
39
def to_string (self ):
39
- return escape_bytes (self .val ['Data' ], self .val ['Length' ])
40
+ data = self .val ['Data' ]
41
+ length = self .val ['Length' ]
42
+ return data .lazy_string (length = length )
43
+
44
+ def display_hint (self ):
45
+ return 'string'
40
46
41
47
class SmallVectorPrinter (Iterator ):
42
48
"""Print an llvm::SmallVector object."""
@@ -300,12 +306,9 @@ def string_from_child(self, child, kind):
300
306
301
307
if self .is_twine_kind (kind , 'PtrAndLengthKind' ):
302
308
val = child ['ptrAndLength' ]
303
- return val ['ptr' ].string (encoding = 'Latin-1' , length = val ['length' ]).encode ('unicode_escape' ).decode ()
304
-
305
- if self .is_twine_kind (kind , 'SmallStringKind' ):
306
- val = child ['smallString' ].dereference ()
307
- pp = SmallStringPrinter (val )
308
- return pp .to_string ()
309
+ data = val ['ptr' ]
310
+ length = val ['length' ]
311
+ return data .string (length = length )
309
312
310
313
if self .is_twine_kind (kind , 'CharKind' ):
311
314
return chr (child ['character' ])
@@ -340,11 +343,9 @@ def string_from_child(self, child, kind):
340
343
def string_from_twine_object (self , twine ):
341
344
'''Return the string representation of the Twine object twine.'''
342
345
343
- lhs_str = ''
344
- rhs_str = ''
345
-
346
346
lhs = twine ['LHS' ]
347
347
rhs = twine ['RHS' ]
348
+
348
349
lhs_kind = str (twine ['LHSKind' ])
349
350
rhs_kind = str (twine ['RHSKind' ])
350
351
@@ -356,6 +357,9 @@ def string_from_twine_object(self, twine):
356
357
def to_string (self ):
357
358
return self .string_from_twine_object (self ._val )
358
359
360
+ def display_hint (self ):
361
+ return 'string'
362
+
359
363
def get_pointer_int_pair (val ):
360
364
"""Get tuple from llvm::PointerIntPair."""
361
365
info_name = val .type .template_argument (4 ).strip_typedefs ().name
0 commit comments