[clang] 78275ef - [clang][Interp] Pick the right APInt constructor on Windows

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 26 09:23:54 PST 2024


Author: Timm Bäder
Date: 2024-02-26T18:23:41+01:00
New Revision: 78275ef0a33a808d30285603585300ce57d7ef26

URL: https://github.com/llvm/llvm-project/commit/78275ef0a33a808d30285603585300ce57d7ef26
DIFF: https://github.com/llvm/llvm-project/commit/78275ef0a33a808d30285603585300ce57d7ef26.diff

LOG: [clang][Interp] Pick the right APInt constructor on Windows

The second parameter needs to be a uint64_t and nothing else.
This broke windows builders, see
https://github.com/llvm/llvm-project/commit/264d828ea6399c31c210b67a050fbf084634da6a

Added: 
    

Modified: 
    clang/lib/AST/Interp/InterpBuiltin.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/InterpBuiltin.cpp b/clang/lib/AST/Interp/InterpBuiltin.cpp
index 8f45c789296b66..760219e0ffa9f3 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<T>), QT);
   else
     pushInteger(S,
-                APSInt(APInt(sizeof(T) * 8, Val, std::is_signed_v<T>),
+                APSInt(APInt(sizeof(T) * 8, static_cast<uint64_t>(Val),
+                             std::is_signed_v<T>),
                        !std::is_signed_v<T>),
                 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;
 }
 


        


More information about the cfe-commits mailing list