diff --git a/clang/lib/AST/Interp/InterpBuiltin.cpp b/clang/lib/AST/Interp/InterpBuiltin.cpp index 8f45c789296b6..760219e0ffa9f 100644 --- a/clang/lib/AST/Interp/InterpBuiltin.cpp +++ b/clang/lib/AST/Interp/InterpBuiltin.cpp @@ -85,7 +85,8 @@ static void pushInteger(InterpState &S, T Val, QualType QT) { pushInteger(S, APSInt(Val, !std::is_signed_v), QT); else pushInteger(S, - APSInt(APInt(sizeof(T) * 8, Val, std::is_signed_v), + APSInt(APInt(sizeof(T) * 8, static_cast(Val), + std::is_signed_v), !std::is_signed_v), QT); } @@ -464,7 +465,7 @@ static bool interp__builtin_popcount(InterpState &S, CodePtr OpPC, PrimType ArgT = *S.getContext().classify(Call->getArg(0)->getType()); APSInt Val = peekToAPSInt(S.Stk, ArgT); - pushInteger(S, APSInt(APInt(32, Val.popcount())), Call->getType()); + pushInteger(S, Val.popcount(), Call->getType()); return true; } @@ -805,7 +806,7 @@ static bool interp__builtin_clz(InterpState &S, CodePtr OpPC, if (ZeroIsUndefined && Val == 0) return false; - pushInteger(S, APSInt(APInt(32, Val.countl_zero())), Call->getType()); + pushInteger(S, Val.countl_zero(), Call->getType()); return true; }