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

via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 12 06:21:16 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/181149.diff


1 Files Affected:

- (modified) clang/lib/AST/ByteCode/Pointer.h (+6-2) 


``````````diff
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;
 }
 

``````````

</details>


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


More information about the cfe-commits mailing list