From e93f98f09c86b909d0ba76196cce57399bf23d6f Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sun, 16 Jan 2022 14:56:42 -0500 Subject: [PATCH] [libc++] [test] Check for another kind of modulemap typo in lint_modulemap.sh.py. Verify that the name of the private submodule matches the name of the detail header. Differential Revision: https://reviews.llvm.org/D117438 --- libcxx/include/module.modulemap | 2 +- libcxx/test/libcxx/lint/lint_modulemap.sh.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap index 33e0ecf69974..e5a92e97f53f 100644 --- a/libcxx/include/module.modulemap +++ b/libcxx/include/module.modulemap @@ -989,7 +989,7 @@ module std [system] { module __function_like { private header "__function_like.h" export * } module __hash_table { header "__hash_table" export * } module __locale { private header "__locale" export * } - module __mbstate { private header "__mbstate_t.h" export * } + module __mbstate_t { private header "__mbstate_t.h" export * } module __mutex_base { private header "__mutex_base" export * } module __node_handle { private header "__node_handle" export * } module __nullptr { header "__nullptr" export * } diff --git a/libcxx/test/libcxx/lint/lint_modulemap.sh.py b/libcxx/test/libcxx/lint/lint_modulemap.sh.py index 870708dd556b..65c58c54b812 100644 --- a/libcxx/test/libcxx/lint/lint_modulemap.sh.py +++ b/libcxx/test/libcxx/lint/lint_modulemap.sh.py @@ -18,6 +18,19 @@ if __name__ == '__main__': with open(modulemap_name, 'r') as f: for line in f.readlines(): if re.match(r'^\s*module.*[{]\s*private', line): + # Check that these lines are all of the expected format. + # This incidentally checks for typos in the module name. + if re.match(r'^\s*module (\w+)\s+[{] private header "\1(.h)?"\s+export [*] [}]', line): + # It's a top-level private header, such as <__bit_reference>. + pass + elif re.match(r'^\s*module (\w+)\s+[{] private header "__\w+/\1[.]h" [}]', line): + # It's a private submodule, such as <__utility/swap.h>. + pass + else: + okay = False + print("LINE DOESN'T MATCH REGEX in libcxx/include/module.modulemap!") + print(line) + # Check that these lines are alphabetized. if (prevline is not None) and (line < prevline): okay = False print('LINES OUT OF ORDER in libcxx/include/module.modulemap!')