[clang] [clang][bytecode] Fix newly added pfp test (PR #184137)

via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 2 06:47:54 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

Do the same thing 370d7ce58011eccfab8105eddbc028cc09c4c5e5 did in ExprConstant.cpp

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+1) 
- (modified) clang/test/CodeGenCXX/pfp-member-pointer-offsetof.cpp (+1) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 62cb37f720af2..c7d3c2e500592 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -5971,6 +5971,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
 
 bool InterpretOffsetOf(InterpState &S, CodePtr OpPC, const OffsetOfExpr *E,
                        ArrayRef<int64_t> ArrayIndices, int64_t &IntResult) {
+  S.getASTContext().recordOffsetOfEvaluation(E);
   CharUnits Result;
   unsigned N = E->getNumComponents();
   assert(N > 0);
diff --git a/clang/test/CodeGenCXX/pfp-member-pointer-offsetof.cpp b/clang/test/CodeGenCXX/pfp-member-pointer-offsetof.cpp
index 842bdd7e9f83d..d4abf27c01dc4 100644
--- a/clang/test/CodeGenCXX/pfp-member-pointer-offsetof.cpp
+++ b/clang/test/CodeGenCXX/pfp-member-pointer-offsetof.cpp
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -fexperimental-allow-pointer-field-protection-attr -fexperimental-pointer-field-protection-abi -o - %s -fexperimental-new-constant-interpreter | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -fexperimental-allow-pointer-field-protection-attr -fexperimental-pointer-field-protection-abi -o - %s | FileCheck %s
 
 // CHECK: @__pfp_ds__ZTS1S.ptr1 = hidden alias i8, inttoptr (i64 3573751839 to ptr)

``````````

</details>


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


More information about the cfe-commits mailing list