https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/109238
We're otherwise still pointing to the old type, but with the new offset. >From aa2c3e286ec40d6897e17df6b2dd93553f93159c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com> Date: Thu, 19 Sep 2024 07:47:33 +0200 Subject: [PATCH] [clang][bytecode] Use field descriptor in IntPointer::atOffset We're otherwise still pointing to the old type, but with the new offset. --- clang/lib/AST/ByteCode/Pointer.cpp | 2 +- clang/test/AST/ByteCode/codegen.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp index 282953eb991a6b..387cad9b137c02 100644 --- a/clang/lib/AST/ByteCode/Pointer.cpp +++ b/clang/lib/AST/ByteCode/Pointer.cpp @@ -665,7 +665,7 @@ IntPointer IntPointer::atOffset(const ASTContext &ASTCtx, uint64_t FieldOffset = ASTCtx.toCharUnitsFromBits(Layout.getFieldOffset(FieldIndex)) .getQuantity(); - return IntPointer{this->Desc, this->Value + FieldOffset}; + return IntPointer{F->Desc, this->Value + FieldOffset}; } IntPointer IntPointer::baseCast(const ASTContext &ASTCtx, diff --git a/clang/test/AST/ByteCode/codegen.c b/clang/test/AST/ByteCode/codegen.c index 8434992823010e..3c6f17e2b87264 100644 --- a/clang/test/AST/ByteCode/codegen.c +++ b/clang/test/AST/ByteCode/codegen.c @@ -17,3 +17,10 @@ struct B { }; const int A = (char *)(&( (struct B *)(16) )->b[0]) - (char *)(16); // CHECK: @A = constant i32 1 + +struct X { int a[2]; }; +int test(void) { + static int i23 = (int) &(((struct X *)0)->a[1]); + return i23; +} +// CHECK: @test.i23 = internal global i32 4, align 4 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits