Skip to content

Commit d2c26d8

Browse files
authored
[clang][Interp] Use first field decl for Record field lookup (#104412)
1 parent 2ccbf92 commit d2c26d8

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

clang/lib/AST/Interp/Program.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
329329
// Reserve space for fields.
330330
Record::FieldList Fields;
331331
for (const FieldDecl *FD : RD->fields()) {
332+
assert(FD == FD->getFirstDecl());
332333
// Note that we DO create fields and descriptors
333334
// for unnamed bitfields here, even though we later ignore
334335
// them everywhere. That's so the FieldDecl's getFieldIndex() matches.

clang/lib/AST/Interp/Record.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const std::string Record::getName() const {
3737
}
3838

3939
const Record::Field *Record::getField(const FieldDecl *FD) const {
40-
auto It = FieldMap.find(FD);
40+
auto It = FieldMap.find(FD->getFirstDecl());
4141
assert(It != FieldMap.end() && "Missing field");
4242
return It->second;
4343
}

clang/test/Modules/enum-codegen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: rm -rf %t
22
// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fmodules-cache-path=%t %s -emit-llvm -o - | FileCheck %s
3+
// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fmodules-cache-path=%t %s -emit-llvm -o - -fexperimental-new-constant-interpreter | FileCheck %s
34

45
// CHECK: @{{.*var.*}} = {{.*}} %union.union_type { i8 1 },
56

0 commit comments

Comments
 (0)