LCOV - code coverage report
Current view: top level - lib/DebugInfo/CodeView - TypeTableCollection.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 20 23 87.0 %
Date: 2018-07-13 00:08:38 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/Support/BinaryStreamReader.h"
      15             : 
      16             : using namespace llvm;
      17             : using namespace llvm::codeview;
      18             : 
      19         125 : TypeTableCollection::TypeTableCollection(ArrayRef<ArrayRef<uint8_t>> Records)
      20         375 :     : NameStorage(Allocator), Records(Records) {
      21         125 :   Names.resize(Records.size());
      22         125 : }
      23             : 
      24         125 : Optional<TypeIndex> TypeTableCollection::getFirst() {
      25         250 :   if (empty())
      26             :     return None;
      27         248 :   return TypeIndex::fromArrayIndex(0);
      28             : }
      29             : 
      30        1426 : Optional<TypeIndex> TypeTableCollection::getNext(TypeIndex Prev) {
      31             :   assert(contains(Prev));
      32             :   ++Prev;
      33        1426 :   if (Prev.toArrayIndex() == size())
      34             :     return None;
      35             :   return Prev;
      36             : }
      37             : 
      38        1865 : CVType TypeTableCollection::getType(TypeIndex Index) {
      39             :   assert(Index.toArrayIndex() < Records.size());
      40        3730 :   ArrayRef<uint8_t> Bytes = Records[Index.toArrayIndex()];
      41             :   const RecordPrefix *Prefix =
      42             :       reinterpret_cast<const RecordPrefix *>(Bytes.data());
      43             :   TypeLeafKind Kind = static_cast<TypeLeafKind>(uint16_t(Prefix->RecordKind));
      44        1865 :   return CVType(Kind, Bytes);
      45             : }
      46             : 
      47        1158 : StringRef TypeTableCollection::getTypeName(TypeIndex Index) {
      48        1158 :   if (Index.isNoneType() || Index.isSimple())
      49         162 :     return TypeIndex::simpleTypeName(Index);
      50             : 
      51             :   uint32_t I = Index.toArrayIndex();
      52        1992 :   if (Names[I].data() == nullptr) {
      53         878 :     StringRef Result = NameStorage.save(computeTypeName(*this, Index));
      54         878 :     Names[I] = Result;
      55             :   }
      56        1992 :   return Names[I];
      57             : }
      58             : 
      59           0 : bool TypeTableCollection::contains(TypeIndex Index) {
      60           0 :   return Index.toArrayIndex() <= size();
      61             : }
      62             : 
      63        1551 : uint32_t TypeTableCollection::size() { return Records.size(); }
      64             : 
      65           0 : uint32_t TypeTableCollection::capacity() { return Records.size(); }

Generated by: LCOV version 1.13