LCOV - code coverage report
Current view: top level - lib/DebugInfo/PDB/Native - NativeEnumTypes.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 29 30 96.7 %
Date: 2018-10-20 13:21:21 Functions: 5 6 83.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //==- NativeEnumTypes.cpp - Native Type Enumerator impl ----------*- 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/PDB/Native/NativeEnumTypes.h"
      11             : 
      12             : #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
      13             : #include "llvm/DebugInfo/CodeView/TypeRecordHelpers.h"
      14             : #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
      15             : #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
      16             : #include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
      17             : #include "llvm/DebugInfo/PDB/PDBSymbol.h"
      18             : #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
      19             : 
      20             : using namespace llvm;
      21             : using namespace llvm::codeview;
      22             : using namespace llvm::pdb;
      23             : 
      24           8 : NativeEnumTypes::NativeEnumTypes(NativeSession &PDBSession,
      25             :                                  LazyRandomTypeCollection &Types,
      26           8 :                                  std::vector<codeview::TypeLeafKind> Kinds)
      27           8 :     : Matches(), Index(0), Session(PDBSession) {
      28           8 :   Optional<TypeIndex> TI = Types.getFirst();
      29        1288 :   while (TI) {
      30        1280 :     CVType CVT = Types.getType(*TI);
      31        1280 :     TypeLeafKind K = CVT.kind();
      32        1280 :     if (llvm::is_contained(Kinds, K)) {
      33             :       // Don't add forward refs, we'll find those later while enumerating.
      34         290 :       if (!isUdtForwardRef(CVT))
      35         254 :         Matches.push_back(*TI);
      36         990 :     } else if (K == TypeLeafKind::LF_MODIFIER) {
      37          48 :       TypeIndex ModifiedTI = getModifiedType(CVT);
      38          48 :       if (!ModifiedTI.isSimple()) {
      39          30 :         CVType UnmodifiedCVT = Types.getType(ModifiedTI);
      40             :         // LF_MODIFIERs point to forward refs, but don't worry about that
      41             :         // here.  We're pushing the TypeIndex of the LF_MODIFIER itself,
      42             :         // so we'll worry about resolving forward refs later.
      43          30 :         if (llvm::is_contained(Kinds, UnmodifiedCVT.kind()))
      44          10 :           Matches.push_back(*TI);
      45             :       }
      46             :     }
      47        2560 :     TI = Types.getNext(*TI);
      48             :   }
      49           8 : }
      50             : 
      51          61 : NativeEnumTypes::NativeEnumTypes(NativeSession &PDBSession,
      52          61 :                                  std::vector<codeview::TypeIndex> Indices)
      53         122 :     : Matches(std::move(Indices)), Index(0), Session(PDBSession) {}
      54             : 
      55          55 : uint32_t NativeEnumTypes::getChildCount() const {
      56         110 :   return static_cast<uint32_t>(Matches.size());
      57             : }
      58             : 
      59         384 : std::unique_ptr<PDBSymbol> NativeEnumTypes::getChildAtIndex(uint32_t N) const {
      60         768 :   if (N < Matches.size()) {
      61         630 :     SymIndexId Id = Session.getSymbolCache().findSymbolByTypeIndex(Matches[N]);
      62         630 :     return Session.getSymbolCache().getSymbolById(Id);
      63             :   }
      64             :   return nullptr;
      65             : }
      66             : 
      67         384 : std::unique_ptr<PDBSymbol> NativeEnumTypes::getNext() {
      68         384 :   return getChildAtIndex(Index++);
      69             : }
      70             : 
      71           0 : void NativeEnumTypes::reset() { Index = 0; }

Generated by: LCOV version 1.13