Skip to content

Commit

Permalink
[clang][bytecode] Use field descriptor in IntPointer::atOffset (llvm#…
Browse files Browse the repository at this point in the history
…109238)

We're otherwise still pointing to the old type, but with the new offset.
  • Loading branch information
tbaederr authored Sep 19, 2024
1 parent 758444c commit 904f58e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/Pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions clang/test/AST/ByteCode/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 904f58e

Please sign in to comment.