[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
This commit is contained in:
Arthur O'Dwyer 2022-01-16 14:56:42 -05:00
parent dc2457c8cf
commit e93f98f09c
2 changed files with 14 additions and 1 deletions

View File

@ -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 * }

View File

@ -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!')