@@ -1325,6 +1325,8 @@ void GetDatamembers(TCppScope_t scope, std::vector<TCppScope_t>& datamembers) {
13251325
13261326 if (auto * CXXRD = llvm::dyn_cast_or_null<CXXRecordDecl>(D)) {
13271327 getSema ().ForceDeclarationOfImplicitMembers (CXXRD);
1328+ if (CXXRD->hasDefinition ())
1329+ CXXRD = CXXRD->getDefinition ();
13281330
13291331 llvm::SmallVector<RecordDecl::decl_iterator, 2 > stack_begin;
13301332 llvm::SmallVector<RecordDecl::decl_iterator, 2 > stack_end;
@@ -1445,7 +1447,7 @@ intptr_t GetVariableOffset(compat::Interpreter& I, Decl* D,
14451447 }
14461448 offset += C.toCharUnitsFromBits (C.getFieldOffset (FD)).getQuantity ();
14471449 }
1448- if (BaseCXXRD && BaseCXXRD != FieldParentRecordDecl) {
1450+ if (BaseCXXRD && BaseCXXRD != FieldParentRecordDecl-> getCanonicalDecl () ) {
14491451 // FieldDecl FD belongs to some class C, but the base class BaseCXXRD is
14501452 // not C. That means BaseCXXRD derives from C. Offset needs to be
14511453 // calculated for Derived class
@@ -1474,7 +1476,7 @@ intptr_t GetVariableOffset(compat::Interpreter& I, Decl* D,
14741476 }
14751477 if (auto * RD = llvm::dyn_cast<CXXRecordDecl>(FieldParentRecordDecl)) {
14761478 // add in the offsets for the (multi level) base classes
1477- while (BaseCXXRD != RD) {
1479+ while (BaseCXXRD != RD-> getCanonicalDecl () ) {
14781480 CXXRecordDecl* Parent = direction.at (RD);
14791481 offset +=
14801482 C.getASTRecordLayout (Parent).getBaseClassOffset (RD).getQuantity ();
0 commit comments