]> granicus.if.org Git - llvm/commitdiff
[codeview] Use separate records for LF_SUBSTR_LIST and LF_ARGLIST
authorReid Kleckner <rnk@google.com>
Wed, 22 Mar 2017 01:37:38 +0000 (01:37 +0000)
committerReid Kleckner <rnk@google.com>
Wed, 22 Mar 2017 01:37:38 +0000 (01:37 +0000)
They are structurally the same, but now we need to distinguish them
because one record lives in the IPI stream and the other lives in TPI.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298474 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/CodeView/TypeRecord.h
include/llvm/DebugInfo/CodeView/TypeRecords.def
lib/DebugInfo/CodeView/TypeDatabaseVisitor.cpp
lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
lib/DebugInfo/CodeView/TypeRecord.cpp
lib/DebugInfo/CodeView/TypeRecordMapping.cpp
test/DebugInfo/PDB/pdbdump-headers.test
tools/llvm-pdbdump/YamlTypeDumper.cpp

index 0b7c41d864a466b26cdc1f6ecf15f4bfeabb851b..64e30af908a574b2c018b71c303c698377f81d9a 100644 (file)
@@ -236,12 +236,29 @@ public:
   StringRef Name;
 };
 
-// LF_ARGLIST, LF_SUBSTR_LIST
+// LF_ARGLIST
 class ArgListRecord : public TypeRecord {
 public:
   explicit ArgListRecord(TypeRecordKind Kind) : TypeRecord(Kind) {}
 
   ArgListRecord(TypeRecordKind Kind, ArrayRef<TypeIndex> Indices)
+      : TypeRecord(Kind), ArgIndices(Indices) {}
+
+  /// Rewrite member type indices with IndexMap. Returns false if a type index
+  /// is not in the map.
+  bool remapTypeIndices(ArrayRef<TypeIndex> IndexMap);
+
+  ArrayRef<TypeIndex> getIndices() const { return ArgIndices; }
+
+  std::vector<TypeIndex> ArgIndices;
+};
+
+// LF_SUBSTR_LIST
+class StringListRecord : public TypeRecord {
+public:
+  explicit StringListRecord(TypeRecordKind Kind) : TypeRecord(Kind) {}
+
+  StringListRecord(TypeRecordKind Kind, ArrayRef<TypeIndex> Indices)
       : TypeRecord(Kind), StringIndices(Indices) {}
 
   /// Rewrite member type indices with IndexMap. Returns false if a type index
index c98dbac21a7a008ad7dc373cc01ea5c0c7b40355..1ca061d0ac147760b6726a2ec0a8f06008724857 100644 (file)
@@ -79,9 +79,7 @@ MEMBER_RECORD(LF_INDEX, 0x1404, ListContinuation)
 TYPE_RECORD(LF_FUNC_ID, 0x1601, FuncId)
 TYPE_RECORD(LF_MFUNC_ID, 0x1602, MemberFuncId)
 TYPE_RECORD(LF_BUILDINFO, 0x1603, BuildInfo)
-// FIXME: We reuse the structure of ArgListRecord for substring lists, but it
-// makes for confusing dumper output.
-TYPE_RECORD_ALIAS(LF_SUBSTR_LIST, 0x1604, StringList, ArgList)
+TYPE_RECORD(LF_SUBSTR_LIST, 0x1604, StringList)
 TYPE_RECORD(LF_STRING_ID, 0x1605, StringId)
 TYPE_RECORD(LF_UDT_SRC_LINE, 0x1606, UdtSourceLine)
 TYPE_RECORD(LF_UDT_MOD_SRC_LINE, 0x1607, UdtModSourceLine)
index d9d5639021826f94738ef2522d74705ec93f4fc1..4c56ab03644b6b7b925be63121ec1fa042d641e7 100644 (file)
@@ -83,6 +83,22 @@ Error TypeDatabaseVisitor::visitKnownRecord(CVType &CVR, ArgListRecord &Args) {
   return Error::success();
 }
 
+Error TypeDatabaseVisitor::visitKnownRecord(CVType &CVR,
+                                            StringListRecord &Strings) {
+  auto Indices = Strings.getIndices();
+  uint32_t Size = Indices.size();
+  SmallString<256> TypeName("\"");
+  for (uint32_t I = 0; I < Size; ++I) {
+    StringRef ArgTypeName = TypeDB.getTypeName(Indices[I]);
+    TypeName.append(ArgTypeName);
+    if (I + 1 != Size)
+      TypeName.append("\" \"");
+  }
+  TypeName.push_back('\"');
+  Name = TypeDB.saveTypeName(TypeName);
+  return Error::success();
+}
+
 Error TypeDatabaseVisitor::visitKnownRecord(CVType &CVR, ClassRecord &Class) {
   Name = Class.getName();
   return Error::success();
index 636985b7899c1b507e01ebe43d81a4abca988ac5..d4d03482419d90d684d749bdaa3030873ea46e34 100644 (file)
@@ -228,6 +228,17 @@ Error TypeDumpVisitor::visitKnownRecord(CVType &CVR, ArgListRecord &Args) {
   return Error::success();
 }
 
+Error TypeDumpVisitor::visitKnownRecord(CVType &CVR, StringListRecord &Strs) {
+  auto Indices = Strs.getIndices();
+  uint32_t Size = Indices.size();
+  W->printNumber("NumStrings", Size);
+  ListScope Arguments(*W, "Strings");
+  for (uint32_t I = 0; I < Size; ++I) {
+    printTypeIndex("String", Indices[I]);
+  }
+  return Error::success();
+}
+
 Error TypeDumpVisitor::visitKnownRecord(CVType &CVR, ClassRecord &Class) {
   uint16_t Props = static_cast<uint16_t>(Class.getOptions());
   W->printNumber("MemberCount", Class.getMemberCount());
index 386694a611a76ae391e3701bce3e3fc9e686bffa..6482f291898f7ebba1f47625bcc20647be73d133 100644 (file)
@@ -64,6 +64,13 @@ bool MemberFuncIdRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
 }
 
 bool ArgListRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
+  bool Success = true;
+  for (TypeIndex &Arg : ArgIndices)
+    Success &= remapIndex(IndexMap, Arg);
+  return Success;
+}
+
+bool StringListRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
   bool Success = true;
   for (TypeIndex &Str : StringIndices)
     Success &= remapIndex(IndexMap, Str);
index 2e1ee978f47aeaff2a25d50488345450cf538446..a81caed8a37ca5dc2526e2579623e3882f2baa75 100644 (file)
@@ -170,6 +170,15 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR,
 }
 
 Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ArgListRecord &Record) {
+  error(IO.mapVectorN<uint32_t>(
+      Record.ArgIndices,
+      [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N); }));
+
+  return Error::success();
+}
+
+Error TypeRecordMapping::visitKnownRecord(CVType &CVR,
+                                          StringListRecord &Record) {
   error(IO.mapVectorN<uint32_t>(
       Record.StringIndices,
       [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N); }));
index c10d866f4a831cae23a535c464f62c9b96a7a3db..ec661344a8412417afba5648ec91d38c347c2c9d 100644 (file)
 ; ALL:     {
 ; ALL:       StringList (0x1057) {
 ; ALL:         TypeLeafKind: LF_SUBSTR_LIST (0x1604)
-; ALL:         NumArgs: 1
-; ALL:         Arguments [
-; ALL:           ArgType: __vc_attributes::threadingAttribute (0x100B)
+; ALL:         NumStrings: 1
+; ALL:         Strings [
+; ALL:           String: __vc_attributes::threadingAttribute (0x100B)
 ; ALL:         ]
 ; ALL:       }
 ; ALL:     }
index e2b901be868eaab46a46bc009b194aae777d3a8c..c7ad02b746eee91cb3777b8eeff5f3aeac082f6c 100644 (file)
@@ -291,7 +291,11 @@ void MappingTraits<StringIdRecord>::mapping(IO &IO, StringIdRecord &String) {
 }
 
 void MappingTraits<ArgListRecord>::mapping(IO &IO, ArgListRecord &Args) {
-  IO.mapRequired("ArgIndices", Args.StringIndices);
+  IO.mapRequired("ArgIndices", Args.ArgIndices);
+}
+
+void MappingTraits<StringListRecord>::mapping(IO &IO, StringListRecord &Strings) {
+  IO.mapRequired("StringIndices", Strings.StringIndices);
 }
 
 void MappingTraits<ClassRecord>::mapping(IO &IO, ClassRecord &Class) {