Skip to content

Commit 904f58e

Browse files
authored
[clang][bytecode] Use field descriptor in IntPointer::atOffset (#109238)
We're otherwise still pointing to the old type, but with the new offset.
1 parent 758444c commit 904f58e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

clang/lib/AST/ByteCode/Pointer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ IntPointer IntPointer::atOffset(const ASTContext &ASTCtx,
665665
uint64_t FieldOffset =
666666
ASTCtx.toCharUnitsFromBits(Layout.getFieldOffset(FieldIndex))
667667
.getQuantity();
668-
return IntPointer{this->Desc, this->Value + FieldOffset};
668+
return IntPointer{F->Desc, this->Value + FieldOffset};
669669
}
670670

671671
IntPointer IntPointer::baseCast(const ASTContext &ASTCtx,

clang/test/AST/ByteCode/codegen.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@ struct B {
1717
};
1818
const int A = (char *)(&( (struct B *)(16) )->b[0]) - (char *)(16);
1919
// CHECK: @A = constant i32 1
20+
21+
struct X { int a[2]; };
22+
int test(void) {
23+
static int i23 = (int) &(((struct X *)0)->a[1]);
24+
return i23;
25+
}
26+
// CHECK: @test.i23 = internal global i32 4, align 4

0 commit comments

Comments
 (0)