-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc++] Implements the new version header generator. #97847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# ===----------------------------------------------------------------------===## | ||
# | ||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# ===----------------------------------------------------------------------===## | ||
|
||
# RUN: %{python} %s %{libcxx-dir}/utils %{libcxx-dir}/test/libcxx/feature_test_macro/test_data.json | ||
|
||
import sys | ||
|
||
sys.path.append(sys.argv[1]) | ||
from generate_feature_test_macro_components import FeatureTestMacros | ||
|
||
|
||
def test(output, expected): | ||
assert output == expected, f"expected\n{expected}\n\noutput\n{output}" | ||
|
||
|
||
ftm = FeatureTestMacros(sys.argv[2]) | ||
test( | ||
ftm.ftm_metadata, | ||
{ | ||
"__cpp_lib_any": { | ||
"headers": ["any"], | ||
"test_suite_guard": None, | ||
"libcxx_guard": None, | ||
}, | ||
"__cpp_lib_barrier": { | ||
"headers": ["barrier"], | ||
"test_suite_guard": "!defined(_LIBCPP_HAS_NO_THREADS) && (!defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_SYNC)", | ||
"libcxx_guard": "!defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC", | ||
}, | ||
"__cpp_lib_format": { | ||
"headers": ["format"], | ||
"test_suite_guard": None, | ||
"libcxx_guard": None, | ||
}, | ||
"__cpp_lib_parallel_algorithm": { | ||
"headers": ["algorithm", "numeric"], | ||
"test_suite_guard": None, | ||
"libcxx_guard": None, | ||
}, | ||
"__cpp_lib_variant": { | ||
"headers": ["variant"], | ||
"test_suite_guard": None, | ||
"libcxx_guard": None, | ||
}, | ||
}, | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,13 @@ | |
"implemented": true | ||
} | ||
] | ||
}, | ||
"c++26": { | ||
"299900": [ | ||
{ | ||
"implemented": true | ||
} | ||
] | ||
} | ||
}, | ||
"headers": [ | ||
|
73 changes: 73 additions & 0 deletions
73
libcxx/test/libcxx/feature_test_macro/version_header.sh.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# ===----------------------------------------------------------------------===## | ||
# | ||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# ===----------------------------------------------------------------------===## | ||
|
||
# RUN: %{python} %s %{libcxx-dir}/utils %{libcxx-dir}/test/libcxx/feature_test_macro/test_data.json | ||
|
||
import sys | ||
|
||
sys.path.append(sys.argv[1]) | ||
from generate_feature_test_macro_components import FeatureTestMacros | ||
|
||
|
||
def test(output, expected): | ||
assert output == expected, f"expected\n{expected}\n\noutput\n{output}" | ||
|
||
|
||
ftm = FeatureTestMacros(sys.argv[2]) | ||
test( | ||
ftm.version_header, | ||
"""// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP_VERSION | ||
#define _LIBCPP_VERSION | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
#if _LIBCPP_STD_VER >= 17 | ||
# define __cpp_lib_any 201606L | ||
# define __cpp_lib_parallel_algorithm 201603L | ||
# define __cpp_lib_variant 202102L | ||
#endif // _LIBCPP_STD_VER >= 17 | ||
|
||
#if _LIBCPP_STD_VER >= 20 | ||
# if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC | ||
# define __cpp_lib_barrier 201907L | ||
# endif | ||
// define __cpp_lib_format 202110L | ||
# undef __cpp_lib_variant | ||
# define __cpp_lib_variant 202106L | ||
#endif // _LIBCPP_STD_VER >= 20 | ||
|
||
#if _LIBCPP_STD_VER >= 23 | ||
// define __cpp_lib_format 202207L | ||
#endif // _LIBCPP_STD_VER >= 23 | ||
|
||
#if _LIBCPP_STD_VER >= 26 | ||
# if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC | ||
# undef __cpp_lib_barrier | ||
# define __cpp_lib_barrier 299900L | ||
# endif | ||
// define __cpp_lib_format 202311L | ||
# undef __cpp_lib_variant | ||
# define __cpp_lib_variant 202306L | ||
#endif // _LIBCPP_STD_VER >= 26 | ||
|
||
#endif // _LIBCPP_VERSION | ||
""", | ||
) |
114 changes: 114 additions & 0 deletions
114
libcxx/test/libcxx/feature_test_macro/version_header_implementation.sh.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# ===----------------------------------------------------------------------===## | ||
# | ||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See https://llvm.org/LICENSE.txt for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# ===----------------------------------------------------------------------===## | ||
|
||
# RUN: %{python} %s %{libcxx-dir}/utils %{libcxx-dir}/test/libcxx/feature_test_macro/test_data.json | ||
|
||
import sys | ||
|
||
sys.path.append(sys.argv[1]) | ||
from generate_feature_test_macro_components import FeatureTestMacros | ||
|
||
|
||
def test(output, expected): | ||
assert output == expected, f"expected\n{expected}\n\noutput\n{output}" | ||
|
||
|
||
ftm = FeatureTestMacros(sys.argv[2]) | ||
test( | ||
ftm.version_header_implementation, | ||
{ | ||
"17": [ | ||
{ | ||
"__cpp_lib_any": { | ||
"value": "201606L", | ||
"implemented": True, | ||
"need_undef": False, | ||
"condition": None, | ||
}, | ||
}, | ||
{ | ||
"__cpp_lib_parallel_algorithm": { | ||
"value": "201603L", | ||
"implemented": True, | ||
"need_undef": False, | ||
"condition": None, | ||
}, | ||
}, | ||
{ | ||
"__cpp_lib_variant": { | ||
"value": "202102L", | ||
"implemented": True, | ||
"need_undef": False, | ||
"condition": None, | ||
}, | ||
}, | ||
], | ||
"20": [ | ||
{ | ||
"__cpp_lib_barrier": { | ||
"value": "201907L", | ||
"implemented": True, | ||
"need_undef": False, | ||
"condition": "!defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC", | ||
}, | ||
}, | ||
{ | ||
"__cpp_lib_format": { | ||
"value": "202110L", | ||
"implemented": False, | ||
"need_undef": False, | ||
"condition": None, | ||
}, | ||
}, | ||
{ | ||
"__cpp_lib_variant": { | ||
"value": "202106L", | ||
"implemented": True, | ||
"need_undef": True, | ||
"condition": None, | ||
}, | ||
}, | ||
], | ||
"23": [ | ||
{ | ||
"__cpp_lib_format": { | ||
"value": "202207L", | ||
"implemented": False, | ||
"need_undef": False, | ||
"condition": None, | ||
}, | ||
}, | ||
], | ||
"26": [ | ||
{ | ||
"__cpp_lib_barrier": { | ||
"value": "299900L", | ||
"implemented": True, | ||
"need_undef": True, | ||
"condition": "!defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC", | ||
}, | ||
}, | ||
{ | ||
"__cpp_lib_format": { | ||
"value": "202311L", | ||
"implemented": False, | ||
"need_undef": False, | ||
"condition": None, | ||
}, | ||
}, | ||
{ | ||
"__cpp_lib_variant": { | ||
"value": "202306L", | ||
"implemented": True, | ||
"need_undef": True, | ||
"condition": None, | ||
}, | ||
}, | ||
], | ||
}, | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output seems incorrect: this value is marked as
"implemented": false
intest_data.json
, and thus it should not be defined in the generated output.llvm-project/libcxx/test/libcxx/feature_test_macro/test_data.json
Lines 136 to 142 in a149e39
(I noticed this while working on an up-to-date FTM data file.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for noticing! This PR should fix it: #108843