LCOV - code coverage report
Current view: top level - lib/DebugInfo/CodeView - TypeTableCollection.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 24 27 88.9 %
Date: 2017-09-14 15:23:50 Functions: 6 8 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- TypeTableCollection.cpp -------------------------------- *- C++ --*-===//
       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/TypeTableCollection.h"
      11             : 
      12             : #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
      13             : #include "llvm/DebugInfo/CodeView/RecordName.h"
      14             : #include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
      15             : #include "llvm/Support/BinaryByteStream.h"
      16             : #include "llvm/Support/BinaryStreamReader.h"
      17             : 
      18             : using namespace llvm;
      19             : using namespace llvm::codeview;
      20             : 
      21          96 : TypeTableCollection::TypeTableCollection(ArrayRef<ArrayRef<uint8_t>> Records)
      22         384 :     : NameStorage(Allocator), Records(Records) {
      23          96 :   Names.resize(Records.size());
      24          96 : }
      25             : 
      26          96 : Optional<TypeIndex> TypeTableCollection::getFirst() {
      27         192 :   if (empty())
      28             :     return None;
      29         190 :   return TypeIndex::fromArrayIndex(0);
      30             : }
      31             : 
      32        1075 : Optional<TypeIndex> TypeTableCollection::getNext(TypeIndex Prev) {
      33             :   assert(contains(Prev));
      34        1075 :   ++Prev;
      35        1075 :   if (Prev.toArrayIndex() == size())
      36             :     return None;
      37             :   return Prev;
      38             : }
      39             : 
      40        1413 : CVType TypeTableCollection::getType(TypeIndex Index) {
      41             :   assert(Index.toArrayIndex() < Records.size());
      42        2826 :   ArrayRef<uint8_t> Bytes = Records[Index.toArrayIndex()];
      43             :   const RecordPrefix *Prefix =
      44        1413 :       reinterpret_cast<const RecordPrefix *>(Bytes.data());
      45        2826 :   TypeLeafKind Kind = static_cast<TypeLeafKind>(uint16_t(Prefix->RecordKind));
      46        2826 :   return CVType(Kind, Bytes);
      47             : }
      48             : 
      49         871 : StringRef TypeTableCollection::getTypeName(TypeIndex Index) {
      50        1742 :   if (Index.isNoneType() || Index.isSimple())
      51         107 :     return TypeIndex::simpleTypeName(Index);
      52             : 
      53         764 :   uint32_t I = Index.toArrayIndex();
      54        2292 :   if (Names[I].data() == nullptr) {
      55        1014 :     StringRef Result = NameStorage.save(computeTypeName(*this, Index));
      56         676 :     Names[I] = Result;
      57             :   }
      58        1528 :   return Names[I];
      59             : }
      60             : 
      61           0 : bool TypeTableCollection::contains(TypeIndex Index) {
      62           0 :   return Index.toArrayIndex() <= size();
      63             : }
      64             : 
      65        1171 : uint32_t TypeTableCollection::size() { return Records.size(); }
      66             : 
      67           0 : uint32_t TypeTableCollection::capacity() { return Records.size(); }

Generated by: LCOV version 1.13