[clang] [clang][bytecode] Handle __builtin_wcslen (PR #119187)

via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 9 02:13:08 PST 2024


================
@@ -256,15 +256,28 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr OpPC,
     return false;
 
   assert(StrPtr.getFieldDesc()->isPrimitiveArray());
-
+  unsigned ElemSize = StrPtr.getFieldDesc()->getElemSize();
   size_t Len = 0;
   for (size_t I = StrPtr.getIndex();; ++I, ++Len) {
     const Pointer &ElemPtr = StrPtr.atIndex(I);
 
     if (!CheckRange(S, OpPC, ElemPtr, AK_Read))
       return false;
 
-    uint8_t Val = ElemPtr.deref<uint8_t>();
+    uint32_t Val;
----------------
cor3ntin wrote:

Should we assert that if `ID == Builtin::BIwcslen` ElemSize is the size of wchar_t?

https://github.com/llvm/llvm-project/pull/119187


More information about the cfe-commits mailing list