https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/227181

>From 8293943f11ff04b7de3e96ce39f4e54a539a9491 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Tue, 29 Sep 2026 05:05:41 +0200
Subject: [PATCH] [clang][bytecode] Move past-end check into CheckFinalLoad

It makes more sense there. Also remove the one of for non-const
pointers, since that one isn't needed anymore
---
 clang/lib/AST/ByteCode/EvalEmitter.cpp | 9 ---------
 clang/lib/AST/ByteCode/Interp.cpp      | 3 +++
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp 
b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index ec7550eb4cc17..01a3040be4e86 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -282,18 +282,9 @@ template <> bool EvalEmitter::emitRet<PT_Ptr>(SourceInfo 
Info) {
 
   // Implicitly convert lvalue to rvalue, if requested.
   if (ConvertResultToRValue) {
-    if (Ptr.isPastEnd())
-      return false;
-
     if (!Ptr.isZero() && !CheckFinalLoad(S, CodePtr(), Ptr))
       return false;
 
-    // Never allow reading from a non-const pointer, unless the memory
-    // has been created in this evaluation.
-    if (!Ptr.isZero() && !Ptr.isConst() && Ptr.isBlockPointer() &&
-        Ptr.block()->getEvalID() != Ctx.getEvalID())
-      return false;
-
     if (!EvalResult.checkLValueFields(S, Ptr, Info, ConstexprKind))
       return false;
 
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 132c4ae92be41..f9cda204a08f5 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1082,6 +1082,9 @@ bool CheckFinalLoad(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr) {
     return CheckWeak(S, OpPC, Ptr.block());
   }
 
+  if (Ptr.isPastEnd())
+    return false;
+
   if (!CheckConstant(S, OpPC, Ptr))
     return false;
 

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

Reply via email to