From d128a03ff3b1d3e48fae41a10e790faf3a775d35 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Wed, 9 Nov 2022 12:48:43 +0100 Subject: [PATCH] [clang][Interp][NFC] Use constexpr if in OffsetHelper Add here is a template parameter, so we can do this. --- clang/lib/AST/Interp/Interp.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h index a90e124..002571e 100644 --- a/clang/lib/AST/Interp/Interp.h +++ b/clang/lib/AST/Interp/Interp.h @@ -1056,7 +1056,12 @@ template bool OffsetHelper(InterpState &S, CodePtr OpPC) { // Offset is valid - compute it on unsigned. int64_t WideIndex = static_cast(Index); int64_t WideOffset = static_cast(Offset); - int64_t Result = Add ? (WideIndex + WideOffset) : (WideIndex - WideOffset); + int64_t Result; + if constexpr (Add) + Result = WideIndex + WideOffset; + else + Result = WideIndex - WideOffset; + S.Stk.push(Ptr.atIndex(static_cast(Result))); return true; } -- 2.7.4