LCOV - code coverage report
Current view: top level - lib/DebugInfo/CodeView - AppendingTypeTableBuilder.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 18 36 50.0 %
Date: 2018-10-20 13:21:21 Functions: 5 13 38.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- AppendingTypeTableBuilder.cpp --------------------------------------===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #include "llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h"
      11             : #include "llvm/ADT/ArrayRef.h"
      12             : #include "llvm/ADT/DenseSet.h"
      13             : #include "llvm/ADT/STLExtras.h"
      14             : #include "llvm/DebugInfo/CodeView/CodeView.h"
      15             : #include "llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h"
      16             : #include "llvm/DebugInfo/CodeView/RecordSerialization.h"
      17             : #include "llvm/DebugInfo/CodeView/TypeIndex.h"
      18             : #include "llvm/Support/Allocator.h"
      19             : #include "llvm/Support/BinaryByteStream.h"
      20             : #include "llvm/Support/BinaryStreamWriter.h"
      21             : #include "llvm/Support/Endian.h"
      22             : #include "llvm/Support/Error.h"
      23             : #include <algorithm>
      24             : #include <cassert>
      25             : #include <cstdint>
      26             : #include <cstring>
      27             : 
      28             : using namespace llvm;
      29             : using namespace llvm::codeview;
      30             : 
      31        1607 : TypeIndex AppendingTypeTableBuilder::nextTypeIndex() const {
      32        3214 :   return TypeIndex::fromArrayIndex(SeenRecords.size());
      33             : }
      34             : 
      35         113 : AppendingTypeTableBuilder::AppendingTypeTableBuilder(BumpPtrAllocator &Storage)
      36         113 :     : RecordStorage(Storage) {}
      37             : 
      38             : AppendingTypeTableBuilder::~AppendingTypeTableBuilder() = default;
      39             : 
      40           0 : Optional<TypeIndex> AppendingTypeTableBuilder::getFirst() {
      41           0 :   if (empty())
      42             :     return None;
      43             : 
      44             :   return TypeIndex(TypeIndex::FirstNonSimpleIndex);
      45             : }
      46             : 
      47           0 : Optional<TypeIndex> AppendingTypeTableBuilder::getNext(TypeIndex Prev) {
      48           0 :   if (++Prev == nextTypeIndex())
      49             :     return None;
      50             :   return Prev;
      51             : }
      52             : 
      53           0 : CVType AppendingTypeTableBuilder::getType(TypeIndex Index) {
      54             :   CVType Type;
      55           0 :   Type.RecordData = SeenRecords[Index.toArrayIndex()];
      56             :   const RecordPrefix *P =
      57           0 :       reinterpret_cast<const RecordPrefix *>(Type.RecordData.data());
      58           0 :   Type.Type = static_cast<TypeLeafKind>(uint16_t(P->RecordKind));
      59           0 :   return Type;
      60             : }
      61             : 
      62           0 : StringRef AppendingTypeTableBuilder::getTypeName(TypeIndex Index) {
      63           0 :   llvm_unreachable("Method not implemented");
      64             : }
      65             : 
      66           0 : bool AppendingTypeTableBuilder::contains(TypeIndex Index) {
      67           0 :   if (Index.isSimple() || Index.isNoneType())
      68           0 :     return false;
      69             : 
      70           0 :   return Index.toArrayIndex() < SeenRecords.size();
      71             : }
      72             : 
      73           0 : uint32_t AppendingTypeTableBuilder::size() { return SeenRecords.size(); }
      74             : 
      75           0 : uint32_t AppendingTypeTableBuilder::capacity() { return SeenRecords.size(); }
      76             : 
      77        1720 : ArrayRef<ArrayRef<uint8_t>> AppendingTypeTableBuilder::records() const {
      78        1720 :   return SeenRecords;
      79             : }
      80             : 
      81           0 : void AppendingTypeTableBuilder::reset() { SeenRecords.clear(); }
      82             : 
      83             : TypeIndex
      84        1477 : AppendingTypeTableBuilder::insertRecordBytes(ArrayRef<uint8_t> &Record) {
      85        1477 :   TypeIndex NewTI = nextTypeIndex();
      86        1477 :   uint8_t *Stable = RecordStorage.Allocate<uint8_t>(Record.size());
      87        1477 :   memcpy(Stable, Record.data(), Record.size());
      88        1477 :   Record = ArrayRef<uint8_t>(Stable, Record.size());
      89        1477 :   SeenRecords.push_back(Record);
      90        1477 :   return NewTI;
      91             : }
      92             : 
      93             : TypeIndex
      94         118 : AppendingTypeTableBuilder::insertRecord(ContinuationRecordBuilder &Builder) {
      95             :   TypeIndex TI;
      96         118 :   auto Fragments = Builder.end(nextTypeIndex());
      97             :   assert(!Fragments.empty());
      98         236 :   for (auto C : Fragments)
      99         118 :     TI = insertRecordBytes(C.RecordData);
     100         118 :   return TI;
     101             : }

Generated by: LCOV version 1.13