[clang] [clang][bytecode] Fix debug-printing one-past-the-end pointers (PR #181149)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 12 06:20:36 PST 2026


https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/181149

Can't call `getIndex()` on those.

>From c0be66f17e4f43c20c83b4980a5d3f7e35a25c1d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Thu, 12 Feb 2026 15:17:59 +0100
Subject: [PATCH] [clang][bytecode] Fix debug-printing one-past-the-end
 pointers

---
 clang/lib/AST/ByteCode/Pointer.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h
index 2515b2fe56ab9..5c3f98ad01eb4 100644
--- a/clang/lib/AST/ByteCode/Pointer.h
+++ b/clang/lib/AST/ByteCode/Pointer.h
@@ -869,8 +869,12 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Pointer &P) {
   OS << ' ';
   if (const Descriptor *D = P.getFieldDesc())
     D->dump(OS);
-  if (P.isArrayElement())
-    OS << " index " << P.getIndex();
+  if (P.isArrayElement()) {
+    if (P.isOnePastEnd())
+      OS << " one-past-the-end";
+    else
+      OS << " index " << P.getIndex();
+  }
   return OS;
 }
 



More information about the cfe-commits mailing list