[PATCH] D120692: [llvm-pdbutil] Fix crashes when TypeIndex is simple or doesn't exist in type stream

Zequan Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 1 11:05:17 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe527986a9c72: [llvm-pdbutil] Fix crashes when TypeIndex is simple or doesn't exist in type… (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120692/new/

https://reviews.llvm.org/D120692

Files:
  llvm/test/tools/llvm-pdbutil/partial-type-stream.test
  llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp


Index: llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
===================================================================
--- llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
+++ llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
@@ -1352,10 +1352,16 @@
 
     for (const auto &I : TiList) {
       TypeIndex TI(I);
-      CVType Type = Types.getType(TI);
-      if (auto EC = codeview::visitTypeRecord(Type, TI, V))
-        Printer.formatLine("An error occurred dumping type record {0}: {1}", TI,
-                           toString(std::move(EC)));
+      if (TI.isSimple()) {
+        Printer.formatLine("{0} | {1}", fmt_align(I, AlignStyle::Right, Width),
+                           Types.getTypeName(TI));
+      } else if (Optional<CVType> Type = Types.tryGetType(TI)) {
+        if (auto EC = codeview::visitTypeRecord(*Type, TI, V))
+          Printer.formatLine("An error occurred dumping type record {0}: {1}",
+                             TI, toString(std::move(EC)));
+      } else {
+        Printer.formatLine("Type {0} doesn't exist in TPI stream", TI);
+      }
     }
   }
 }
Index: llvm/test/tools/llvm-pdbutil/partial-type-stream.test
===================================================================
--- llvm/test/tools/llvm-pdbutil/partial-type-stream.test
+++ llvm/test/tools/llvm-pdbutil/partial-type-stream.test
@@ -2,6 +2,8 @@
 ; RUN:     | FileCheck --check-prefix=NODEPS %s
 ; RUN: llvm-pdbutil dump -type-index=0x1019 -dependents -dont-resolve-forward-refs \
 ; RUN:     %p/Inputs/ClassLayoutTest.pdb | FileCheck --check-prefix=DEPS %s
+; RUN: llvm-pdbutil dump -type-index=0x3,0x30,0x44,0x74 \
+; RUN:     %p/Inputs/ClassLayoutTest.pdb | FileCheck --check-prefix=SIMPLE %s 
 
 
 NODEPS:                          Types (TPI Stream)
@@ -27,3 +29,12 @@
 DEPS-NEXT:            return type = 0x0003 (void), # args = 0, param list = 0x100E
 DEPS-NEXT:            class type = 0x1017, this type = 0x1018, this adjust = 0
 DEPS-NEXT:            calling conv = thiscall, options = None
+
+
+SIMPLE:                          Types (TPI Stream)
+SIMPLE-NEXT: ============================================================
+SIMPLE-NEXT:   Showing 4 records.
+SIMPLE-NEXT:   0x0003 (void) | void
+SIMPLE-NEXT:   0x0030 (bool) | bool
+SIMPLE-NEXT:   0x0044 (__float48) | __float48
+SIMPLE-NEXT:   0x0074 (int) | int


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120692.412169.patch
Type: text/x-patch
Size: 2320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220301/b174bc00/attachment.bin>


More information about the llvm-commits mailing list