[llvm] [TOOLS][opt-viewer] fixed error for demangler_lock and string formatting (PR #102298)
Vyom Sharma via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 10 01:28:09 PDT 2024
https://github.com/vyom1611 updated https://github.com/llvm/llvm-project/pull/102298
>From 1014b9398d72634d2c7c8f891c2134f4ab21192b Mon Sep 17 00:00:00 2001
From: vyom1611 <sharm843 at umn.edu>
Date: Wed, 7 Aug 2024 15:44:13 +0530
Subject: [PATCH] [TOOLS][opt-viewer] fixed error for demangler_lock and string
formatting
---
llvm/tools/opt-viewer/opt-viewer.py | 2 +-
llvm/tools/opt-viewer/optrecord.py | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/llvm/tools/opt-viewer/opt-viewer.py b/llvm/tools/opt-viewer/opt-viewer.py
index c9c7db726f7652..2d32d66bbe3aee 100755
--- a/llvm/tools/opt-viewer/opt-viewer.py
+++ b/llvm/tools/opt-viewer/opt-viewer.py
@@ -135,7 +135,7 @@ def render_inline_remarks(self, r, line):
# Column is the number of characters *including* tabs, keep those and
# replace everything else with spaces.
indent = line[: max(r.Column, 1) - 1]
- indent = re.sub("\S", " ", indent)
+ indent = re.sub(r"\S", " ", indent)
# Create expanded message and link if we have a multiline message.
lines = r.message.split("\n")
diff --git a/llvm/tools/opt-viewer/optrecord.py b/llvm/tools/opt-viewer/optrecord.py
index 9e2fc7cb553b58..9b20562e803cb0 100644
--- a/llvm/tools/opt-viewer/optrecord.py
+++ b/llvm/tools/opt-viewer/optrecord.py
@@ -74,6 +74,8 @@ def set_demangler(cls, demangler):
@classmethod
def demangle(cls, name):
+ if cls.demangler_proc is None:
+ return name # Return the original name if demangler is not available
with cls.demangler_lock:
cls.demangler_proc.stdin.write((name + "\n").encode("utf-8"))
cls.demangler_proc.stdin.flush()
@@ -299,7 +301,7 @@ def get_remarks(input_file, filter_=None):
filter_e = re.compile(filter_)
for remark in docs:
remark.canonicalize()
- # Avoid remarks withoug debug location or if they are duplicated
+ # Avoid remarks without debug location or if they are duplicated
if not hasattr(remark, "DebugLoc") or remark.key in all_remarks:
continue
More information about the llvm-commits
mailing list