LCOV - code coverage report
Current view: top level - lib/DebugInfo/CodeView - CVSymbolVisitor.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 26 35 74.3 %
Date: 2017-09-14 15:23:50 Functions: 31 44 70.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- CVSymbolVisitor.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/CVSymbolVisitor.h"
      11             : 
      12             : #include "llvm/DebugInfo/CodeView/CodeViewError.h"
      13             : #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
      14             : #include "llvm/Support/BinaryByteStream.h"
      15             : 
      16             : using namespace llvm;
      17             : using namespace llvm::codeview;
      18             : 
      19         313 : CVSymbolVisitor::CVSymbolVisitor(SymbolVisitorCallbacks &Callbacks)
      20         313 :     : Callbacks(Callbacks) {}
      21             : 
      22             : template <typename T>
      23        1127 : static Error visitKnownRecord(CVSymbol &Record,
      24             :                               SymbolVisitorCallbacks &Callbacks) {
      25        1127 :   SymbolRecordKind RK = static_cast<SymbolRecordKind>(Record.Type);
      26        1282 :   T KnownRecord(RK);
      27        3381 :   if (auto EC = Callbacks.visitKnownRecord(Record, KnownRecord))
      28           0 :     return EC;
      29        3381 :   return Error::success();
      30             : }
      31             : 
      32        1127 : static Error finishVisitation(CVSymbol &Record,
      33             :                               SymbolVisitorCallbacks &Callbacks) {
      34        1127 :   switch (Record.Type) {
      35           0 :   default:
      36           0 :     if (auto EC = Callbacks.visitUnknownSymbol(Record))
      37           0 :       return EC;
      38             :     break;
      39             : #define SYMBOL_RECORD(EnumName, EnumVal, Name)                                 \
      40             :   case EnumName: {                                                             \
      41             :     if (auto EC = visitKnownRecord<Name>(Record, Callbacks))                   \
      42             :       return EC;                                                               \
      43             :     break;                                                                     \
      44             :   }
      45             : #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)                \
      46             :   SYMBOL_RECORD(EnumVal, EnumVal, AliasName)
      47             : #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
      48             :   }
      49             : 
      50        3381 :   if (auto EC = Callbacks.visitSymbolEnd(Record))
      51           0 :     return EC;
      52             : 
      53        3381 :   return Error::success();
      54             : }
      55             : 
      56         909 : Error CVSymbolVisitor::visitSymbolRecord(CVSymbol &Record) {
      57        2727 :   if (auto EC = Callbacks.visitSymbolBegin(Record))
      58           0 :     return EC;
      59         909 :   return finishVisitation(Record, Callbacks);
      60             : }
      61             : 
      62         218 : Error CVSymbolVisitor::visitSymbolRecord(CVSymbol &Record, uint32_t Offset) {
      63         654 :   if (auto EC = Callbacks.visitSymbolBegin(Record, Offset))
      64           0 :     return EC;
      65         218 :   return finishVisitation(Record, Callbacks);
      66             : }
      67             : 
      68         273 : Error CVSymbolVisitor::visitSymbolStream(const CVSymbolArray &Symbols) {
      69        4032 :   for (auto I : Symbols) {
      70        2667 :     if (auto EC = visitSymbolRecord(I))
      71           0 :       return EC;
      72             :   }
      73         819 :   return Error::success();
      74             : }
      75             : 
      76          27 : Error CVSymbolVisitor::visitSymbolStream(const CVSymbolArray &Symbols,
      77             :                                          uint32_t InitialOffset) {
      78         696 :   for (auto I : Symbols) {
      79         561 :     if (auto EC = visitSymbolRecord(I, InitialOffset))
      80           0 :       return EC;
      81         187 :     InitialOffset += I.length();
      82             :   }
      83          81 :   return Error::success();
      84             : }

Generated by: LCOV version 1.13