summaryrefslogtreecommitdiff
path: root/libcxx
diff options
context:
space:
mode:
authorMark de Wever <koraq@xs4all.nl>2023-04-30 21:23:30 +0200
committerMark de Wever <koraq@xs4all.nl>2023-05-04 19:51:12 +0200
commitcc3be76bea668b7b314fdc0c9c3830e35f7a9981 (patch)
tree6460c98c43aec5c503efa6bfeed733f7e5e947ea /libcxx
parent3bcc28becd403f80099d1774e1f02705f785ceaf (diff)
downloadllvm-cc3be76bea668b7b314fdc0c9c3830e35f7a9981.tar.gz
[libc++][test] Selects proper C++23 field.
D149553 changes the name of the LangOptions member. This change allows libc++ to work with either name. Reviewed By: philnik, #libc Differential Revision: https://reviews.llvm.org/D149554
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp b/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp
index 038788d94c91..c4a51fad7272 100644
--- a/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp
+++ b/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp
@@ -25,6 +25,24 @@ bool isUgly(std::string_view str) {
return str.find("__") != std::string_view::npos;
}
+// Starting with Clang 17 ToT C++23 support is provided by CPlusPlus23 instead
+// of C++23 support is provided by CPlusPlus2b. To allow a smooth transition for
+// libc++ use "reflection" to select the proper member. Since the change
+// happens in the development cycle it's not possible to use #ifdefs.
+template <class T>
+bool CPlusPlus23(const T& lang_opts)
+ requires requires { T::CPlusPlus2b; }
+{
+ return lang_opts.CPlusPlus2b;
+}
+
+template <class T>
+bool CPlusPlus23(const T& lang_opts)
+ requires requires { T::CPlusPlus23; }
+{
+ return lang_opts.CPlusPlus23;
+}
+
std::vector<const char*> get_standard_attributes(const clang::LangOptions& lang_opts) {
std::vector<const char*> attributes = {"noreturn", "carries_dependency"};
@@ -43,7 +61,7 @@ std::vector<const char*> get_standard_attributes(const clang::LangOptions& lang_
attributes.emplace_back("no_unique_address");
}
- if (lang_opts.CPlusPlus2b) {
+ if (CPlusPlus23(lang_opts)) {
attributes.emplace_back("assume");
}