[libcxx-commits] [libcxx] cc3be76 - [libc++][test] Selects proper C++23 field.
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Thu May 4 10:51:19 PDT 2023
Author: Mark de Wever
Date: 2023-05-04T19:51:12+02:00
New Revision: cc3be76bea668b7b314fdc0c9c3830e35f7a9981
URL: https://github.com/llvm/llvm-project/commit/cc3be76bea668b7b314fdc0c9c3830e35f7a9981
DIFF: https://github.com/llvm/llvm-project/commit/cc3be76bea668b7b314fdc0c9c3830e35f7a9981.diff
LOG: [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
Added:
Modified:
libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp
Removed:
################################################################################
diff --git a/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp b/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp
index 038788d94c915..c4a51fad72720 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");
}
More information about the libcxx-commits
mailing list