LCOV - code coverage report
Current view: top level - lib/ObjectYAML - DWARFVisitor.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 7 22 31.8 %
Date: 2017-09-14 15:23:50 Functions: 3 40 7.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===--- DWARFVisitor.h -----------------------------------------*- 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             : //===----------------------------------------------------------------------===//
      11             : 
      12             : #ifndef LLVM_OBJECTYAML_DWARFVISITOR_H
      13             : #define LLVM_OBJECTYAML_DWARFVISITOR_H
      14             : 
      15             : #include "llvm/ADT/StringRef.h"
      16             : #include "llvm/BinaryFormat/Dwarf.h"
      17             : #include "llvm/Support/MemoryBuffer.h"
      18             : 
      19             : namespace llvm {
      20             : 
      21             : namespace DWARFYAML {
      22             : 
      23             : struct Data;
      24             : struct Unit;
      25             : struct Entry;
      26             : struct FormValue;
      27             : struct AttributeAbbrev;
      28             : 
      29             : /// \brief A class to visits DWARFYAML Compile Units and DIEs in preorder.
      30             : ///
      31             : /// Extensions of this class can either maintain const or non-const references
      32             : /// to the DWARFYAML::Data object.
      33             : template <typename T> class VisitorImpl {
      34             : protected:
      35             :   T &DebugInfo;
      36             : 
      37             :   /// Visitor Functions
      38             :   /// @{
      39           0 :   virtual void onStartCompileUnit(Unit &CU) {}
      40           0 :   virtual void onEndCompileUnit(Unit &CU) {}
      41           0 :   virtual void onStartDIE(Unit &CU, Entry &DIE) {}
      42           0 :   virtual void onEndDIE(Unit &CU, Entry &DIE) {}
      43           0 :   virtual void onForm(AttributeAbbrev &AttAbbrev, FormValue &Value) {}
      44             :   /// @}
      45             : 
      46             :   /// Const Visitor Functions
      47             :   /// @{
      48           0 :   virtual void onStartCompileUnit(const Unit &CU) {}
      49          17 :   virtual void onEndCompileUnit(const Unit &CU) {}
      50           0 :   virtual void onStartDIE(const Unit &CU, const Entry &DIE) {}
      51          41 :   virtual void onEndDIE(const Unit &CU, const Entry &DIE) {}
      52         154 :   virtual void onForm(const AttributeAbbrev &AttAbbrev,
      53         154 :                       const FormValue &Value) {}
      54             :   /// @}
      55             : 
      56             :   /// Value visitors
      57             :   /// @{
      58           0 :   virtual void onValue(const uint8_t U) {}
      59           0 :   virtual void onValue(const uint16_t U) {}
      60           0 :   virtual void onValue(const uint32_t U) {}
      61           0 :   virtual void onValue(const uint64_t U, const bool LEB = false) {}
      62           0 :   virtual void onValue(const int64_t S, const bool LEB = false) {}
      63           0 :   virtual void onValue(const StringRef String) {}
      64           0 :   virtual void onValue(const MemoryBufferRef MBR) {}
      65             :   /// @}
      66             : 
      67             : public:
      68          23 :   VisitorImpl(T &DI) : DebugInfo(DI) {}
      69             : 
      70           0 :   virtual ~VisitorImpl() {}
      71             : 
      72             :   void traverseDebugInfo();
      73             : 
      74             : private:
      75             :   void onVariableSizeValue(uint64_t U, unsigned Size);
      76             : };
      77             : 
      78             : // Making the visior instantiations extern and explicit in the cpp file. This
      79             : // prevents them from being instantiated in every compile unit that uses the
      80             : // visitors.
      81             : extern template class VisitorImpl<DWARFYAML::Data>;
      82             : extern template class VisitorImpl<const DWARFYAML::Data>;
      83             : 
      84             : class Visitor : public VisitorImpl<Data> {
      85             : public:
      86             :   Visitor(Data &DI) : VisitorImpl<Data>(DI) {}
      87             : };
      88             : 
      89          23 : class ConstVisitor : public VisitorImpl<const Data> {
      90             : public:
      91          46 :   ConstVisitor(const Data &DI) : VisitorImpl<const Data>(DI) {}
      92             : };
      93             : 
      94             : } // namespace DWARFYAML
      95             : } // namespace llvm
      96             : 
      97             : #endif

Generated by: LCOV version 1.13