[clang-tools-extra] [clang-tidy] Reject malformed -std spellings in `check_clang_tidy.py`. NFC. (PR #195609)
Zeyi Xu via cfe-commits
cfe-commits at lists.llvm.org
Mon May 4 01:53:03 PDT 2026
================
@@ -460,24 +460,30 @@ def run(self) -> None:
def expand_std(std: str) -> List[str]:
- split_std, or_later, _ = std.partition("-or-later")
-
- if not or_later:
- return [split_std]
-
- for standard_list in (CPP_STANDARDS, C_STANDARDS):
- item = next(
- (
- i
- for i, v in enumerate(standard_list)
- if (split_std in v if isinstance(v, (list, tuple)) else split_std == v)
- ),
- None,
- )
- if item is not None:
- return [split_std] + [
- x if isinstance(x, str) else x[0] for x in standard_list[item + 1 :]
- ]
+ split_std, or_later, suffix = std.partition("-or-later")
+
+ if or_later:
+ if suffix:
+ # Keep malformed -or-later spellings unchanged so clang diagnoses them.
+ return [std]
+
+ for standard_list in (CPP_STANDARDS, C_STANDARDS):
+ item = next(
+ (
+ i
+ for i, v in enumerate(standard_list)
+ if (
+ split_std in v
+ if isinstance(v, (list, tuple))
+ else split_std == v
+ )
+ ),
+ None,
+ )
+ if item is not None:
+ return [split_std] + [
+ x if isinstance(x, str) else x[0] for x in standard_list[item + 1 :]
+ ]
return [std]
----------------
zeyi2 wrote:
```python
if not or_later:
return [split_std]
```
Behavior is the same since `split_std == std` when `partition("-or-later")` does not find the separator.
https://github.com/llvm/llvm-project/pull/195609
More information about the cfe-commits
mailing list