hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

- fixes error: Line: 91  result += contents[pos:m.start(index)] TypeError: can 
only concatenate str (not "bytes") to str
- fixes the "-code-completion-at=%s:%(lineb'-7')" rewritten results


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140300

Files:
  llvm/utils/relative_lines.py


Index: llvm/utils/relative_lines.py
===================================================================
--- llvm/utils/relative_lines.py
+++ llvm/utils/relative_lines.py
@@ -68,23 +68,23 @@
             print(f"{file}:{line}: target line {target} is farther than 
{args.near}", file=sys.stderr)
             return capture
         if target > line:
-            delta = b('+' + str(target - line))
+            delta = '+' + str(target - line)
         elif target < line:
-            delta = b('-' + str(line - target))
+            delta = '-' + str(line - target)
         else:
-            delta = b''
+            delta = ''
 
         prefix = contents[:offset].rsplit(b'\n')[-1]
         is_lit = b'RUN' in prefix or b'DEFINE' in prefix
-        text = b(('%(line{0})' if is_lit else '[[@LINE{0}]]').format(delta))
+        text = ('%(line{0})' if is_lit else '[[@LINE{0}]]').format(delta)
         if args.verbose:
             print(f"{file}:{line}: {0} ==> {text}")
-        return text
+        return b(text)
 
     def replace_match(m):
         """Text to replace a whole match, e.g. --at=42:3 => --at=%(line+2):3"""
         line = 1 + contents[:m.start()].count(b'\n')
-        result = ''
+        result = b''
         pos = m.start()
         for index, capture in enumerate(m.groups()):
             index += 1 # re groups are conventionally 1-indexed


Index: llvm/utils/relative_lines.py
===================================================================
--- llvm/utils/relative_lines.py
+++ llvm/utils/relative_lines.py
@@ -68,23 +68,23 @@
             print(f"{file}:{line}: target line {target} is farther than {args.near}", file=sys.stderr)
             return capture
         if target > line:
-            delta = b('+' + str(target - line))
+            delta = '+' + str(target - line)
         elif target < line:
-            delta = b('-' + str(line - target))
+            delta = '-' + str(line - target)
         else:
-            delta = b''
+            delta = ''
 
         prefix = contents[:offset].rsplit(b'\n')[-1]
         is_lit = b'RUN' in prefix or b'DEFINE' in prefix
-        text = b(('%(line{0})' if is_lit else '[[@LINE{0}]]').format(delta))
+        text = ('%(line{0})' if is_lit else '[[@LINE{0}]]').format(delta)
         if args.verbose:
             print(f"{file}:{line}: {0} ==> {text}")
-        return text
+        return b(text)
 
     def replace_match(m):
         """Text to replace a whole match, e.g. --at=42:3 => --at=%(line+2):3"""
         line = 1 + contents[:m.start()].count(b'\n')
-        result = ''
+        result = b''
         pos = m.start()
         for index, capture in enumerate(m.groups()):
             index += 1 # re groups are conventionally 1-indexed
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to