================
@@ -23785,25 +23785,29 @@ EvaluateBuiltinStrLen(const Expr *E, EvalInfo &Info,
   if (!EvaluatePointer(E, String, Info))
     return std::nullopt;
 
+  QualType CharTy = E->getType()->getPointeeType();
+
   // Fast path: if it's a string literal, search the string value.
   if (const StringLiteral *S = dyn_cast_or_null<StringLiteral>(
           String.getLValueBase().dyn_cast<const Expr *>())) {
     StringRef Str = S->getBytes();
     int64_t Off = String.Offset.getQuantity();
-    if (Off >= 0 && (uint64_t)Off <= (uint64_t)Str.size()) {
-      UnsignedOrNone ZeroIndex = S->findZeroCodeUnit(Off);
-      if (StringResult) {
-        if (ZeroIndex)
-          Str = Str.substr(Off, *ZeroIndex);
-        *StringResult = Str;
+    unsigned Width = S->getCharByteWidth();
+    // When the text is wanted, wide strings go to the slow path, which
+    // builds it one char per character. Raw bytes here would not match.
+    if (Off >= 0 && (uint64_t)Off <= (uint64_t)Str.size() && Off % Width == 0 
&&
----------------
MScarta wrote:

Done.


https://github.com/llvm/llvm-project/pull/241354
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to