[libcxx-commits] [libcxx] b6d7568 - [libc++] [test] Check the presence of "pragma include_instead" in newly added headers.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Feb 27 09:28:31 PST 2022
Author: Arthur O'Dwyer
Date: 2022-02-27T12:27:56-05:00
New Revision: b6d75682f9fe6a164878b98989a157b7a5e36c02
URL: https://github.com/llvm/llvm-project/commit/b6d75682f9fe6a164878b98989a157b7a5e36c02
DIFF: https://github.com/llvm/llvm-project/commit/b6d75682f9fe6a164878b98989a157b7a5e36c02.diff
LOG: [libc++] [test] Check the presence of "pragma include_instead" in newly added headers.
Unless/until we revert D106124, we should make sure that every newly added
detail header includes this line.
Added:
Modified:
libcxx/test/libcxx/lint/lint_headers.sh.py
Removed:
################################################################################
diff --git a/libcxx/test/libcxx/lint/lint_headers.sh.py b/libcxx/test/libcxx/lint/lint_headers.sh.py
index b2e6b477f1aef..5f3f128c02b75 100644
--- a/libcxx/test/libcxx/lint/lint_headers.sh.py
+++ b/libcxx/test/libcxx/lint/lint_headers.sh.py
@@ -15,11 +15,38 @@ def exclude_from_consideration(path):
os.path.basename(path) == '__config' or
os.path.basename(path) == '__config_site.in' or
os.path.basename(path) == '__libcpp_version' or
- os.path.basename(path) == '__locale' or
not os.path.isfile(path)
)
+def check_for_pragma_GCC_system_header(pretty_fname, lines):
+ if pretty_fname not in ['__undef_macros']:
+ if '# pragma GCC system_header\n' not in lines:
+ print('FAILED TO FIND # pragma GCC system_header in libcxx/include/%s!' % pretty_fname)
+ return False
+ return True
+
+def check_for_pragma_clang_include_instead(pretty_fname, lines):
+ expect_include_instead = pretty_fname.startswith('__') and pretty_fname not in [
+ '__assert',
+ '__bsd_locale_fallbacks.h',
+ '__bsd_locale_defaults.h',
+ '__availability',
+ '__debug',
+ '__errc',
+ '__mbstate_t.h',
+ '__undef_macros',
+ ]
+ found_include_instead = any(line.startswith('# pragma clang include_instead') for line in lines)
+ if expect_include_instead and not found_include_instead:
+ print('FAILED TO FIND # pragma clang include_instead in libcxx/include/%s!' % pretty_fname)
+ return False
+ elif found_include_instead and not expect_include_instead:
+ print('UNEXPECTEDLY FOUND # pragma clang include_instead in libcxx/include/%s!' % pretty_fname)
+ return False
+ return True
+
+
if __name__ == '__main__':
libcxx_test_libcxx_lint = os.path.dirname(os.path.abspath(__file__))
libcxx_include = os.path.abspath(os.path.join(libcxx_test_libcxx_lint, '../../../include'))
@@ -37,11 +64,11 @@ def pretty(path):
okay = True
for fname in all_headers:
+ pretty_fname = pretty(fname)
with open(fname, 'r') as f:
lines = f.readlines()
- if '# pragma GCC system_header\n' not in lines:
- if pretty(fname) not in ['__undef_macros']:
- okay = False
- print('FAILED TO FIND # pragma GCC system_header in libcxx/include/%s!' % pretty(fname))
+ okay = check_for_pragma_GCC_system_header(pretty_fname, lines) and okay
+ okay = check_for_pragma_clang_include_instead(pretty_fname, lines) and okay
+
assert okay
More information about the libcxx-commits
mailing list