LCOV - code coverage report
Current view: top level - lib/ObjectYAML - DWARFVisitor.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 8 24 33.3 %
Date: 2018-10-20 13:21:21 Functions: 4 40 10.0 %
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             : /// 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           1 :   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          24 :   virtual void onEndCompileUnit(const Unit &CU) {}
      50           0 :   virtual void onStartDIE(const Unit &CU, const Entry &DIE) {}
      51          61 :   virtual void onEndDIE(const Unit &CU, const Entry &DIE) {}
      52         204 :   virtual void onForm(const AttributeAbbrev &AttAbbrev,
      53         204 :                       const FormValue &Value) {}
      54         204 :   /// @}
      55         204 : 
      56           0 :   /// Value visitors
      57           0 :   /// @{
      58             :   virtual void onValue(const uint8_t U) {}
      59             :   virtual void onValue(const uint16_t U) {}
      60             :   virtual void onValue(const uint32_t U) {}
      61             :   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           0 :   /// @}
      66           0 : 
      67           0 : public:
      68          31 :   VisitorImpl(T &DI) : DebugInfo(DI) {}
      69             : 
      70             :   virtual ~VisitorImpl() {}
      71             : 
      72           0 :   void traverseDebugInfo();
      73             : 
      74           0 : 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             : class ConstVisitor : public VisitorImpl<const Data> {
      90             : public:
      91             :   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