forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc++] Implements the new version header generator. (llvm#97847)
The generator makes a few changes to the output - removes the synopsis, it did not really show what was implemented correctly. - the output now is clang-format clean. This code uses the new FTM data structure. Since the contents of this structure are not up-to-date the code is only used in its tests.
- Loading branch information
1 parent
019c1fa
commit 87e2841
Showing
7 changed files
with
390 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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.