================
@@ -292,26 +355,78 @@ def check_notes(self, clang_tidy_output: str) -> None:
             try_run(
                 [
                     "FileCheck",
-                    "-input-file=" + notes_file,
+                    f"-input-file={notes_file}",
                     self.input_file_name,
-                    "-check-prefixes=" + ",".join(self.notes.prefixes),
+                    f"-check-prefixes={','.join(self.notes.prefixes)}",
                     "-implicit-check-not={{note|warning|error}}:",
                 ]
             )
 
+    def check_header_messages(self, clang_tidy_output: str) -> str:
+        """
+        Filters and verifies clang-tidy diagnostics for headers.
+
+        - Input: The raw diagnostic output from clang-tidy.
+        - Output: The diagnostic output intended for the main file
+                  verification.
+
+        This function separates messages belonging to headers specified by
+        `-check-header', verifies them using FileCheck against the header's
+        own rules, and returns the rest for further processing.
+        """
+        if not self.check_headers:
+            return clang_tidy_output
+
+        header_messages = defaultdict(list)
+        remaining_lines: List[str] = []
+        current_file: str = ""
+
+        for line in clang_tidy_output.splitlines(keepends=True):
+            if re.match(r"^\d+ warnings? generated\.", line):
+                continue
+            # Matches the beginning of a clang-tidy diagnostic line,
+            # which starts with "file_path:line:col: ".
+            match = re.match(r"^(.+):\d+:\d+: ", line)
+            if match:
----------------
EugeneZelenko wrote:

```suggestion
            if match := re.match(r"^(.+):\d+:\d+: ", line):
```

https://github.com/llvm/llvm-project/pull/175735
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to