Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regular expression to guard against a repeating version string #84575

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wolfy1961
Copy link
Collaborator

A recent change d6c2cbbc651 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.

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 8, 2024

@llvm/pr-subscribers-testing-tools

Author: Wolfgang Pieb (wolfy1961)

Changes

A recent change d6c2cbbc651 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.


Full diff: https://github.com/llvm/llvm-project/pull/84575.diff

1 Files Affected:

  • (modified) llvm/utils/UpdateTestChecks/common.py (+1-1)
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{{.*}}"),

@arichardson
Copy link
Member

Would it be possible to write a LLVM IR test for update_test_checks.py with pre-existing metadata? Or do we only scrub it for update_cc_test_checks.py?

@wolfy1961
Copy link
Collaborator Author

Sorry for the long delay.
I added a test for the currently failing case to demonstrate the fix. It was easier than I thought.

@wolfy1961
Copy link
Collaborator Author

Rebased.

Ping ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants