[libcxx-commits] [PATCH] D149554: [libc++][test] Selects proper C++23 field.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Apr 30 12:25:46 PDT 2023
Mordante created this revision.
Mordante added a reviewer: philnik.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
D149553 <https://reviews.llvm.org/D149553> changes the name of the LangOptions member. This change allows
libc++ to work with either name.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D149554
Files:
libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp
Index: libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp
===================================================================
--- libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp
+++ libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp
@@ -13,6 +13,7 @@
#include <algorithm>
#include <array>
+#include <concepts>
#include <span>
#include <string_view>
@@ -25,6 +26,24 @@
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(!std::same_as<decltype(T::CPlusPlus2b), void>)
+{
+ return lang_opts.CPlusPlus2b;
+}
+
+template <class T>
+bool CPlusPlus23(const T& lang_opts)
+ requires(!std::same_as<decltype(T::CPlusPlus23), void>)
+{
+ 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 +62,7 @@
attributes.emplace_back("no_unique_address");
}
- if (lang_opts.CPlusPlus2b) {
+ if (CPlusPlus23(lang_opts)) {
attributes.emplace_back("assume");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149554.518345.patch
Type: text/x-patch
Size: 1436 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230430/70ef8f09/attachment.bin>
More information about the libcxx-commits
mailing list