OSDN Git Service

Don't crash in llvm-pdbutil when dumping TypeIndexes with high bit set.
authorZachary Turner <zturner@google.com>
Fri, 15 Dec 2017 00:27:49 +0000 (00:27 +0000)
committerZachary Turner <zturner@google.com>
Fri, 15 Dec 2017 00:27:49 +0000 (00:27 +0000)
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

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

index e0c2226..c71281d 100644 (file)
@@ -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(); }
 
index 48c7165..40a0e46 100644 (file)
@@ -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);