diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index edf668921f9c1..be4bfe475667d 100755 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -483,6 +483,18 @@ def add_version_header(tc): }, ]], key=lambda tc: tc["name"]) +# Map from each header to the Lit annotations that should be used for +# tests that include that header. +# +# For example, when threads are not supported, any feature-test-macro test +# that includes should be marked as UNSUPPORTED, because including +# is a hard error in that case. +lit_markup = { + "atomic": ["UNSUPPORTED: libcpp-has-no-threads"], + "shared_mutex": ["UNSUPPORTED: libcpp-has-no-threads"], + "thread": ["UNSUPPORTED: libcpp-has-no-threads"], +} + def get_std_dialects(): std_dialects = ['c++14', 'c++17', 'c++2a'] return list(std_dialects) @@ -734,10 +746,6 @@ def mk_line(prefix, suffix): result += "*/" return result -def is_threading_header_unsafe_to_include(h): - # NOTE: "" does not blow up when included without threads. - return h in ['atomic', 'shared_mutex'] - def produce_tests(): headers = set([h for tc in feature_test_macros for h in tc["headers"]]) for h in headers: @@ -746,9 +754,7 @@ def produce_tests(): for tc in test_list: assert 'unimplemented' in tc.keys() continue - test_tags = "" - if is_threading_header_unsafe_to_include(h): - test_tags += '\n// UNSUPPORTED: libcpp-has-no-threads\n' + markup = '\n'.join('// ' + tag for tag in lit_markup.get(h, [])) test_body = \ """//===----------------------------------------------------------------------===// // @@ -760,7 +766,7 @@ def produce_tests(): // // WARNING: This test was generated by {script_name} // and should not be edited manually. -{test_tags} +{markup} // <{header}> // Test the feature test macros defined by <{header}> @@ -791,7 +797,7 @@ def produce_tests(): int main(int, char**) {{ return 0; }} """.format(script_name=script_name, header=h, - test_tags=test_tags, + markup=('\n{}\n'.format(markup) if markup else ''), synopsis=generate_synopsis(test_list), cxx11_tests=generate_std_test(test_list, 'c++11').strip(), cxx14_tests=generate_std_test(test_list, 'c++14').strip(),