-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[STLForwardCompat] Implement llvm::type_identity #146390
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
Conversation
@llvm/pr-subscribers-clang @llvm/pr-subscribers-llvm-adt Author: Krzysztof Parzyszek (kparzysz) ChangesA basic implementation until we get it in Full diff: https://github.com/llvm/llvm-project/pull/146390.diff 2 Files Affected:
diff --git a/clang/include/clang/Tooling/Transformer/Transformer.h b/clang/include/clang/Tooling/Transformer/Transformer.h
index 71b1fe81b9518..ecf7c0912d2d8 100644
--- a/clang/include/clang/Tooling/Transformer/Transformer.h
+++ b/clang/include/clang/Tooling/Transformer/Transformer.h
@@ -42,11 +42,6 @@ class TransformerImpl {
virtual void
onMatchImpl(const ast_matchers::MatchFinder::MatchResult &Result) = 0;
};
-
-// FIXME: Use std::type_identity or backport when available.
-template <class T> struct type_identity {
- using type = T;
-};
} // namespace detail
template <typename T> struct TransformerResult {
@@ -95,8 +90,8 @@ class Transformer : public ast_matchers::MatchFinder::MatchCallback {
template <typename MetadataT>
explicit Transformer(
transformer::RewriteRuleWith<MetadataT> Rule,
- std::function<void(llvm::Expected<TransformerResult<
- typename detail::type_identity<MetadataT>::type>>)>
+ std::function<void(
+ llvm::Expected<TransformerResult<llvm::type_identity_t<MetadataT>>>)>
Consumer);
/// N.B. Passes `this` pointer to `MatchFinder`. So, this object should not
@@ -200,8 +195,8 @@ template <typename T> class WithMetadataImpl final : public TransformerImpl {
template <typename MetadataT>
Transformer::Transformer(
transformer::RewriteRuleWith<MetadataT> Rule,
- std::function<void(llvm::Expected<TransformerResult<
- typename detail::type_identity<MetadataT>::type>>)>
+ std::function<void(
+ llvm::Expected<TransformerResult<llvm::type_identity_t<MetadataT>>>)>
Consumer)
: Impl(std::make_unique<detail::WithMetadataImpl<MetadataT>>(
std::move(Rule), std::move(Consumer))) {}
diff --git a/llvm/include/llvm/ADT/STLForwardCompat.h b/llvm/include/llvm/ADT/STLForwardCompat.h
index 75a0d4acf67f1..370caf5a897b5 100644
--- a/llvm/include/llvm/ADT/STLForwardCompat.h
+++ b/llvm/include/llvm/ADT/STLForwardCompat.h
@@ -36,6 +36,16 @@ template <typename T>
using remove_cvref_t // NOLINT(readability-identifier-naming)
= typename llvm::remove_cvref<T>::type;
+template <typename T>
+struct type_identity // NOLINT(readability-identifier-naming)
+{
+ using type = T;
+};
+
+template <typename T>
+using type_identity_t // NOLINT(readability-identifier-naming)
+ = typename llvm::type_identity<T>::type;
+
//===----------------------------------------------------------------------===//
// Features from C++23
//===----------------------------------------------------------------------===//
|
unit test would be nice (just in the form of a static_assert, probably) |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/18899 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/12328 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/22503 Here is the relevant piece of the build log for the reference
|
A basic implementation until we get it in `std` in C++20.
A basic implementation until we get it in `std` in C++20.
A basic implementation until we get it in
std
in C++20.