summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-05-19 05:57:45 +0000
committerZachary Turner <zturner@google.com>2017-05-19 05:57:45 +0000
commit1dfcf8d92c808bd9fcb4d1a0d81582453f80c423 (patch)
tree611a9e1848ebefa1e5a9e22f6939c0482b8ee05e /llvm/lib
parent47fdc73771c39a83d97b8eb142dd311eb773e541 (diff)
downloadbcm5719-llvm-1dfcf8d92c808bd9fcb4d1a0d81582453f80c423.tar.gz
bcm5719-llvm-1dfcf8d92c808bd9fcb4d1a0d81582453f80c423.zip
Revert "[CodeView] Provide a common interface for type collections."
This is a squash of ~5 reverts of, well, pretty much everything I did today. Something is seriously broken with lit on Windows right now, and as a result assertions that fire in tests are triggering failures. I've been breaking non-Windows bots all day which has seriously confused me because all my tests have been passing, and after running lit with -a to view the output even on successful runs, I find out that the tool is crashing and yet lit is still reporting it as a success! At this point I don't even know where to start, so rather than leave the tree broken for who knows how long, I will get this back to green, and then once lit is fixed on Windows, hopefully hopefully fix the remaining set of problems for real. llvm-svn: 303409
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp40
-rw-r--r--llvm/lib/DebugInfo/CodeView/CMakeLists.txt7
-rw-r--r--llvm/lib/DebugInfo/CodeView/CVTypeDumper.cpp61
-rw-r--r--llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp190
-rw-r--r--llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp226
-rw-r--r--llvm/lib/DebugInfo/CodeView/RandomAccessTypeVisitor.cpp89
-rw-r--r--llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp13
-rw-r--r--llvm/lib/DebugInfo/CodeView/TypeDatabase.cpp74
-rw-r--r--llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp13
-rw-r--r--llvm/lib/DebugInfo/CodeView/TypeIndex.cpp27
-rw-r--r--llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp2
-rw-r--r--llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp82
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp1
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp3
14 files changed, 283 insertions, 545 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index ae14e000c38..7d945690e9c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -13,6 +13,7 @@
#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"
@@ -22,7 +23,6 @@
#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,21 +469,17 @@ void CodeViewDebug::emitTypeInformation() {
CommentPrefix += ' ';
}
- TypeTableCollection Table(TypeTable.records());
- Optional<TypeIndex> B = Table.getFirst();
- do {
- // This will fail if the record data is invalid.
- CVType Record = Table.getType(*B);
-
+ TypeDatabase TypeDB(TypeTable.records().size());
+ CVTypeDumper CVTD(TypeDB);
+ TypeTable.ForEachRecord([&](TypeIndex Index, ArrayRef<uint8_t> Record) {
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(Table, &SP, false);
-
- Error E = codeview::visitTypeRecord(Record, *B, TDV);
+ TypeDumpVisitor TDV(TypeDB, &SP, false);
+ Error E = CVTD.dump(Record, TDV);
if (E) {
logAllUnhandledErrors(std::move(E), errs(), "error: ");
llvm_unreachable("produced malformed type record");
@@ -493,9 +489,29 @@ 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
}
- OS.EmitBinaryData(Record.str_data());
- } while ((B = Table.getNext(*B)));
+ StringRef S(reinterpret_cast<const char *>(Record.data()), Record.size());
+ OS.EmitBinaryData(S);
+ });
}
namespace {
diff --git a/llvm/lib/DebugInfo/CodeView/CMakeLists.txt b/llvm/lib/DebugInfo/CodeView/CMakeLists.txt
index 556ebf78622..8d9353ae5f5 100644
--- a/llvm/lib/DebugInfo/CodeView/CMakeLists.txt
+++ b/llvm/lib/DebugInfo/CodeView/CMakeLists.txt
@@ -2,10 +2,10 @@ add_llvm_library(LLVMDebugInfoCodeView
CodeViewError.cpp
CodeViewRecordIO.cpp
CVSymbolVisitor.cpp
+ CVTypeDumper.cpp
CVTypeVisitor.cpp
EnumTables.cpp
Formatters.cpp
- LazyRandomTypeCollection.cpp
Line.cpp
ModuleDebugFileChecksumFragment.cpp
ModuleDebugFragment.cpp
@@ -13,6 +13,7 @@ add_llvm_library(LLVMDebugInfoCodeView
ModuleDebugFragmentVisitor.cpp
ModuleDebugInlineeLinesFragment.cpp
ModuleDebugLineFragment.cpp
+ RandomAccessTypeVisitor.cpp
RecordSerialization.cpp
StringTable.cpp
SymbolRecordMapping.cpp
@@ -21,12 +22,10 @@ add_llvm_library(LLVMDebugInfoCodeView
TypeDatabase.cpp
TypeDatabaseVisitor.cpp
TypeDumpVisitor.cpp
- TypeIndex.cpp
TypeRecordMapping.cpp
TypeSerializer.cpp
TypeStreamMerger.cpp
- TypeTableCollection.cpp
-
+
ADDITIONAL_HEADER_DIRS
${LLVM_MAIN_INCLUDE_DIR}/llvm/DebugInfo/CodeView
)
diff --git a/llvm/lib/DebugInfo/CodeView/CVTypeDumper.cpp b/llvm/lib/DebugInfo/CodeView/CVTypeDumper.cpp
new file mode 100644
index 00000000000..02e1682f76e
--- /dev/null
+++ b/llvm/lib/DebugInfo/CodeView/CVTypeDumper.cpp
@@ -0,0 +1,61 @@
+//===-- CVTypeDumper.cpp - CodeView type info dumper ------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
+#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
+#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
+#include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
+#include "llvm/DebugInfo/CodeView/TypeRecord.h"
+#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
+#include "llvm/Support/BinaryByteStream.h"
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+Error CVTypeDumper::dump(const CVType &Record, TypeVisitorCallbacks &Dumper) {
+ TypeDatabaseVisitor DBV(TypeDB);
+ TypeVisitorCallbackPipeline Pipeline;
+ Pipeline.addCallbackToPipeline(DBV);
+ Pipeline.addCallbackToPipeline(Dumper);
+
+ CVType RecordCopy = Record;
+ return codeview::visitTypeRecord(RecordCopy, Pipeline, VDS_BytesPresent,
+ Handler);
+}
+
+Error CVTypeDumper::dump(const CVTypeArray &Types,
+ TypeVisitorCallbacks &Dumper) {
+ TypeDatabaseVisitor DBV(TypeDB);
+ TypeVisitorCallbackPipeline Pipeline;
+ Pipeline.addCallbackToPipeline(DBV);
+ Pipeline.addCallbackToPipeline(Dumper);
+
+ return codeview::visitTypeStream(Types, Pipeline, Handler);
+}
+
+Error CVTypeDumper::dump(ArrayRef<uint8_t> Data, TypeVisitorCallbacks &Dumper) {
+ BinaryByteStream Stream(Data, llvm::support::little);
+ CVTypeArray Types;
+ BinaryStreamReader Reader(Stream);
+ if (auto EC = Reader.readArray(Types, Reader.getLength()))
+ return EC;
+
+ return dump(Types, Dumper);
+}
+
+void CVTypeDumper::printTypeIndex(ScopedPrinter &Printer, StringRef FieldName,
+ TypeIndex TI, TypeDatabase &DB) {
+ StringRef TypeName;
+ if (!TI.isNoneType())
+ TypeName = DB.getTypeName(TI);
+ if (!TypeName.empty())
+ Printer.printHex(FieldName, TypeName, TI.getIndex());
+ else
+ Printer.printHex(FieldName, TI.getIndex());
+}
diff --git a/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp b/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
index e8d967b6389..0f7f5f66779 100644
--- a/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
+++ b/llvm/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
@@ -9,9 +9,7 @@
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
-#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
-#include "llvm/DebugInfo/CodeView/TypeCollection.h"
#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
#include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
@@ -24,6 +22,8 @@
using namespace llvm;
using namespace llvm::codeview;
+CVTypeVisitor::CVTypeVisitor(TypeVisitorCallbacks &Callbacks)
+ : Callbacks(Callbacks) {}
template <typename T>
static Error visitKnownRecord(CVType &Record, TypeVisitorCallbacks &Callbacks) {
@@ -66,67 +66,6 @@ static Expected<TypeServer2Record> deserializeTypeServerRecord(CVType &Record) {
return R;
}
-static Error visitMemberRecord(CVMemberRecord &Record,
- TypeVisitorCallbacks &Callbacks) {
- if (auto EC = Callbacks.visitMemberBegin(Record))
- return EC;
-
- switch (Record.Kind) {
- default:
- if (auto EC = Callbacks.visitUnknownMember(Record))
- return EC;
- break;
-#define MEMBER_RECORD(EnumName, EnumVal, Name) \
- case EnumName: { \
- if (auto EC = visitKnownMember<Name##Record>(Record, Callbacks)) \
- return EC; \
- break; \
- }
-#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) \
- MEMBER_RECORD(EnumVal, EnumVal, AliasName)
-#define TYPE_RECORD(EnumName, EnumVal, Name)
-#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#include "llvm/DebugInfo/CodeView/TypeRecords.def"
- }
-
- if (auto EC = Callbacks.visitMemberEnd(Record))
- return EC;
-
- return Error::success();
-}
-
-namespace {
-
-class CVTypeVisitor {
-public:
- explicit CVTypeVisitor(TypeVisitorCallbacks &Callbacks);
-
- void addTypeServerHandler(TypeServerHandler &Handler);
-
- Error visitTypeRecord(CVType &Record, TypeIndex Index);
- Error visitTypeRecord(CVType &Record);
-
- /// Visits the type records in Data. Sets the error flag on parse failures.
- Error visitTypeStream(const CVTypeArray &Types);
- Error visitTypeStream(CVTypeRange Types);
- Error visitTypeStream(TypeCollection &Types);
-
- Error visitMemberRecord(CVMemberRecord Record);
- Error visitFieldListMemberStream(BinaryStreamReader &Stream);
-
-private:
- Expected<bool> handleTypeServer(CVType &Record);
- Error finishVisitation(CVType &Record);
-
- /// The interface to the class that gets notified of each visitation.
- TypeVisitorCallbacks &Callbacks;
-
- TinyPtrVector<TypeServerHandler *> Handlers;
-};
-
-CVTypeVisitor::CVTypeVisitor(TypeVisitorCallbacks &Callbacks)
- : Callbacks(Callbacks) {}
-
void CVTypeVisitor::addTypeServerHandler(TypeServerHandler &Handler) {
Handlers.push_back(&Handler);
}
@@ -205,6 +144,35 @@ Error CVTypeVisitor::visitTypeRecord(CVType &Record) {
return finishVisitation(Record);
}
+static Error visitMemberRecord(CVMemberRecord &Record,
+ TypeVisitorCallbacks &Callbacks) {
+ if (auto EC = Callbacks.visitMemberBegin(Record))
+ return EC;
+
+ switch (Record.Kind) {
+ default:
+ if (auto EC = Callbacks.visitUnknownMember(Record))
+ return EC;
+ break;
+#define MEMBER_RECORD(EnumName, EnumVal, Name) \
+ case EnumName: { \
+ if (auto EC = visitKnownMember<Name##Record>(Record, Callbacks)) \
+ return EC; \
+ break; \
+ }
+#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) \
+ MEMBER_RECORD(EnumVal, EnumVal, AliasName)
+#define TYPE_RECORD(EnumName, EnumVal, Name)
+#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#include "llvm/DebugInfo/CodeView/TypeRecords.def"
+ }
+
+ if (auto EC = Callbacks.visitMemberEnd(Record))
+ return EC;
+
+ return Error::success();
+}
+
Error CVTypeVisitor::visitMemberRecord(CVMemberRecord Record) {
return ::visitMemberRecord(Record, Callbacks);
}
@@ -226,20 +194,12 @@ Error CVTypeVisitor::visitTypeStream(CVTypeRange Types) {
return Error::success();
}
-Error CVTypeVisitor::visitTypeStream(TypeCollection &Types) {
- if (Types.empty())
- return Error::success();
-
- Optional<TypeIndex> I = Types.getFirst();
- do {
- CVType Type = Types.getType(*I);
- if (auto EC = visitTypeRecord(Type, *I))
- return EC;
- } while ((I = Types.getNext(*I)));
- return Error::success();
-}
+Error CVTypeVisitor::visitFieldListMemberStream(BinaryStreamReader Reader) {
+ FieldListDeserializer Deserializer(Reader);
+ TypeVisitorCallbackPipeline Pipeline;
+ Pipeline.addCallbackToPipeline(Deserializer);
+ Pipeline.addCallbackToPipeline(Callbacks);
-Error CVTypeVisitor::visitFieldListMemberStream(BinaryStreamReader &Reader) {
TypeLeafKind Leaf;
while (!Reader.empty()) {
if (auto EC = Reader.readEnum(Leaf))
@@ -247,13 +207,20 @@ Error CVTypeVisitor::visitFieldListMemberStream(BinaryStreamReader &Reader) {
CVMemberRecord Record;
Record.Kind = Leaf;
- if (auto EC = ::visitMemberRecord(Record, Callbacks))
+ if (auto EC = ::visitMemberRecord(Record, Pipeline))
return EC;
}
return Error::success();
}
+Error CVTypeVisitor::visitFieldListMemberStream(ArrayRef<uint8_t> Data) {
+ BinaryByteStream S(Data, llvm::support::little);
+ BinaryStreamReader SR(S);
+ return visitFieldListMemberStream(SR);
+}
+
+namespace {
struct FieldListVisitHelper {
FieldListVisitHelper(TypeVisitorCallbacks &Callbacks, ArrayRef<uint8_t> Data,
VisitorDataSource Source)
@@ -274,8 +241,11 @@ struct FieldListVisitHelper {
};
struct VisitHelper {
- VisitHelper(TypeVisitorCallbacks &Callbacks, VisitorDataSource Source)
+ VisitHelper(TypeVisitorCallbacks &Callbacks, VisitorDataSource Source,
+ TypeServerHandler *TS)
: Visitor((Source == VDS_BytesPresent) ? Pipeline : Callbacks) {
+ if (TS)
+ Visitor.addTypeServerHandler(*TS);
if (Source == VDS_BytesPresent) {
Pipeline.addCallbackToPipeline(Deserializer);
Pipeline.addCallbackToPipeline(Callbacks);
@@ -292,57 +262,29 @@ Error llvm::codeview::visitTypeRecord(CVType &Record, TypeIndex Index,
TypeVisitorCallbacks &Callbacks,
VisitorDataSource Source,
TypeServerHandler *TS) {
- VisitHelper V(Callbacks, Source);
- if (TS)
- V.Visitor.addTypeServerHandler(*TS);
- return V.Visitor.visitTypeRecord(Record, Index);
+ VisitHelper Helper(Callbacks, Source, TS);
+ return Helper.Visitor.visitTypeRecord(Record, Index);
}
Error llvm::codeview::visitTypeRecord(CVType &Record,
TypeVisitorCallbacks &Callbacks,
VisitorDataSource Source,
TypeServerHandler *TS) {
- VisitHelper V(Callbacks, Source);
- if (TS)
- V.Visitor.addTypeServerHandler(*TS);
- return V.Visitor.visitTypeRecord(Record);
-}
-
-Error llvm::codeview::visitTypeStream(const CVTypeArray &Types,
- TypeVisitorCallbacks &Callbacks,
- TypeServerHandler *TS) {
- VisitHelper V(Callbacks, VDS_BytesPresent);
- if (TS)
- V.Visitor.addTypeServerHandler(*TS);
- return V.Visitor.visitTypeStream(Types);
+ VisitHelper Helper(Callbacks, Source, TS);
+ return Helper.Visitor.visitTypeRecord(Record);
}
-Error llvm::codeview::visitTypeStream(CVTypeRange Types,
- TypeVisitorCallbacks &Callbacks,
- TypeServerHandler *TS) {
- VisitHelper V(Callbacks, VDS_BytesPresent);
- if (TS)
- V.Visitor.addTypeServerHandler(*TS);
- return V.Visitor.visitTypeStream(Types);
-}
-
-Error llvm::codeview::visitTypeStream(TypeCollection &Types,
- TypeVisitorCallbacks &Callbacks,
- TypeServerHandler *TS) {
- // When the internal visitor calls Types.getType(Index) the interface is
- // required to return a CVType with the bytes filled out. So we can assume
- // that the bytes will be present when individual records are visited.
- VisitHelper V(Callbacks, VDS_BytesPresent);
- if (TS)
- V.Visitor.addTypeServerHandler(*TS);
- return V.Visitor.visitTypeStream(Types);
+Error llvm::codeview::visitMemberRecordStream(ArrayRef<uint8_t> FieldList,
+ TypeVisitorCallbacks &Callbacks) {
+ CVTypeVisitor Visitor(Callbacks);
+ return Visitor.visitFieldListMemberStream(FieldList);
}
Error llvm::codeview::visitMemberRecord(CVMemberRecord Record,
TypeVisitorCallbacks &Callbacks,
VisitorDataSource Source) {
- FieldListVisitHelper V(Callbacks, Record.Data, Source);
- return V.Visitor.visitMemberRecord(Record);
+ FieldListVisitHelper Helper(Callbacks, Record.Data, Source);
+ return Helper.Visitor.visitMemberRecord(Record);
}
Error llvm::codeview::visitMemberRecord(TypeLeafKind Kind,
@@ -354,8 +296,16 @@ Error llvm::codeview::visitMemberRecord(TypeLeafKind Kind,
return visitMemberRecord(R, Callbacks, VDS_BytesPresent);
}
-Error llvm::codeview::visitMemberRecordStream(ArrayRef<uint8_t> FieldList,
- TypeVisitorCallbacks &Callbacks) {
- FieldListVisitHelper V(Callbacks, FieldList, VDS_BytesPresent);
- return V.Visitor.visitFieldListMemberStream(V.Reader);
+Error llvm::codeview::visitTypeStream(const CVTypeArray &Types,
+ TypeVisitorCallbacks &Callbacks,
+ TypeServerHandler *TS) {
+ VisitHelper Helper(Callbacks, VDS_BytesPresent, TS);
+ return Helper.Visitor.visitTypeStream(Types);
+}
+
+Error llvm::codeview::visitTypeStream(CVTypeRange Types,
+ TypeVisitorCallbacks &Callbacks,
+ TypeServerHandler *TS) {
+ VisitHelper Helper(Callbacks, VDS_BytesPresent, TS);
+ return Helper.Visitor.visitTypeStream(Types);
}
diff --git a/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp b/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
deleted file mode 100644
index 4886a187088..00000000000
--- a/llvm/lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp
+++ /dev/null
@@ -1,226 +0,0 @@
-//===- LazyRandomTypeCollection.cpp ---------------------------- *- C++--*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
-
-#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
-#include "llvm/DebugInfo/CodeView/CodeViewError.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
-#include "llvm/DebugInfo/CodeView/TypeServerHandler.h"
-#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
-
-using namespace llvm;
-using namespace llvm::codeview;
-
-static void error(Error &&EC) {
- assert(!static_cast<bool>(EC));
- if (EC)
- consumeError(std::move(EC));
-}
-
-LazyRandomTypeCollection::LazyRandomTypeCollection(uint32_t RecordCountHint)
- : LazyRandomTypeCollection(CVTypeArray(), RecordCountHint,
- PartialOffsetArray()) {}
-
-LazyRandomTypeCollection::LazyRandomTypeCollection(
- const CVTypeArray &Types, uint32_t RecordCountHint,
- PartialOffsetArray PartialOffsets)
- : Database(RecordCountHint), Types(Types), DatabaseVisitor(Database),
- PartialOffsets(PartialOffsets) {
- KnownOffsets.resize(Database.capacity());
-}
-
-LazyRandomTypeCollection::LazyRandomTypeCollection(ArrayRef<uint8_t> Data,
- uint32_t RecordCountHint)
- : LazyRandomTypeCollection(RecordCountHint) {
- reset(Data);
-}
-
-LazyRandomTypeCollection::LazyRandomTypeCollection(StringRef Data,
- uint32_t RecordCountHint)
- : LazyRandomTypeCollection(
- makeArrayRef(Data.bytes_begin(), Data.bytes_end()), RecordCountHint) {
-}
-
-LazyRandomTypeCollection::LazyRandomTypeCollection(const CVTypeArray &Types,
- uint32_t NumRecords)
- : LazyRandomTypeCollection(Types, NumRecords, PartialOffsetArray()) {}
-
-void LazyRandomTypeCollection::reset(StringRef Data) {
- reset(makeArrayRef(Data.bytes_begin(), Data.bytes_end()));
-}
-
-void LazyRandomTypeCollection::reset(ArrayRef<uint8_t> Data) {
- PartialOffsets = PartialOffsetArray();
-
- BinaryStreamReader Reader(Data, support::little);
- error(Reader.readArray(Types, Reader.getLength()));
-
- KnownOffsets.resize(Database.capacity());
-}
-
-CVType LazyRandomTypeCollection::getType(TypeIndex Index) {
- error(ensureTypeExists(Index));
- return Database.getTypeRecord(Index);
-}
-
-StringRef LazyRandomTypeCollection::getTypeName(TypeIndex Index) {
- if (!Index.isSimple()) {
- // 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.
- consumeError(ensureTypeExists(Index));
- }
-
- return Database.getTypeName(Index);
-}
-
-bool LazyRandomTypeCollection::contains(TypeIndex Index) {
- return Database.contains(Index);
-}
-
-uint32_t LazyRandomTypeCollection::size() { return Database.size(); }
-
-uint32_t LazyRandomTypeCollection::capacity() { return Database.capacity(); }
-
-Error LazyRandomTypeCollection::ensureTypeExists(TypeIndex TI) {
- if (!Database.contains(TI)) {
- if (auto EC = visitRangeForType(TI))
- return EC;
- }
- return Error::success();
-}
-
-Error LazyRandomTypeCollection::visitRangeForType(TypeIndex TI) {
- if (PartialOffsets.empty())
- return fullScanForType(TI);
-
- auto Next = std::upper_bound(PartialOffsets.begin(), PartialOffsets.end(), TI,
- [](TypeIndex Value, const TypeIndexOffset &IO) {
- return Value < IO.Type;
- });
-
- assert(Next != PartialOffsets.begin());
- auto Prev = std::prev(Next);
-
- TypeIndex TIB = Prev->Type;
- if (Database.contains(TIB)) {
- // They've asked us to fetch a type index, but the entry we found in the
- // partial offsets array has already been visited. Since we visit an entire
- // block every time, that means this record should have been previously
- // discovered. Ultimately, this means this is a request for a non-existant
- // type index.
- return make_error<CodeViewError>("Invalid type index");
- }
-
- TypeIndex TIE;
- if (Next == PartialOffsets.end()) {
- TIE = TypeIndex::fromArrayIndex(Database.capacity());
- } else {
- TIE = Next->Type;
- }
-
- if (auto EC = visitRange(TIB, Prev->Offset, TIE))
- return EC;
- return Error::success();
-}
-
-TypeIndex LazyRandomTypeCollection::getFirst() {
- TypeIndex TI = TypeIndex::fromArrayIndex(0);
- error(ensureTypeExists(TI));
- return TI;
-}
-
-Optional<TypeIndex> LazyRandomTypeCollection::getNext(TypeIndex Prev) {
- // We can't be sure how long this type stream is, given that the initial count
- // given to the constructor is just a hint. So just try to make sure the next
- // record exists, and if anything goes wrong, we must be at the end.
- if (auto EC = ensureTypeExists(Prev + 1)) {
- consumeError(std::move(EC));
- return None;
- }
-
- return Prev + 1;
-}
-
-Error LazyRandomTypeCollection::fullScanForType(TypeIndex TI) {
- assert(PartialOffsets.empty());
-
- TypeIndex CurrentTI = TypeIndex::fromArrayIndex(0);
- uint32_t Offset = 0;
- auto Begin = Types.begin();
-
- if (!Database.empty()) {
- // In the case of type streams which we don't know the number of records of,
- // it's possible to search for a type index triggering a full scan, but then
- // later additional records are added since we didn't know how many there
- // would be until we did a full visitation, then you try to access the new
- // type triggering another full scan. To avoid this, we assume that if the
- // database has some records, this must be what's going on. So we ask the
- // database for the largest type index less than the one we're searching for
- // and only do the forward scan from there.
- auto Prev = Database.largestTypeIndexLessThan(TI);
- assert(Prev.hasValue() && "Empty database with valid types?");
- Offset = KnownOffsets[Prev->toArrayIndex()];
- CurrentTI = *Prev;
- ++CurrentTI;
- Begin = Types.at(Offset);
- ++Begin;
- Offset = Begin.offset();
- }
-
- auto End = Types.end();
- while (Begin != End) {
- if (auto EC = visitOneRecord(CurrentTI, Offset, *Begin))
- return EC;
-
- Offset += Begin.getRecordLength();
- ++Begin;
- ++CurrentTI;
- }
- if (CurrentTI <= TI) {
- return make_error<CodeViewError>("Type Index does not exist!");
- }
- return Error::success();
-}
-
-Error LazyRandomTypeCollection::visitRange(TypeIndex Begin,
- uint32_t BeginOffset,
- TypeIndex End) {
-
- auto RI = Types.at(BeginOffset);
- assert(RI != Types.end());
-
- while (Begin != End) {
- if (auto EC = visitOneRecord(Begin, BeginOffset, *RI))
- return EC;
-
- BeginOffset += RI.getRecordLength();
- ++Begin;
- ++RI;
- }
-
- return Error::success();
-}
-
-Error LazyRandomTypeCollection::visitOneRecord(TypeIndex TI, uint32_t Offset,
- CVType &Record) {
- assert(!Database.contains(TI));
- if (auto EC = codeview::visitTypeRecord(Record, TI, DatabaseVisitor))
- return EC;
- // Keep the KnownOffsets array the same size as the Database's capacity. Since
- // we don't always know how many records are in the type stream, we need to be
- // prepared for the database growing and receicing a type index that can't fit
- // in our current buffer.
- if (KnownOffsets.size() < Database.capacity())
- KnownOffsets.resize(Database.capacity());
- KnownOffsets[TI.toArrayIndex()] = Offset;
- return Error::success();
-}
diff --git a/llvm/lib/DebugInfo/CodeView/RandomAccessTypeVisitor.cpp b/llvm/lib/DebugInfo/CodeView/RandomAccessTypeVisitor.cpp
new file mode 100644
index 00000000000..704d1131108
--- /dev/null
+++ b/llvm/lib/DebugInfo/CodeView/RandomAccessTypeVisitor.cpp
@@ -0,0 +1,89 @@
+//===- RandomAccessTypeVisitor.cpp ---------------------------- *- C++ --*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/CodeView/RandomAccessTypeVisitor.h"
+
+#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
+#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
+#include "llvm/DebugInfo/CodeView/TypeServerHandler.h"
+#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+RandomAccessTypeVisitor::RandomAccessTypeVisitor(
+ const CVTypeArray &Types, uint32_t NumRecords,
+ PartialOffsetArray PartialOffsets)
+ : Database(NumRecords), Types(Types), DatabaseVisitor(Database),
+ PartialOffsets(PartialOffsets) {
+
+ KnownOffsets.resize(Database.capacity());
+}
+
+Error RandomAccessTypeVisitor::visitTypeIndex(TypeIndex TI,
+ TypeVisitorCallbacks &Callbacks) {
+ assert(TI.toArrayIndex() < Database.capacity());
+
+ if (!Database.contains(TI)) {
+ if (auto EC = visitRangeForType(TI))
+ return EC;
+ }
+
+ assert(Database.contains(TI));
+ auto &Record = Database.getTypeRecord(TI);
+ return codeview::visitTypeRecord(Record, TI, Callbacks);
+}
+
+Error RandomAccessTypeVisitor::visitRangeForType(TypeIndex TI) {
+ if (PartialOffsets.empty()) {
+ TypeIndex TIB(TypeIndex::FirstNonSimpleIndex);
+ TypeIndex TIE = TIB + Database.capacity();
+ return visitRange(TIB, 0, TIE);
+ }
+
+ auto Next = std::upper_bound(PartialOffsets.begin(), PartialOffsets.end(), TI,
+ [](TypeIndex Value, const TypeIndexOffset &IO) {
+ return Value < IO.Type;
+ });
+
+ assert(Next != PartialOffsets.begin());
+ auto Prev = std::prev(Next);
+
+ TypeIndex TIB = Prev->Type;
+ TypeIndex TIE;
+ if (Next == PartialOffsets.end()) {
+ TIE = TypeIndex::fromArrayIndex(Database.capacity());
+ } else {
+ TIE = Next->Type;
+ }
+
+ if (auto EC = visitRange(TIB, Prev->Offset, TIE))
+ return EC;
+ return Error::success();
+}
+
+Error RandomAccessTypeVisitor::visitRange(TypeIndex Begin, uint32_t BeginOffset,
+ TypeIndex End) {
+
+ auto RI = Types.at(BeginOffset);
+ assert(RI != Types.end());
+
+ while (Begin != End) {
+ assert(!Database.contains(Begin));
+ if (auto EC = codeview::visitTypeRecord(*RI, Begin, DatabaseVisitor))
+ return EC;
+ KnownOffsets[Begin.toArrayIndex()] = BeginOffset;
+
+ BeginOffset += RI.getRecordLength();
+ ++Begin;
+ ++RI;
+ }
+
+ return Error::success();
+}
diff --git a/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp b/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp
index 7d01c8c5f19..5395e4349b2 100644
--- a/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp
+++ b/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp
@@ -11,6 +11,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h"
+#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
#include "llvm/DebugInfo/CodeView/EnumTables.h"
#include "llvm/DebugInfo/CodeView/StringTable.h"
#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
@@ -32,9 +33,9 @@ namespace {
/// the visitor out of SymbolDumper.h.
class CVSymbolDumperImpl : public SymbolVisitorCallbacks {
public:
- CVSymbolDumperImpl(TypeCollection &Types, SymbolDumpDelegate *ObjDelegate,
+ CVSymbolDumperImpl(TypeDatabase &TypeDB, SymbolDumpDelegate *ObjDelegate,
ScopedPrinter &W, bool PrintRecordBytes)
- : Types(Types), ObjDelegate(ObjDelegate), W(W),
+ : TypeDB(TypeDB), ObjDelegate(ObjDelegate), W(W),
PrintRecordBytes(PrintRecordBytes), InFunctionScope(false) {}
/// CVSymbolVisitor overrides.
@@ -53,7 +54,7 @@ private:
void printLocalVariableAddrGap(ArrayRef<LocalVariableAddrGap> Gaps);
void printTypeIndex(StringRef FieldName, TypeIndex TI);
- TypeCollection &Types;
+ TypeDatabase &TypeDB;
SymbolDumpDelegate *ObjDelegate;
ScopedPrinter &W;
@@ -82,7 +83,7 @@ void CVSymbolDumperImpl::printLocalVariableAddrGap(
}
void CVSymbolDumperImpl::printTypeIndex(StringRef FieldName, TypeIndex TI) {
- codeview::printTypeIndex(W, FieldName, TI, Types);
+ CVTypeDumper::printTypeIndex(W, FieldName, TI, TypeDB);
}
Error CVSymbolDumperImpl::visitSymbolBegin(CVSymbol &CVR) {
@@ -669,7 +670,7 @@ Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) {
Error CVSymbolDumper::dump(CVRecord<SymbolKind> &Record) {
SymbolVisitorCallbackPipeline Pipeline;
SymbolDeserializer Deserializer(ObjDelegate.get());
- CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(), W, PrintRecordBytes);
+ CVSymbolDumperImpl Dumper(TypeDB, ObjDelegate.get(), W, PrintRecordBytes);
Pipeline.addCallbackToPipeline(Deserializer);
Pipeline.addCallbackToPipeline(Dumper);
@@ -680,7 +681,7 @@ Error CVSymbolDumper::dump(CVRecord<SymbolKind> &Record) {
Error CVSymbolDumper::dump(const CVSymbolArray &Symbols) {
SymbolVisitorCallbackPipeline Pipeline;
SymbolDeserializer Deserializer(ObjDelegate.get());
- CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(), W, PrintRecordBytes);
+ CVSymbolDumperImpl Dumper(TypeDB, ObjDelegate.get(), W, PrintRecordBytes);
Pipeline.addCallbackToPipeline(Deserializer);
Pipeline.addCallbackToPipeline(Dumper);
diff --git a/llvm/lib/DebugInfo/CodeView/TypeDatabase.cpp b/llvm/lib/DebugInfo/CodeView/TypeDatabase.cpp
index 89531e02212..7924440e5e2 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeDatabase.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeDatabase.cpp
@@ -72,20 +72,16 @@ TypeDatabase::TypeDatabase(uint32_t Capacity) : TypeNameStorage(Allocator) {
}
TypeIndex TypeDatabase::appendType(StringRef Name, const CVType &Data) {
- LargestTypeIndex = getAppendIndex();
- if (LargestTypeIndex.toArrayIndex() >= capacity())
+ TypeIndex TI;
+ TI = getAppendIndex();
+ if (TI.toArrayIndex() >= capacity())
grow();
- recordType(Name, LargestTypeIndex, Data);
- return LargestTypeIndex;
+ recordType(Name, TI, Data);
+ return TI;
}
void TypeDatabase::recordType(StringRef Name, TypeIndex Index,
const CVType &Data) {
- LargestTypeIndex = empty() ? Index : std::max(Index, LargestTypeIndex);
-
- if (LargestTypeIndex.toArrayIndex() >= capacity())
- grow(Index);
-
uint32_t AI = Index.toArrayIndex();
assert(!contains(Index));
@@ -148,65 +144,19 @@ uint32_t TypeDatabase::size() const { return Count; }
uint32_t TypeDatabase::capacity() const { return TypeRecords.size(); }
-CVType TypeDatabase::getType(TypeIndex Index) { return getTypeRecord(Index); }
-
-StringRef TypeDatabase::getTypeName(TypeIndex Index) {
- return static_cast<const TypeDatabase *>(this)->getTypeName(Index);
-}
-
-bool TypeDatabase::contains(TypeIndex Index) {
- return static_cast<const TypeDatabase *>(this)->contains(Index);
-}
-
-uint32_t TypeDatabase::size() {
- return static_cast<const TypeDatabase *>(this)->size();
-}
-
-uint32_t TypeDatabase::capacity() {
- return static_cast<const TypeDatabase *>(this)->capacity();
-}
-
-void TypeDatabase::grow() { grow(LargestTypeIndex + 1); }
-
-void TypeDatabase::grow(TypeIndex NewIndex) {
- uint32_t NewSize = NewIndex.toArrayIndex() + 1;
-
- if (NewSize <= capacity())
- return;
-
- uint32_t NewCapacity = NewSize * 3 / 2;
-
- TypeRecords.resize(NewCapacity);
- CVUDTNames.resize(NewCapacity);
- ValidRecords.resize(NewCapacity);
+void TypeDatabase::grow() {
+ TypeRecords.emplace_back();
+ CVUDTNames.emplace_back();
+ ValidRecords.resize(ValidRecords.size() + 1);
}
bool TypeDatabase::empty() const { return size() == 0; }
-Optional<TypeIndex> TypeDatabase::largestTypeIndexLessThan(TypeIndex TI) const {
- uint32_t AI = TI.toArrayIndex();
- int N = ValidRecords.find_prev(AI);
- if (N == -1)
- return None;
- return TypeIndex::fromArrayIndex(N);
-}
-
TypeIndex TypeDatabase::getAppendIndex() const {
if (empty())
return TypeIndex::fromArrayIndex(0);
- return LargestTypeIndex + 1;
-}
-
-TypeIndex TypeDatabase::getFirst() {
- int N = ValidRecords.find_first();
- assert(N != -1);
- return TypeIndex::fromArrayIndex(N);
-}
-
-Optional<TypeIndex> TypeDatabase::getNext(TypeIndex Prev) {
- int N = ValidRecords.find_next(Prev.toArrayIndex());
- if (N == -1)
- return None;
- return TypeIndex::fromArrayIndex(N);
+ int Index = ValidRecords.find_last();
+ assert(Index != -1);
+ return TypeIndex::fromArrayIndex(Index) + 1;
}
diff --git a/llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp b/llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
index 84f52a05581..9485c9cfedf 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
@@ -10,13 +10,15 @@
#include "llvm/DebugInfo/CodeView/TypeDumpVisitor.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/Formatters.h"
-#include "llvm/DebugInfo/CodeView/TypeCollection.h"
#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
#include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
+#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
+#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
#include "llvm/Support/BinaryByteStream.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/ScopedPrinter.h"
@@ -163,15 +165,16 @@ static StringRef getLeafTypeName(TypeLeafKind LT) {
}
void TypeDumpVisitor::printTypeIndex(StringRef FieldName, TypeIndex TI) const {
- codeview::printTypeIndex(*W, FieldName, TI, TpiTypes);
+ CVTypeDumper::printTypeIndex(*W, FieldName, TI, TypeDB);
}
void TypeDumpVisitor::printItemIndex(StringRef FieldName, TypeIndex TI) const {
- codeview::printTypeIndex(*W, FieldName, TI, getSourceTypes());
+ CVTypeDumper::printTypeIndex(*W, FieldName, TI, getSourceDB());
}
Error TypeDumpVisitor::visitTypeBegin(CVType &Record) {
- return visitTypeBegin(Record, TypeIndex::fromArrayIndex(TpiTypes.size()));
+ TypeIndex TI = getSourceDB().getAppendIndex();
+ return visitTypeBegin(Record, TI);
}
Error TypeDumpVisitor::visitTypeBegin(CVType &Record, TypeIndex Index) {
@@ -242,7 +245,7 @@ Error TypeDumpVisitor::visitKnownRecord(CVType &CVR, StringListRecord &Strs) {
W->printNumber("NumStrings", Size);
ListScope Arguments(*W, "Strings");
for (uint32_t I = 0; I < Size; ++I) {
- printItemIndex("String", Indices[I]);
+ printTypeIndex("String", Indices[I]);
}
return Error::success();
}
diff --git a/llvm/lib/DebugInfo/CodeView/TypeIndex.cpp b/llvm/lib/DebugInfo/CodeView/TypeIndex.cpp
deleted file mode 100644
index 20ba6470cd5..00000000000
--- a/llvm/lib/DebugInfo/CodeView/TypeIndex.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===-- TypeIndex.cpp - CodeView type index ---------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/DebugInfo/CodeView/TypeIndex.h"
-
-#include "llvm/DebugInfo/CodeView/TypeCollection.h"
-#include "llvm/Support/ScopedPrinter.h"
-
-using namespace llvm;
-using namespace llvm::codeview;
-
-void llvm::codeview::printTypeIndex(ScopedPrinter &Printer, StringRef FieldName,
- TypeIndex TI, TypeCollection &Types) {
- StringRef TypeName;
- if (!TI.isNoneType())
- TypeName = Types.getTypeName(TI);
- if (!TypeName.empty())
- Printer.printHex(FieldName, TypeName, TI.getIndex());
- else
- Printer.printHex(FieldName, TI.getIndex());
-}
diff --git a/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp b/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
index 46747f8eab9..9b70b7f6700 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
@@ -11,9 +11,11 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
+#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
+#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ScopedPrinter.h"
diff --git a/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp b/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
deleted file mode 100644
index 4e53437f24a..00000000000
--- a/llvm/lib/DebugInfo/CodeView/TypeTableCollection.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-//===- TypeTableCollection.cpp -------------------------------- *- C++ --*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/DebugInfo/CodeView/TypeTableCollection.h"
-
-#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
-#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
-#include "llvm/Support/BinaryByteStream.h"
-#include "llvm/Support/BinaryStreamReader.h"
-
-using namespace llvm;
-using namespace llvm::codeview;
-
-static void error(Error &&EC) {
- assert(!static_cast<bool>(EC));
- if (EC)
- consumeError(std::move(EC));
-}
-
-TypeTableCollection::TypeTableCollection(
- ArrayRef<MutableArrayRef<uint8_t>> Records)
- : Records(Records), Database(Records.size()) {}
-
-TypeIndex TypeTableCollection::getFirst() {
- assert(!empty());
- return TypeIndex::fromArrayIndex(0);
-}
-
-Optional<TypeIndex> TypeTableCollection::getNext(TypeIndex Prev) {
- ++Prev;
- assert(Prev.toArrayIndex() <= size());
- if (Prev.toArrayIndex() == size())
- return None;
- return Prev;
-}
-
-void TypeTableCollection::ensureTypeExists(TypeIndex Index) {
- assert(hasCapacityFor(Index));
-
- if (Database.contains(Index))
- return;
-
- BinaryByteStream Bytes(Records[Index.toArrayIndex()], support::little);
-
- CVType Type;
- uint32_t Len;
- error(VarStreamArrayExtractor<CVType>::extract(Bytes, Len, Type));
-
- TypeDatabaseVisitor DBV(Database);
- error(codeview::visitTypeRecord(Type, Index, DBV));
- assert(Database.contains(Index));
-}
-
-CVType TypeTableCollection::getType(TypeIndex Index) {
- ensureTypeExists(Index);
- return Database.getTypeRecord(Index);
-}
-
-StringRef TypeTableCollection::getTypeName(TypeIndex Index) {
- if (!Index.isSimple())
- ensureTypeExists(Index);
- return Database.getTypeName(Index);
-}
-
-bool TypeTableCollection::contains(TypeIndex Index) {
- return Database.contains(Index);
-}
-
-uint32_t TypeTableCollection::size() { return Records.size(); }
-
-uint32_t TypeTableCollection::capacity() { return Records.size(); }
-
-bool TypeTableCollection::hasCapacityFor(TypeIndex Index) const {
- return Index.toArrayIndex() < Records.size();
-}
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp
index f00567db743..cb783cf4fea 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PDBTypeServerHandler.cpp
@@ -21,7 +21,6 @@
#include "llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h"
-#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/DebugInfo/PDB/GenericError.h"
#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
diff --git a/llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp b/llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp
index 8e006587389..c53ba815c0b 100644
--- a/llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/TpiStream.cpp
@@ -9,7 +9,10 @@
#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
#include "llvm/ADT/iterator_range.h"
+#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
+#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
+#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
#include "llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h"
OpenPOWER on IntegriCloud