1 //===-- MemoryTypeTableBuilder.cpp ----------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h"
11 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
14 using namespace codeview;
16 MemoryTypeTableBuilder::Record::Record(StringRef RData)
17 : Size(RData.size()), Data(new char[RData.size()]) {
18 memcpy(Data.get(), RData.data(), RData.size());
21 TypeIndex MemoryTypeTableBuilder::writeRecord(StringRef Data) {
22 auto I = HashedRecords.find(Data);
23 if (I != HashedRecords.end()) {
27 std::unique_ptr<Record> R(new Record(Data));
29 TypeIndex TI(static_cast<uint32_t>(Records.size()) +
30 TypeIndex::FirstNonSimpleIndex);
31 HashedRecords.insert(std::make_pair(StringRef(R->data(), R->size()), TI));
32 Records.push_back(std::move(R));