""" Parses compiler output from Clang or GCC and checks that warnings exist only in files that are expected to have warnings. """ import argparse from collections import defaultdict import re import sys from pathlib import Path from typing import NamedTuple class FileWarnings(NamedTuple): name: str count: int def extract_warnings_from_compiler_output( compiler_output: str, compiler_output_type: str, path_prefix: str = "", ) -> list[dict]: """ Extracts warnings from the compiler output based on compiler output type. Removes path prefix from file paths if provided. Compatible with GCC and Clang compiler output. """ # Choose pattern and compile regex for particular compiler output if compiler_output_type == "gcc": regex_pattern = ( r"(?P.*):(?P\d+):(?P\d+): warning: " r"(?P.*?)(?: (?P