================
@@ -324,14 +348,34 @@ std::optional<uint64_t> Context::evaluateStrlen(State 
&Parent, const Expr *E) {
   std::optional<uint64_t> Result;
   auto PtrRes = C.interpretAsPointer(E, [&](InterpState &S, CodePtr OpPC,
                                             const Pointer &Ptr) {
-    if (!Ptr.isBlockPointer())
+    if (!Ptr.isReadablePointerType())
+      return false;
+
+    if (Ptr.isPastEnd())
       return false;
 
+    if (Ptr.isStringPointer()) {
+
+      const auto *Lit = Ptr.asStringPointer().getLiteral();
+      int64_t Off = Ptr.getByteOffset();
+      if (Off < 0)
+        return false;
----------------
ojhunt wrote:

What happens here if I have something like `("foo"+2) -1` ?

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

Reply via email to