LCOV - code coverage report
Current view: top level - lib/DebugInfo/CodeView - CVSymbolVisitor.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 21 24 87.5 %
Date: 2018-06-17 00:07:59 Functions: 36 44 81.8 %
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             : 
      15             : using namespace llvm;
      16             : using namespace llvm::codeview;
      17             : 
      18         398 : CVSymbolVisitor::CVSymbolVisitor(SymbolVisitorCallbacks &Callbacks)
      19         398 :     : Callbacks(Callbacks) {}
      20             : 
      21             : template <typename T>
      22        1682 : static Error visitKnownRecord(CVSymbol &Record,
      23             :                               SymbolVisitorCallbacks &Callbacks) {
      24        1682 :   SymbolRecordKind RK = static_cast<SymbolRecordKind>(Record.Type);
      25             :   T KnownRecord(RK);
      26        3364 :   if (auto EC = Callbacks.visitKnownRecord(Record, KnownRecord))
      27             :     return EC;
      28             :   return Error::success();
      29             : }
      30             : 
      31        1682 : static Error finishVisitation(CVSymbol &Record,
      32             :                               SymbolVisitorCallbacks &Callbacks) {
      33        1682 :   switch (Record.Type) {
      34           0 :   default:
      35           0 :     if (auto EC = Callbacks.visitUnknownSymbol(Record))
      36           0 :       return EC;
      37             :     break;
      38             : #define SYMBOL_RECORD(EnumName, EnumVal, Name)                                 \
      39             :   case EnumName: {                                                             \
      40             :     if (auto EC = visitKnownRecord<Name>(Record, Callbacks))                   \
      41             :       return EC;                                                               \
      42             :     break;                                                                     \
      43             :   }
      44             : #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)                \
      45             :   SYMBOL_RECORD(EnumVal, EnumVal, AliasName)
      46             : #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
      47             :   }
      48             : 
      49        3364 :   if (auto EC = Callbacks.visitSymbolEnd(Record))
      50             :     return EC;
      51             : 
      52             :   return Error::success();
      53             : }
      54             : 
      55        1361 : Error CVSymbolVisitor::visitSymbolRecord(CVSymbol &Record) {
      56        2722 :   if (auto EC = Callbacks.visitSymbolBegin(Record))
      57             :     return EC;
      58        1361 :   return finishVisitation(Record, Callbacks);
      59             : }
      60             : 
      61         321 : Error CVSymbolVisitor::visitSymbolRecord(CVSymbol &Record, uint32_t Offset) {
      62         642 :   if (auto EC = Callbacks.visitSymbolBegin(Record, Offset))
      63             :     return EC;
      64         321 :   return finishVisitation(Record, Callbacks);
      65             : }
      66             : 
      67         350 : Error CVSymbolVisitor::visitSymbolStream(const CVSymbolArray &Symbols) {
      68        1691 :   for (auto I : Symbols) {
      69        2682 :     if (auto EC = visitSymbolRecord(I))
      70             :       return EC;
      71             :   }
      72             :   return Error::success();
      73             : }
      74             : 
      75          34 : Error CVSymbolVisitor::visitSymbolStream(const CVSymbolArray &Symbols,
      76             :                                          uint32_t InitialOffset) {
      77         324 :   for (auto I : Symbols) {
      78         580 :     if (auto EC = visitSymbolRecord(I, InitialOffset))
      79             :       return EC;
      80         290 :     InitialOffset += I.length();
      81             :   }
      82             :   return Error::success();
      83             : }

Generated by: LCOV version 1.13