diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-22 19:43:28 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-22 19:43:28 +0000 | 
| commit | b5630dbadf9a2a06754194387d6b0fd9962a67f1 (patch) | |
| tree | 3fe1e2bc0dc2823ab21f06959fbb3eaca317ea29 /lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | |
| parent | 7af96fb3afd6725a2824a0a5ca5dad34e5e0b056 (diff) | |
Notes
Diffstat (limited to 'lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
| -rw-r--r-- | lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 41 | 
1 files changed, 13 insertions, 28 deletions
| diff --git a/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 7d945690e9c3..1b39e46ee466 100644 --- a/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -13,7 +13,6 @@  #include "CodeViewDebug.h"  #include "llvm/ADT/TinyPtrVector.h" -#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"  #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"  #include "llvm/DebugInfo/CodeView/CodeView.h"  #include "llvm/DebugInfo/CodeView/Line.h" @@ -23,6 +22,7 @@  #include "llvm/DebugInfo/CodeView/TypeDumpVisitor.h"  #include "llvm/DebugInfo/CodeView/TypeIndex.h"  #include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/CodeView/TypeTableCollection.h"  #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"  #include "llvm/IR/Constants.h"  #include "llvm/MC/MCAsmInfo.h" @@ -469,17 +469,21 @@ void CodeViewDebug::emitTypeInformation() {      CommentPrefix += ' ';    } -  TypeDatabase TypeDB(TypeTable.records().size()); -  CVTypeDumper CVTD(TypeDB); -  TypeTable.ForEachRecord([&](TypeIndex Index, ArrayRef<uint8_t> Record) { +  TypeTableCollection Table(TypeTable.records()); +  Optional<TypeIndex> B = Table.getFirst(); +  while (B) { +    // This will fail if the record data is invalid. +    CVType Record = Table.getType(*B); +      if (OS.isVerboseAsm()) {        // Emit a block comment describing the type record for readability.        SmallString<512> CommentBlock;        raw_svector_ostream CommentOS(CommentBlock);        ScopedPrinter SP(CommentOS);        SP.setPrefix(CommentPrefix); -      TypeDumpVisitor TDV(TypeDB, &SP, false); -      Error E = CVTD.dump(Record, TDV); +      TypeDumpVisitor TDV(Table, &SP, false); + +      Error E = codeview::visitTypeRecord(Record, *B, TDV);        if (E) {          logAllUnhandledErrors(std::move(E), errs(), "error: ");          llvm_unreachable("produced malformed type record"); @@ -489,29 +493,10 @@ void CodeViewDebug::emitTypeInformation() {        // newline.        OS.emitRawComment(            CommentOS.str().drop_front(CommentPrefix.size() - 1).rtrim()); -    } else { -#ifndef NDEBUG -      // Assert that the type data is valid even if we aren't dumping -      // comments. The MSVC linker doesn't do much type record validation, -      // so the first link of an invalid type record can succeed while -      // subsequent links will fail with LNK1285. -      BinaryByteStream Stream(Record, llvm::support::little); -      CVTypeArray Types; -      BinaryStreamReader Reader(Stream); -      Error E = Reader.readArray(Types, Reader.getLength()); -      if (!E) { -        TypeVisitorCallbacks C; -        E = codeview::visitTypeStream(Types, C); -      } -      if (E) { -        logAllUnhandledErrors(std::move(E), errs(), "error: "); -        llvm_unreachable("produced malformed type record"); -      } -#endif      } -    StringRef S(reinterpret_cast<const char *>(Record.data()), Record.size()); -    OS.EmitBinaryData(S); -  }); +    OS.EmitBinaryData(Record.str_data()); +    B = Table.getNext(*B); +  }  }  namespace { | 
