[clang-tools-extra] [clang-tidy] Reject malformed -std spellings in `check_clang_tidy.py`. NFC. (PR #195609)

via cfe-commits cfe-commits at lists.llvm.org
Mon May 4 01:28:59 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tidy

Author: Zeyi Xu (zeyi2)

<details>
<summary>Changes</summary>

`check_clang_tidy.py` expanded any `-std` value containing `-or-later`, even when extra text followed the suffix. e.g. `c++20-or-latermisc` was treated like `c++20-or-later`.

This commit requires `-or-later` to be the actual end of the spelling before expanding it, so malformed values are passed through and diagnosed by clang.

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


1 Files Affected:

- (modified) clang-tools-extra/test/clang-tidy/check_clang_tidy.py (+4-1) 


``````````diff
diff --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
index 71c072e62e3f2..f932b77ecaba3 100755
--- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -460,11 +460,14 @@ def run(self) -> None:
 
 
 def expand_std(std: str) -> List[str]:
-    split_std, or_later, _ = std.partition("-or-later")
+    split_std, or_later, suffix = std.partition("-or-later")
 
     if not or_later:
         return [split_std]
 
+    if suffix:
+        return [std]
+
     for standard_list in (CPP_STANDARDS, C_STANDARDS):
         item = next(
             (

``````````

</details>


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


More information about the cfe-commits mailing list