From ab7a683546c062a5f05c292fad9a4b71567fa409 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Fri, 2 Dec 2022 00:19:28 -0800 Subject: [PATCH] [TypeSwitch] Use perfect forwarding in the cast functions This allows for properly supporting TypeSwitch on reference types which do not support copying/do not want copying. --- llvm/include/llvm/ADT/TypeSwitch.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/include/llvm/ADT/TypeSwitch.h b/llvm/include/llvm/ADT/TypeSwitch.h index 044b243..523ff54 100644 --- a/llvm/include/llvm/ADT/TypeSwitch.h +++ b/llvm/include/llvm/ADT/TypeSwitch.h @@ -71,8 +71,8 @@ protected: /// Attempt to dyn_cast the given `value` to `CastT`. This overload is /// selected if `value` already has a suitable dyn_cast method. template - static auto castValue( - ValueT value, + static decltype(auto) castValue( + ValueT &&value, std::enable_if_t::value> * = nullptr) { return value.template dyn_cast(); @@ -81,8 +81,8 @@ protected: /// Attempt to dyn_cast the given `value` to `CastT`. This overload is /// selected if llvm::dyn_cast should be used. template - static auto castValue( - ValueT value, + static decltype(auto) castValue( + ValueT &&value, std::enable_if_t::value> * = nullptr) { return dyn_cast(value); -- 2.7.4