LCOV - code coverage report
Current view: top level - lib/DebugInfo/PDB/Native - NativeEnumGlobals.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 18 19 94.7 %
Date: 2018-10-20 13:21:21 Functions: 4 5 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //==- NativeEnumGlobals.cpp - Native Global 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/NativeEnumGlobals.h"
      11             : 
      12             : #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
      13             : #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
      14             : #include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
      15             : #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
      16             : #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
      17             : #include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
      18             : #include "llvm/DebugInfo/PDB/PDBSymbol.h"
      19             : 
      20             : using namespace llvm;
      21             : using namespace llvm::codeview;
      22             : using namespace llvm::pdb;
      23             : 
      24           2 : NativeEnumGlobals::NativeEnumGlobals(NativeSession &PDBSession,
      25           2 :                                      std::vector<codeview::SymbolKind> Kinds)
      26           4 :     : Index(0), Session(PDBSession) {
      27           2 :   GlobalsStream &GS = cantFail(Session.getPDBFile().getPDBGlobalsStream());
      28           6 :   SymbolStream &SS = cantFail(Session.getPDBFile().getPDBSymbolStream());
      29          44 :   for (uint32_t Off : GS.getGlobalsTable()) {
      30          42 :     CVSymbol S = SS.readRecord(Off);
      31          42 :     if (!llvm::is_contained(Kinds, S.kind()))
      32             :       continue;
      33           6 :     MatchOffsets.push_back(Off);
      34             :   }
      35           2 : }
      36             : 
      37           1 : uint32_t NativeEnumGlobals::getChildCount() const {
      38           2 :   return static_cast<uint32_t>(MatchOffsets.size());
      39             : }
      40             : 
      41             : std::unique_ptr<PDBSymbol>
      42           8 : NativeEnumGlobals::getChildAtIndex(uint32_t N) const {
      43          16 :   if (N >= MatchOffsets.size())
      44             :     return nullptr;
      45             : 
      46             :   SymIndexId Id =
      47          12 :       Session.getSymbolCache().getOrCreateGlobalSymbolByOffset(MatchOffsets[N]);
      48          12 :   return Session.getSymbolCache().getSymbolById(Id);
      49             : }
      50             : 
      51           8 : std::unique_ptr<PDBSymbol> NativeEnumGlobals::getNext() {
      52           8 :   return getChildAtIndex(Index++);
      53             : }
      54             : 
      55           0 : void NativeEnumGlobals::reset() { Index = 0; }

Generated by: LCOV version 1.13