[llvm] e527986 - [llvm-pdbutil] Fix crashes when TypeIndex is simple or doesn't exist in type stream
Zequan Wu via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 1 11:05:04 PST 2022
Author: Zequan Wu
Date: 2022-03-01T11:04:56-08:00
New Revision: e527986a9c72e0ac5fb69a68bf2a7191bebbb68e
URL: https://github.com/llvm/llvm-project/commit/e527986a9c72e0ac5fb69a68bf2a7191bebbb68e
DIFF: https://github.com/llvm/llvm-project/commit/e527986a9c72e0ac5fb69a68bf2a7191bebbb68e.diff
LOG: [llvm-pdbutil] Fix crashes when TypeIndex is simple or doesn't exist in type stream
- Print simple TypeIndex
- Print error message when type doesn't exist.
Differential Revision: https://reviews.llvm.org/D120692
Added:
Modified:
llvm/test/tools/llvm-pdbutil/partial-type-stream.test
llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-pdbutil/partial-type-stream.test b/llvm/test/tools/llvm-pdbutil/partial-type-stream.test
index 5a72b6266793c..c007465769163 100644
--- a/llvm/test/tools/llvm-pdbutil/partial-type-stream.test
+++ b/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: 0x1019 | LF_MFUNCTION [size = 28]
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
diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
index 0e4f103d08c62..a3502c4b8edca 100644
--- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp
@@ -1352,10 +1352,16 @@ static void dumpPartialTypeStream(LinePrinter &Printer,
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);
+ }
}
}
}
More information about the llvm-commits
mailing list