[llvm] [clang] Include LLVM_VERSION_SUFFIX in the Clang version string. (PR #74469)

via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 5 05:50:34 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: James Y Knight (jyknight)

<details>
<summary>Changes</summary>

This causes current mainline to now report "18.0.0git" instead of "18.0.0".

Fixes #<!-- -->53825

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


3 Files Affected:

- (modified) clang/CMakeLists.txt (+4-2) 
- (modified) clang/test/Frontend/sarif-diagnostics.cpp (+2-2) 
- (modified) llvm/utils/UpdateTestChecks/common.py (+1-1) 


``````````diff
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 9b52c58be41e7..65ed790e69c2a 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -290,8 +290,10 @@ endif()
 if(NOT DEFINED CLANG_VERSION_PATCHLEVEL)
   set(CLANG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH})
 endif()
-# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX.
-set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}")
+if(NOT DEFINED CLANG_VERSION_SUFFIX)
+  set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
+endif()
+set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${LLVM_VERSION_SUFFIX}")
 message(STATUS "Clang version: ${CLANG_VERSION}")
 
 # Configure the Version.inc file.
diff --git a/clang/test/Frontend/sarif-diagnostics.cpp b/clang/test/Frontend/sarif-diagnostics.cpp
index 9a4e686389a2e..767c5802ca13d 100644
--- a/clang/test/Frontend/sarif-diagnostics.cpp
+++ b/clang/test/Frontend/sarif-diagnostics.cpp
@@ -64,5 +64,5 @@ void f1(t1 x, t1 y) {
 // CHECK: {"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"{{[0-9]+}}","name":""},{"defaultConfiguration":
 // CHECK: {"enabled":true,"level":"error","rank":50},"fullDescription":{"text":""},"id":"{{[0-9]+}}","name":""},{"defaultConfiguration":
 // CHECK: {"enabled":true,"level":"error","rank":50},"fullDescription":
-// CHECK: {"text":""},"id":"{{[0-9]+}}","name":""}],"version":"{{[0-9]+\.[0-9]+\.[0-9]+}}"}}}],"version":"2.1.0"}
-// CHECK: 2 warnings and 6 errors generated.
\ No newline at end of file
+// CHECK: {"text":""},"id":"{{[0-9]+}}","name":""}],"version":"{{[0-9]+\.[0-9]+\.[0-9]+[^" ]*}}"}}}],"version":"2.1.0"}
+// CHECK: 2 warnings and 6 errors generated.
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 5c3775e3d0859..0fe0dfc506b05 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -1701,7 +1701,7 @@ def add(var):
 
 METADATA_FILTERS = [
     (
-        r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?: \([^)]+\))?",
+        r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?:[^\" ]*)(?: \([^)]+\))?",
         r"{{.*}}\2{{.*}}",
     ),  # preface with glob also, to capture optional CLANG_VENDOR
     (r'(!DIFile\(filename: ".+", directory: )".+"', r"\1{{.*}}"),

``````````

</details>


https://github.com/llvm/llvm-project/pull/74469


More information about the cfe-commits mailing list