From 7c65d57af0ef20ce28ca9c1efae8e3214d57268d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sat, 17 Sep 2022 16:14:37 +0200 Subject: [PATCH] [clang][Interp][NFC] Unify the two ReadArg() implementations Just use a constexpr if here instead of two different implementations. [# --- clang/lib/AST/Interp/Interp.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h index c8df624dfa23d6..0df7ead28cd340 100644 --- a/clang/lib/AST/Interp/Interp.h +++ b/clang/lib/AST/Interp/Interp.h @@ -993,17 +993,13 @@ inline bool ExpandPtr(InterpState &S, CodePtr OpPC) { // Read opcode arguments //===----------------------------------------------------------------------===// -template -inline std::enable_if_t::value, T> ReadArg(InterpState &S, - CodePtr &OpPC) { - return OpPC.read(); -} - -template -inline std::enable_if_t::value, T> ReadArg(InterpState &S, - CodePtr &OpPC) { - uint32_t ID = OpPC.read(); - return reinterpret_cast(S.P.getNativePointer(ID)); +template inline T ReadArg(InterpState &S, CodePtr &OpPC) { + if constexpr (std::is_pointer::value) { + uint32_t ID = OpPC.read(); + return reinterpret_cast(S.P.getNativePointer(ID)); + } else { + return OpPC.read(); + } } /// Interpreter entry point.