[clang-tools-extra] [clang-tidy] Header check support for check_clang_tidy.py (PR #175735)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 4 00:02:56 PST 2026
================
@@ -196,15 +210,36 @@ def get_prefixes(self) -> None:
)
assert expect_diagnosis or self.expect_no_diagnosis
+ def _sanitize_content(self, text: str) -> str:
+ return re.sub("// *CHECK-[A-Z0-9\\-]*:[^\r\n]*", "//", text)
+
+ def _filter_prefixes(self, prefixes: Sequence[str], check_file: str) -> List[str]:
----------------
zeyi2 wrote:
`_filter_prefixes` checks which prefixes are actually present in a given file.
If we invoke `FileCheck` with `--check-prefix=CHECK-FIXES` but the file contains no `CHECK-FIXES:` directives, `FileCheck` will fail.
This is common in header testing scenarios where expectations differ between files. [e.g. the main file might verify code changes (`CHECK-FIXES`), while the header file might only verify warnings (`CHECK-MESSAGES`)]
This function ensures we only pass the relevant prefixes to `FileCheck` for each specific file.
https://github.com/llvm/llvm-project/pull/175735
More information about the cfe-commits
mailing list