From: Zachary Turner Date: Fri, 15 Dec 2017 00:27:49 +0000 (+0000) Subject: Don't crash in llvm-pdbutil when dumping TypeIndexes with high bit set. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1764ef1f3a7e3df710e492ab0b53fe50b1273ce1;p=llvm Don't crash in llvm-pdbutil when dumping TypeIndexes with high bit set. This is a special code that indicates that it's a function id. While I'm still not certain how to interpret these, we definitely should *not* be using these values as indices into an array directly. For now, when we encounter one of these, just print the numeric value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320775 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/DebugInfo/CodeView/TypeIndex.h b/include/llvm/DebugInfo/CodeView/TypeIndex.h index e0c2226bdbd..c71281de714 100644 --- a/include/llvm/DebugInfo/CodeView/TypeIndex.h +++ b/include/llvm/DebugInfo/CodeView/TypeIndex.h @@ -98,6 +98,7 @@ public: static const uint32_t FirstNonSimpleIndex = 0x1000; static const uint32_t SimpleKindMask = 0x000000ff; static const uint32_t SimpleModeMask = 0x00000700; + static const uint32_t DecoratedItemIdMask = 0x80000000; public: TypeIndex() : Index(static_cast(SimpleTypeKind::None)) {} @@ -110,6 +111,7 @@ public: uint32_t getIndex() const { return Index; } void setIndex(uint32_t I) { Index = I; } bool isSimple() const { return Index < FirstNonSimpleIndex; } + bool isDecoratedItemId() const { return !!(Index & DecoratedItemIdMask); } bool isNoneType() const { return *this == None(); } diff --git a/tools/llvm-pdbutil/MinimalSymbolDumper.cpp b/tools/llvm-pdbutil/MinimalSymbolDumper.cpp index 48c71652d9e..40a0e46efd4 100644 --- a/tools/llvm-pdbutil/MinimalSymbolDumper.cpp +++ b/tools/llvm-pdbutil/MinimalSymbolDumper.cpp @@ -337,7 +337,7 @@ Error MinimalSymbolDumper::visitSymbolEnd(CVSymbol &Record) { std::string MinimalSymbolDumper::typeOrIdIndex(codeview::TypeIndex TI, bool IsType) const { - if (TI.isSimple()) + if (TI.isSimple() || TI.isDecoratedItemId()) return formatv("{0}", TI).str(); auto &Container = IsType ? Types : Ids; StringRef Name = Container.getTypeName(TI);