[llvm] [utils] Fix llvm/utils/demangle_tree.py:parse_line to correctly check… (PR #142153)

via llvm-commits llvm-commits at lists.llvm.org
Fri May 30 07:12:38 PDT 2025


https://github.com/sivan-shani created https://github.com/llvm/llvm-project/pull/142153

… for closing parenthesis

Previously, parse_line incorrectly repeated the check for open_paren instead of verifying the presence of a closing parenthesis. This caused inputs with an unmatched opening parenthesis to be parsed incorrectly.

For example:
    print(parse_line('?foo (bar'))
    → before: ('?foo', 'ba')   [incorrect]
    → after:  (None, None)     [correct]

Fixed the condition to properly check close_paren.

>From 15503b9d866ff864f4d3296f72499508ead59429 Mon Sep 17 00:00:00 2001
From: Sivan Shani <sivan.shani at arm.com>
Date: Fri, 30 May 2025 15:06:39 +0100
Subject: [PATCH] [utils] Fix llvm/utils/demangle_tree.py:parse_line to
 correctly check for closing parenthesis
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Previously, parse_line incorrectly repeated the check for open_paren
instead of verifying the presence of a closing parenthesis. This caused
inputs with an unmatched opening parenthesis to be parsed incorrectly.

For example:
    print(parse_line('?foo (bar'))
    → before: ('?foo', 'ba')   [incorrect]
    → after:  (None, None)     [correct]

Fixed the condition to properly check close_paren.
---
 llvm/utils/demangle_tree.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/utils/demangle_tree.py b/llvm/utils/demangle_tree.py
index 9d9603e63b832..6fbb8c6a36ca3 100644
--- a/llvm/utils/demangle_tree.py
+++ b/llvm/utils/demangle_tree.py
@@ -28,7 +28,7 @@ def parse_line(line):
     if open_paren == -1:
         return None, None
     close_paren = line.rfind(")", open_paren)
-    if open_paren == -1:
+    if close_paren == -1:
         return None, None
     mangled = line[question:open_paren]
     demangled = line[open_paren + 1 : close_paren]



More information about the llvm-commits mailing list