]> granicus.if.org Git - llvm/commitdiff
Don't crash if a type record can't be found.
authorZachary Turner <zturner@google.com>
Sat, 17 Jun 2017 00:02:24 +0000 (00:02 +0000)
committerZachary Turner <zturner@google.com>
Sat, 17 Jun 2017 00:02:24 +0000 (00:02 +0000)
This was a regression introduced in a previous patch.  Adding
back the code that handles this case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305617 91177308-0d34-0410-b5e6-96231b3b80d8

lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp

index 9b5871e7eaf8e44c78859028111fd0d5a7ea3cb4..551963ea306e68c1bec096661e0654c7e560fd1c 100644 (file)
@@ -75,6 +75,15 @@ StringRef LazyRandomTypeCollection::getTypeName(TypeIndex Index) {
   if (Index.isNoneType() || Index.isSimple())
     return TypeIndex::simpleTypeName(Index);
 
+  // Try to make sure the type exists.  Even if it doesn't though, it may be
+  // because we're dumping a symbol stream with no corresponding type stream
+  // present, in which case we still want to be able to print <unknown UDT>
+  // for the type names.
+  if (auto EC = ensureTypeExists(Index)) {
+    consumeError(std::move(EC));
+    return "<unknown UDT>";
+  }
+
   uint32_t I = Index.toArrayIndex();
   if (I >= TypeNames.size())
     TypeNames.resize(I + 1);