[llvm] r320775 - Don't crash in llvm-pdbutil when dumping TypeIndexes with high bit set.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 16:27:49 PST 2017


Author: zturner
Date: Thu Dec 14 16:27:49 2017
New Revision: 320775

URL: http://llvm.org/viewvc/llvm-project?rev=320775&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/DebugInfo/CodeView/TypeIndex.h
    llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeIndex.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeIndex.h?rev=320775&r1=320774&r2=320775&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeIndex.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeIndex.h Thu Dec 14 16:27:49 2017
@@ -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<uint32_t>(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(); }
 

Modified: llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp?rev=320775&r1=320774&r2=320775&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/MinimalSymbolDumper.cpp Thu Dec 14 16:27:49 2017
@@ -337,7 +337,7 @@ Error MinimalSymbolDumper::visitSymbolEn
 
 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);




More information about the llvm-commits mailing list