Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions clang/include/clang/Tooling/Transformer/Transformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))) {}
Expand Down
10 changes: 10 additions & 0 deletions llvm/include/llvm/ADT/STLForwardCompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
//===----------------------------------------------------------------------===//
Expand Down
Loading