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-10-20 13:21:21 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         138 : TypeTableCollection::TypeTableCollection(ArrayRef<ArrayRef<uint8_t>> Records)
      20         276 :     : NameStorage(Allocator), Records(Records) {
      21         138 :   Names.resize(Records.size());
      22         138 : }
      23             : 
      24         138 : Optional<TypeIndex> TypeTableCollection::getFirst() {
      25         138 :   if (empty())
      26             :     return None;
      27         274 :   return TypeIndex::fromArrayIndex(0);
      28             : }
      29             : 
      30        1987 : Optional<TypeIndex> TypeTableCollection::getNext(TypeIndex Prev) {
      31             :   assert(contains(Prev));
      32             :   ++Prev;
      33        1987 :   if (Prev.toArrayIndex() == size())
      34             :     return None;
      35             :   return Prev;
      36             : }
      37             : 
      38        2558 : CVType TypeTableCollection::getType(TypeIndex Index) {
      39             :   assert(Index.toArrayIndex() < Records.size());
      40        5116 :   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        2558 :   return CVType(Kind, Bytes);
      45             : }
      46             : 
      47        1305 : StringRef TypeTableCollection::getTypeName(TypeIndex Index) {
      48        1305 :   if (Index.isNoneType() || Index.isSimple())
      49         167 :     return TypeIndex::simpleTypeName(Index);
      50             : 
      51             :   uint32_t I = Index.toArrayIndex();
      52        2276 :   if (Names[I].data() == nullptr) {
      53         571 :     StringRef Result = NameStorage.save(computeTypeName(*this, Index));
      54        1142 :     Names[I] = Result;
      55             :   }
      56        2276 :   return Names[I];
      57             : }
      58             : 
      59           0 : bool TypeTableCollection::contains(TypeIndex Index) {
      60           0 :   return Index.toArrayIndex() <= size();
      61             : }
      62             : 
      63        2125 : uint32_t TypeTableCollection::size() { return Records.size(); }
      64             : 
      65           0 : uint32_t TypeTableCollection::capacity() { return Records.size(); }

Generated by: LCOV version 1.13