GlobalUDTs.clear();
TypeIndices.clear();
CompleteTypeIndices.clear();
- ClassInfoMap.clear();
}
void CodeViewDebug::collectMemberInfo(ClassInfo &Info,
Info.Members.push_back({DDTy, 0});
return;
}
- // Member with no name, must be nested structure/union, collects its memebers
+ // An unnamed member must represent a nested struct or union. Add all the
+ // indirect fields to the current record.
assert((DDTy->getOffsetInBits() % 8) == 0 && "Unnamed bitfield member!");
- unsigned offset = DDTy->getOffsetInBits() / 8;
+ unsigned Offset = DDTy->getOffsetInBits() / 8;
const DIType *Ty = DDTy->getBaseType().resolve();
const DICompositeType *DCTy = cast<DICompositeType>(Ty);
- ClassInfo &NestedInfo = collectClassInfo(DCTy);
- ClassInfo::MemberList &Members = NestedInfo.Members;
- for (unsigned i = 0, e = Members.size(); i != e; ++i)
+ ClassInfo NestedInfo = collectClassInfo(DCTy);
+ for (const ClassInfo::MemberInfo &IndirectField : NestedInfo.Members)
Info.Members.push_back(
- {Members[i].MemberTypeNode, Members[i].BaseOffset + offset});
+ {IndirectField.MemberTypeNode, IndirectField.BaseOffset + Offset});
}
-ClassInfo &CodeViewDebug::collectClassInfo(const DICompositeType *Ty) {
- auto Insertion = ClassInfoMap.insert({Ty, std::unique_ptr<ClassInfo>()});
- ClassInfo *Info = nullptr;
- {
- std::unique_ptr<ClassInfo> &InfoEntry = Insertion.first->second;
- if (!Insertion.second)
- return *InfoEntry;
- InfoEntry.reset(new ClassInfo());
- Info = InfoEntry.get();
- }
-
+ClassInfo CodeViewDebug::collectClassInfo(const DICompositeType *Ty) {
+ ClassInfo Info;
// Add elements to structure type.
DINodeArray Elements = Ty->getElements();
for (auto *Element : Elements) {
// Non-virtual methods does not need the introduced marker.
// Set it to false.
bool Introduced = false;
- Info->Methods[SP->getRawName()].push_back({SP, Introduced});
+ Info.Methods[SP->getRawName()].push_back({SP, Introduced});
} else if (auto *DDTy = dyn_cast<DIDerivedType>(Element)) {
if (DDTy->getTag() == dwarf::DW_TAG_member)
- collectMemberInfo(*Info, DDTy);
+ collectMemberInfo(Info, DDTy);
else if (DDTy->getTag() == dwarf::DW_TAG_inheritance) {
// FIXME: collect class info from inheritance.
} else if (DDTy->getTag() == dwarf::DW_TAG_friend) {
}
// Skip other unrecognized kinds of elements.
}
-
- return *Info;
+ return Info;
}
TypeIndex CodeViewDebug::lowerTypeClass(const DICompositeType *Ty) {
// contributes to this count, even though the overload group is a single field
// list record.
unsigned MemberCount = 0;
- ClassInfo &Info = collectClassInfo(Ty);
+ ClassInfo Info = collectClassInfo(Ty);
FieldListRecordBuilder Fields;
// Create members.
/// always looked up in the normal TypeIndices map.
DenseMap<const DICompositeType *, codeview::TypeIndex> CompleteTypeIndices;
- /// Map from DICompositeType* to class info.
- DenseMap<const DICompositeType *, std::unique_ptr<ClassInfo>> ClassInfoMap;
const DISubprogram *CurrentSubprogram = nullptr;
// The UDTs we have seen while processing types; each entry is a pair of type
codeview::TypeIndex lowerCompleteTypeUnion(const DICompositeType *Ty);
void collectMemberInfo(ClassInfo &Info, const DIDerivedType *DDTy);
- ClassInfo &collectClassInfo(const DICompositeType *Ty);
+ ClassInfo collectClassInfo(const DICompositeType *Ty);
/// Common record member lowering functionality for record types, which are
/// structs, classes, and unions. Returns the field list index and the member