summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter
diff options
context:
space:
mode:
authorAdrian McCarthy <amccarth@google.com>2016-07-06 19:49:51 +0000
committerAdrian McCarthy <amccarth@google.com>2016-07-06 19:49:51 +0000
commit820ca5404ce9b919ad9be94049298bcec81ce3fa (patch)
treeb364997a30741ccd4ac7b8e22b15036c3d2b159a /llvm/lib/CodeGen/AsmPrinter
parentdcfce2d0ecb1508b9ebe32aade343e3595213bd6 (diff)
downloadbcm5719-llvm-820ca5404ce9b919ad9be94049298bcec81ce3fa.tar.gz
bcm5719-llvm-820ca5404ce9b919ad9be94049298bcec81ce3fa.zip
Retry: "Emit CodeView type records for nested classes."
Now with a corrected test to account for a recently supported properties bit in the debug info of a struct. Original review: http://reviews.llvm.org/D21939 This reverts commit 970c3fd497a28d25dd69526eb52594a696c37968. llvm-svn: 274661
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp34
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h2
2 files changed, 29 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index bd4df879d5f..fe63b7043c5 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1414,6 +1414,8 @@ struct llvm::ClassInfo {
MemberList Members;
// Direct overloaded methods gathered by name.
MethodsMap Methods;
+
+ std::vector<const DICompositeType *> NestedClasses;
};
void CodeViewDebug::clear() {
@@ -1466,8 +1468,8 @@ ClassInfo CodeViewDebug::collectClassInfo(const DICompositeType *Ty) {
// friends in the past, but modern versions do not.
}
// FIXME: Get Clang to emit function virtual table here and handle it.
- // FIXME: Get clang to emit nested types here and do something with
- // them.
+ } else if (auto *Composite = dyn_cast<DICompositeType>(Element)) {
+ Info.NestedClasses.push_back(Composite);
}
// Skip other unrecognized kinds of elements.
}
@@ -1496,7 +1498,12 @@ TypeIndex CodeViewDebug::lowerCompleteTypeClass(const DICompositeType *Ty) {
TypeIndex FieldTI;
TypeIndex VShapeTI;
unsigned FieldCount;
- std::tie(FieldTI, VShapeTI, FieldCount) = lowerRecordFieldList(Ty);
+ bool ContainsNestedClass;
+ std::tie(FieldTI, VShapeTI, FieldCount, ContainsNestedClass) =
+ lowerRecordFieldList(Ty);
+
+ if (ContainsNestedClass)
+ CO |= ClassOptions::ContainsNestedClass;
std::string FullName = getFullyQualifiedName(Ty);
@@ -1532,7 +1539,13 @@ TypeIndex CodeViewDebug::lowerCompleteTypeUnion(const DICompositeType *Ty) {
ClassOptions CO = getCommonClassOptions(Ty);
TypeIndex FieldTI;
unsigned FieldCount;
- std::tie(FieldTI, std::ignore, FieldCount) = lowerRecordFieldList(Ty);
+ bool ContainsNestedClass;
+ std::tie(FieldTI, std::ignore, FieldCount, ContainsNestedClass) =
+ lowerRecordFieldList(Ty);
+
+ if (ContainsNestedClass)
+ CO |= ClassOptions::ContainsNestedClass;
+
uint64_t SizeInBytes = Ty->getSizeInBits() / 8;
std::string FullName = getFullyQualifiedName(Ty);
@@ -1550,7 +1563,7 @@ TypeIndex CodeViewDebug::lowerCompleteTypeUnion(const DICompositeType *Ty) {
return UnionTI;
}
-std::tuple<TypeIndex, TypeIndex, unsigned>
+std::tuple<TypeIndex, TypeIndex, unsigned, bool>
CodeViewDebug::lowerRecordFieldList(const DICompositeType *Ty) {
// Manually count members. MSVC appears to count everything that generates a
// field list record. Each individual overload in a method overload group
@@ -1645,8 +1658,17 @@ CodeViewDebug::lowerRecordFieldList(const DICompositeType *Ty) {
OverloadedMethodRecord(Methods.size(), MethodList, Name));
}
}
+
+ // Create nested classes.
+ for (const DICompositeType *Nested : Info.NestedClasses) {
+ NestedTypeRecord R(getTypeIndex(DITypeRef(Nested)), Nested->getName());
+ Fields.writeNestedType(R);
+ MemberCount++;
+ }
+
TypeIndex FieldTI = TypeTable.writeFieldList(Fields);
- return std::make_tuple(FieldTI, TypeIndex(), MemberCount);
+ return std::make_tuple(FieldTI, TypeIndex(), MemberCount,
+ !Info.NestedClasses.empty());
}
TypeIndex CodeViewDebug::getVBPTypeIndex() {
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
index 51dd5df1027..31da1b11fa4 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
@@ -275,7 +275,7 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase {
/// Common record member lowering functionality for record types, which are
/// structs, classes, and unions. Returns the field list index and the member
/// count.
- std::tuple<codeview::TypeIndex, codeview::TypeIndex, unsigned>
+ std::tuple<codeview::TypeIndex, codeview::TypeIndex, unsigned, bool>
lowerRecordFieldList(const DICompositeType *Ty);
/// Inserts {{Node, ClassTy}, TI} into TypeIndices and checks for duplicates.
OpenPOWER on IntegriCloud