[codeview] Emit nested enums and typedefs from classes
Previously we limited ourselves to only emitting nested classes, but we
need other kinds of types as well.
This fixes the Visual Studio STL visualizers, so that users can
visualize std::string and other objects.
llvm-svn: 310410
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 833e5ba..4346803 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1655,7 +1655,7 @@
TypeIndex VShapeTI;
- std::vector<const DICompositeType *> NestedClasses;
+ std::vector<const DIType *> NestedTypes;
};
void CodeViewDebug::clear() {
@@ -1706,12 +1706,14 @@
} else if (DDTy->getTag() == dwarf::DW_TAG_pointer_type &&
DDTy->getName() == "__vtbl_ptr_type") {
Info.VShapeTI = getTypeIndex(DDTy);
+ } else if (DDTy->getTag() == dwarf::DW_TAG_typedef) {
+ Info.NestedTypes.push_back(DDTy);
} else if (DDTy->getTag() == dwarf::DW_TAG_friend) {
// Ignore friend members. It appears that MSVC emitted info about
// friends in the past, but modern versions do not.
}
} else if (auto *Composite = dyn_cast<DICompositeType>(Element)) {
- Info.NestedClasses.push_back(Composite);
+ Info.NestedTypes.push_back(Composite);
}
// Skip other unrecognized kinds of elements.
}
@@ -1920,7 +1922,7 @@
}
// Create nested classes.
- for (const DICompositeType *Nested : Info.NestedClasses) {
+ for (const DIType *Nested : Info.NestedTypes) {
NestedTypeRecord R(getTypeIndex(DITypeRef(Nested)), Nested->getName());
FLBR.writeMemberType(R);
MemberCount++;
@@ -1928,7 +1930,7 @@
TypeIndex FieldTI = FLBR.end(true);
return std::make_tuple(FieldTI, Info.VShapeTI, MemberCount,
- !Info.NestedClasses.empty());
+ !Info.NestedTypes.empty());
}
TypeIndex CodeViewDebug::getVBPTypeIndex() {