[llvm] Fix regular expression to guard against a repeating version string (PR #84575)

Wolfgang Pieb via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 8 14:16:46 PST 2024


https://github.com/wolfy1961 created https://github.com/llvm/llvm-project/pull/84575

A recent change [d6c2cbbc651](https://github.sie.sony.com/SIE-Private/cpu-toolchain-ppr/commit/d6c2cbbc6513bd412b34f3bf70e21b5a363b2fd9) causes the test `clang/test/utils/update_cc_test_checks/generated-funcs.test` to fail for compilers with version strings that repeat the sequence "version", such as `clang version 19.0.0 (myvendor clang version 4.0.0)`.

Making the expression preceding "\w+ version" non-greedy fix this.

Unfortunately there is no simple way to generate a test case, since it would require a change in the clang version string.

>From d5de1b45038ab646c1cb5a0b7ed8645be362c9a7 Mon Sep 17 00:00:00 2001
From: wpieb <Wolfgang.Pieb at sony.com>
Date: Fri, 8 Mar 2024 13:44:47 -0800
Subject: [PATCH] Fix regular expression to guard against a repeating version
 string

---
 llvm/utils/UpdateTestChecks/common.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index ecb19d233a8d1a..85b4bdd2c6dc7a 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -2189,7 +2189,7 @@ def add(var):
 
 METADATA_FILTERS = [
     (
-        r"(?<=\")(.+ )?(\w+ version )[\d.]+(?:[^\" ]*)(?: \([^)]+\))?",
+        r"(?<=\")(.+ )??(\w+ version )[\d.]+(?:[^\" ]*)(?: \([^)]+\))?",
         r"{{.*}}\2{{.*}}",
     ),  # preface with glob also, to capture optional CLANG_VENDOR
     (r'(!DIFile\(filename: ".+", directory: )".+"', r"\1{{.*}}"),



More information about the llvm-commits mailing list