[clang] [clang][AST] Print OnePastTheEnd bit in `APValue::dump()` (PR #214450)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 6 03:46:42 PDT 2026
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/214450
For lvalue APValues.
>From d8b7eb46022a86d03779b9cc615231298f217f0e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Thu, 6 Aug 2026 12:45:50 +0200
Subject: [PATCH] [clang][AST] Print OnePastTheEnd bit in `APValue::dump()`
For lvalue APValues.
---
clang/lib/AST/TextNodeDumper.cpp | 1 +
clang/test/AST/ast-dump-APValue-lvalue.cpp | 18 +++++++++++-------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index d987dd6cacd12..e9f0727becfe1 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -759,6 +759,7 @@ void TextNodeDumper::Visit(const APValue &Value, QualType Ty) {
}
OS << ", Null=" << Value.isNullPointer()
<< ", Offset=" << Value.getLValueOffset().getQuantity()
+ << ", OnePastTheEnd=" << Value.isLValueOnePastTheEnd()
<< ", HasPath=" << Value.hasLValuePath();
if (Value.hasLValuePath()) {
OS << ", PathLength=" << Value.getLValuePath().size();
diff --git a/clang/test/AST/ast-dump-APValue-lvalue.cpp b/clang/test/AST/ast-dump-APValue-lvalue.cpp
index f4cf2f5291760..92e881aca3d80 100644
--- a/clang/test/AST/ast-dump-APValue-lvalue.cpp
+++ b/clang/test/AST/ast-dump-APValue-lvalue.cpp
@@ -40,31 +40,35 @@ struct MP : P, Q {
void Test(int (&arr)[10]) {
constexpr int *pi = &i;
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pi 'int *const' constexpr cinit
- // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=0, HasPath=1, PathLength=0, Path=()
+ // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=0, OnePastTheEnd=0, HasPath=1, PathLength=0, Path=()
+
+ constexpr int *pi2 = &i + 1;
+ // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pi2 'int *const' constexpr cinit
+ // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=4, OnePastTheEnd=1, HasPath=1, PathLength=0, Path=()
constexpr int *psi = &s.i;
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} psi 'int *const' constexpr cinit
- // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=0, HasPath=1, PathLength=1, Path=({{.*}})
+ // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=0, OnePastTheEnd=0, HasPath=1, PathLength=1, Path=({{.*}})
constexpr int *psii = &s.ii;
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} psii 'int *const' constexpr cinit
- // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=4, HasPath=1, PathLength=1, Path=({{.*}})
+ // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=4, OnePastTheEnd=0, HasPath=1, PathLength=1, Path=({{.*}})
constexpr int *pf = &f.s.ii;
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pf 'int *const' constexpr cinit
- // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=16, HasPath=1, PathLength=2, Path=({{.*}}, {{.*}})
+ // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=16, OnePastTheEnd=0, HasPath=1, PathLength=2, Path=({{.*}}, {{.*}})
constexpr char *pc = &f.padding[2];
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pc 'char *const' constexpr cinit
- // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=2, HasPath=1, PathLength=2, Path=({{.*}}, 2)
+ // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=2, OnePastTheEnd=0, HasPath=1, PathLength=2, Path=({{.*}}, 2)
constexpr const int *n = nullptr;
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} n 'const int *const' constexpr cinit
- // CHECK-NEXT: | |-value: LValue Base=null, Null=1, Offset=0, HasPath=1, PathLength=0, Path=()
+ // CHECK-NEXT: | |-value: LValue Base=null, Null=1, Offset=0, OnePastTheEnd=0, HasPath=1, PathLength=0, Path=()
constexpr const std::type_info* pti = &typeid(int);
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pti 'const std::type_info *const' constexpr cinit
- // CHECK-NEXT: | |-value: LValue Base=TypeInfoLValue typeid(int), Null=0, Offset=0, HasPath=1, PathLength=0, Path=()
+ // CHECK-NEXT: | |-value: LValue Base=TypeInfoLValue typeid(int), Null=0, Offset=0, OnePastTheEnd=0, HasPath=1, PathLength=0, Path=()
constexpr int(MP::*pmi) = (int MP::*)&P::x;
// CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pmi 'int (MP::*const)' constexpr cinit
More information about the cfe-commits
mailing list