From ec636a404bf8c89fa24b7f2fcab62545d5f26eb9 Mon Sep 17 00:00:00 2001 From: implicitfield <114500360+implicitfield@users.noreply.github.com> Date: Wed, 7 Jun 2023 16:35:35 +0400 Subject: [PATCH] Meta: Make check-style.py complain if a non-AK complex header is used LibC's complex.h should not be used in C++ code, and libc++'s version implementation does not follow the Serenity C++ style. --- Meta/check-style.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Meta/check-style.py b/Meta/check-style.py index 7a370c28bf..0cf25c0517 100755 --- a/Meta/check-style.py +++ b/Meta/check-style.py @@ -47,6 +47,9 @@ GOOD_PRAGMA_ONCE_PATTERN = re.compile('(^|\\S\n\n)#pragma once(\n\n\\S.|$)') # LibC is supposed to be a system library; don't mention the directory. BAD_INCLUDE_LIBC = re.compile("# *include "](?!\\)).*$', re.M) SYSTEM_INCLUDE_PATTERN = re.compile("^ *# *include *<([^>]+)>(?: /[*/].*)?$") @@ -98,6 +101,7 @@ def run(): errors_include_libc = [] errors_include_weird_format = [] errors_include_missing_local = [] + errors_include_bad_complex = [] for filename in find_files_here_or_argv(): with open(filename, "r") as f: @@ -121,6 +125,8 @@ def run(): if not is_in_prefix_list(filename, LIBC_CHECK_EXCLUDES): if BAD_INCLUDE_LIBC.search(file_content): errors_include_libc.append(filename) + if BAD_INCLUDE_COMPLEX.search(file_content): + errors_include_bad_complex.append(filename) if not is_in_prefix_list(filename, INCLUDE_CHECK_EXCLUDES): file_directory = pathlib.Path(filename).parent for include_line in ANY_INCLUDE_PATTERN.findall(file_content): @@ -173,6 +179,12 @@ def run(): " ".join(errors_include_missing_local), ) have_errors = True + if errors_include_bad_complex: + print( + "Files that include a non-AK complex header:", + " ".join(errors_include_bad_complex), + ) + have_errors = True if have_errors: sys.exit(1)