[codeview] Add classes and unions to the Local/Global UDTs lists
Differential Revision: http://reviews.llvm.org/D21655
llvm-svn: 273626
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 4c46e51..ed06c5a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -829,6 +829,27 @@
}
}
+void CodeViewDebug::addToUDTs(const DIType *Ty, TypeIndex TI) {
+ SmallVector<StringRef, 5> QualifiedNameComponents;
+ const DISubprogram *ClosestSubprogram = getQualifiedNameComponents(
+ Ty->getScope().resolve(), QualifiedNameComponents);
+
+ std::string FullyQualifiedName =
+ getQualifiedName(QualifiedNameComponents, Ty->getName());
+
+ if (ClosestSubprogram == nullptr)
+ GlobalUDTs.emplace_back(std::move(FullyQualifiedName), TI);
+ else if (ClosestSubprogram == CurrentSubprogram)
+ LocalUDTs.emplace_back(std::move(FullyQualifiedName), TI);
+
+ // TODO: What if the ClosestSubprogram is neither null or the current
+ // subprogram? Currently, the UDT just gets dropped on the floor.
+ //
+ // The current behavior is not desirable. To get maximal fidelity, we would
+ // need to perform all type translation before beginning emission of .debug$S
+ // and then make LocalUDTs a member of FunctionInfo
+}
+
TypeIndex CodeViewDebug::lowerType(const DIType *Ty, const DIType *ClassTy) {
// Generic dispatch for lowering an unknown type.
switch (Ty->getTag()) {
@@ -873,25 +894,7 @@
TypeIndex UnderlyingTypeIndex = getTypeIndex(UnderlyingTypeRef);
StringRef TypeName = Ty->getName();
- SmallVector<StringRef, 5> QualifiedNameComponents;
- const DISubprogram *ClosestSubprogram = getQualifiedNameComponents(
- Ty->getScope().resolve(), QualifiedNameComponents);
-
- if (ClosestSubprogram == nullptr) {
- std::string FullyQualifiedName =
- getQualifiedName(QualifiedNameComponents, TypeName);
- GlobalUDTs.emplace_back(std::move(FullyQualifiedName), UnderlyingTypeIndex);
- } else if (ClosestSubprogram == CurrentSubprogram) {
- std::string FullyQualifiedName =
- getQualifiedName(QualifiedNameComponents, TypeName);
- LocalUDTs.emplace_back(std::move(FullyQualifiedName), UnderlyingTypeIndex);
- }
- // TODO: What if the ClosestSubprogram is neither null or the current
- // subprogram? Currently, the UDT just gets dropped on the floor.
- //
- // The current behavior is not desirable. To get maximal fidelity, we would
- // need to perform all type translation before beginning emission of .debug$S
- // and then make LocalUDTs a member of FunctionInfo
+ addToUDTs(Ty, UnderlyingTypeIndex);
if (UnderlyingTypeIndex == TypeIndex(SimpleTypeKind::Int32Long) &&
TypeName == "HRESULT")
@@ -899,6 +902,7 @@
if (UnderlyingTypeIndex == TypeIndex(SimpleTypeKind::UInt16Short) &&
TypeName == "wchar_t")
return TypeIndex(SimpleTypeKind::WideCharacter);
+
return UnderlyingTypeIndex;
}
@@ -1419,6 +1423,8 @@
TypeIndex(0x0), getFullFilepath(Ty->getFile()))),
Ty->getLine()));
+ addToUDTs(Ty, ClassTI);
+
return ClassTI;
}
@@ -1453,6 +1459,8 @@
TypeIndex(0x0), getFullFilepath(Ty->getFile()))),
Ty->getLine()));
+ addToUDTs(Ty, UnionTI);
+
return UnionTI;
}