Generate codeview for array type metadata.

Differential Revision: http://reviews.llvm.org/D21107

llvm-svn: 272187
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index db1dc51..530b1fe 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -726,6 +726,8 @@
 TypeIndex CodeViewDebug::lowerType(const DIType *Ty) {
   // Generic dispatch for lowering an unknown type.
   switch (Ty->getTag()) {
+  case dwarf::DW_TAG_array_type:
+    return lowerTypeArray(cast<DICompositeType>(Ty));
   case dwarf::DW_TAG_typedef:
     return lowerTypeAlias(cast<DIDerivedType>(Ty));
   case dwarf::DW_TAG_base_type:
@@ -765,6 +767,18 @@
   return UnderlyingTypeIndex;
 }
 
+TypeIndex CodeViewDebug::lowerTypeArray(const DICompositeType *Ty) {
+  DITypeRef ElementTypeRef = Ty->getBaseType();
+  TypeIndex ElementTypeIndex = getTypeIndex(ElementTypeRef);
+  // IndexType is size_t, which depends on the bitness of the target.
+  TypeIndex IndexType = Asm->MAI->getPointerSize() == 8
+                            ? TypeIndex(SimpleTypeKind::UInt64Quad)
+                            : TypeIndex(SimpleTypeKind::UInt32Long);
+  uint64_t Size = Ty->getSizeInBits() / 8;
+  ArrayRecord Record(ElementTypeIndex, IndexType, Size, Ty->getName());
+  return TypeTable.writeArray(Record);
+}
+
 TypeIndex CodeViewDebug::lowerTypeBasic(const DIBasicType *Ty) {
   TypeIndex Index;
   dwarf::TypeKind Kind;