LCOV - code coverage report
Current view: top level - include/llvm/DebugInfo/PDB - PDBSymbol.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 27 44 61.4 %
Date: 2018-10-20 13:21:21 Functions: 12 28 42.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- PDBSymbol.h - base class for user-facing symbol types -----*- 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             : #ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOL_H
      11             : #define LLVM_DEBUGINFO_PDB_PDBSYMBOL_H
      12             : 
      13             : #include "ConcreteSymbolEnumerator.h"
      14             : #include "IPDBRawSymbol.h"
      15             : #include "PDBExtras.h"
      16             : #include "PDBTypes.h"
      17             : #include "llvm/ADT/STLExtras.h"
      18             : #include "llvm/Support/Casting.h"
      19             : 
      20             : #define FORWARD_SYMBOL_METHOD(MethodName)                                      \
      21             :   auto MethodName() const->decltype(RawSymbol->MethodName()) {                 \
      22             :     return RawSymbol->MethodName();                                            \
      23             :   }
      24             : 
      25             : #define FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(ConcreteType, PrivateName, \
      26             :                                                     PublicName)                \
      27             :   auto PublicName##Id() const->decltype(RawSymbol->PrivateName##Id()) {        \
      28             :     return RawSymbol->PrivateName##Id();                                       \
      29             :   }                                                                            \
      30             :   std::unique_ptr<ConcreteType> PublicName() const {                           \
      31             :     uint32_t Id = PublicName##Id();                                            \
      32             :     return getConcreteSymbolByIdHelper<ConcreteType>(Id);                      \
      33             :   }
      34             : 
      35             : #define FORWARD_SYMBOL_ID_METHOD_WITH_NAME(PrivateName, PublicName)            \
      36             :   FORWARD_CONCRETE_SYMBOL_ID_METHOD_WITH_NAME(PDBSymbol, PrivateName,          \
      37             :                                               PublicName)
      38             : 
      39             : #define FORWARD_SYMBOL_ID_METHOD(MethodName)                                   \
      40             :   FORWARD_SYMBOL_ID_METHOD_WITH_NAME(MethodName, MethodName)
      41             : 
      42             : namespace llvm {
      43             : 
      44             : class StringRef;
      45             : class raw_ostream;
      46             : 
      47             : namespace pdb {
      48             : class IPDBRawSymbol;
      49             : class IPDBSession;
      50             : 
      51             : #define DECLARE_PDB_SYMBOL_CONCRETE_TYPE(TagValue)                             \
      52             : private:                                                                       \
      53             :   using PDBSymbol::PDBSymbol;                                                  \
      54             :   friend class PDBSymbol;                                                      \
      55             :                                                                                \
      56             : public:                                                                        \
      57             :   static const PDB_SymType Tag = TagValue;                                     \
      58             :   static bool classof(const PDBSymbol *S) { return S->getSymTag() == Tag; }
      59             : 
      60             : #define DECLARE_PDB_SYMBOL_CUSTOM_TYPE(Condition)                              \
      61             : private:                                                                       \
      62             :   using PDBSymbol::PDBSymbol;                                                  \
      63             :   friend class PDBSymbol;                                                      \
      64             :                                                                                \
      65             : public:                                                                        \
      66             :   static bool classof(const PDBSymbol *S) { return Condition; }
      67             : 
      68             : /// PDBSymbol defines the base of the inheritance hierarchy for concrete symbol
      69             : /// types (e.g. functions, executables, vtables, etc).  All concrete symbol
      70             : /// types inherit from PDBSymbol and expose the exact set of methods that are
      71             : /// valid for that particular symbol type, as described in the Microsoft
      72             : /// reference "Lexical and Class Hierarchy of Symbol Types":
      73             : /// https://msdn.microsoft.com/en-us/library/370hs6k4.aspx
      74         953 : class PDBSymbol {
      75             :   static std::unique_ptr<PDBSymbol> createSymbol(const IPDBSession &PDBSession,
      76             :                                                  PDB_SymType Tag);
      77             : 
      78             : protected:
      79             :   explicit PDBSymbol(const IPDBSession &PDBSession);
      80             :   PDBSymbol(PDBSymbol &&Other);
      81             : 
      82             : public:
      83             :   static std::unique_ptr<PDBSymbol>
      84             :   create(const IPDBSession &PDBSession,
      85             :          std::unique_ptr<IPDBRawSymbol> RawSymbol);
      86             :   static std::unique_ptr<PDBSymbol> create(const IPDBSession &PDBSession,
      87             :                                            IPDBRawSymbol &RawSymbol);
      88             : 
      89             :   template <typename ConcreteT>
      90             :   static std::unique_ptr<ConcreteT>
      91             :   createAs(const IPDBSession &PDBSession,
      92             :            std::unique_ptr<IPDBRawSymbol> RawSymbol) {
      93             :     std::unique_ptr<PDBSymbol> S = create(PDBSession, std::move(RawSymbol));
      94             :     return unique_dyn_cast_or_null<ConcreteT>(std::move(S));
      95             :   }
      96             :   template <typename ConcreteT>
      97          19 :   static std::unique_ptr<ConcreteT> createAs(const IPDBSession &PDBSession,
      98             :                                              IPDBRawSymbol &RawSymbol) {
      99          19 :     std::unique_ptr<PDBSymbol> S = create(PDBSession, RawSymbol);
     100          19 :     return unique_dyn_cast_or_null<ConcreteT>(std::move(S));
     101             :   }
     102             : 
     103             :   virtual ~PDBSymbol();
     104             : 
     105             :   /// Dumps the contents of a symbol a raw_ostream.  By default this will just
     106             :   /// call dump() on the underlying RawSymbol, which allows us to discover
     107             :   /// unknown properties, but individual implementations of PDBSymbol may
     108             :   /// override the behavior to only dump known fields.
     109             :   virtual void dump(PDBSymDumper &Dumper) const = 0;
     110             : 
     111             :   /// For certain PDBSymbolTypes, dumps additional information for the type that
     112             :   /// normally goes on the right side of the symbol.
     113           0 :   virtual void dumpRight(PDBSymDumper &Dumper) const {}
     114             : 
     115             :   void defaultDump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowFlags,
     116             :                    PdbSymbolIdField RecurseFlags) const;
     117             :   void dumpProperties() const;
     118             :   void dumpChildStats() const;
     119             : 
     120             :   PDB_SymType getSymTag() const;
     121             :   uint32_t getSymIndexId() const;
     122             : 
     123           0 :   template <typename T> std::unique_ptr<T> findOneChild() const {
     124           0 :     auto Enumerator(findAllChildren<T>());
     125           0 :     if (!Enumerator)
     126             :       return nullptr;
     127           0 :     return Enumerator->getNext();
     128             :   }
     129           0 : 
     130           0 :   template <typename T>
     131         116 :   std::unique_ptr<ConcreteSymbolEnumerator<T>> findAllChildren() const {
     132         116 :     auto BaseIter = RawSymbol->findChildren(T::Tag);
     133         116 :     if (!BaseIter)
     134             :       return nullptr;
     135           0 :     return llvm::make_unique<ConcreteSymbolEnumerator<T>>(std::move(BaseIter));
     136           0 :   }
     137           0 :   std::unique_ptr<IPDBEnumSymbols> findAllChildren(PDB_SymType Type) const;
     138           0 :   std::unique_ptr<IPDBEnumSymbols> findAllChildren() const;
     139           0 : 
     140             :   std::unique_ptr<IPDBEnumSymbols>
     141             :   findChildren(PDB_SymType Type, StringRef Name,
     142             :                PDB_NameSearchFlags Flags) const;
     143          24 :   std::unique_ptr<IPDBEnumSymbols> findChildrenByRVA(PDB_SymType Type,
     144          24 :                                                      StringRef Name,
     145          24 :                                                      PDB_NameSearchFlags Flags,
     146             :                                                      uint32_t RVA) const;
     147             :   std::unique_ptr<IPDBEnumSymbols> findInlineFramesByRVA(uint32_t RVA) const;
     148             : 
     149           0 :   const IPDBRawSymbol &getRawSymbol() const { return *RawSymbol; }
     150           0 :   IPDBRawSymbol &getRawSymbol() { return *RawSymbol; }
     151           0 : 
     152           0 :   const IPDBSession &getSession() const { return Session; }
     153             : 
     154             :   std::unique_ptr<IPDBEnumSymbols> getChildStats(TagStats &Stats) const;
     155           3 : 
     156           3 : protected:
     157           3 :   std::unique_ptr<PDBSymbol> getSymbolByIdHelper(uint32_t Id) const;
     158             : 
     159             :   template <typename ConcreteType>
     160          22 :   std::unique_ptr<ConcreteType> getConcreteSymbolByIdHelper(uint32_t Id) const {
     161          23 :     return unique_dyn_cast_or_null<ConcreteType>(getSymbolByIdHelper(Id));
     162           1 :   }
     163           1 : 
     164             :   const IPDBSession &Session;
     165             :   std::unique_ptr<IPDBRawSymbol> OwnedRawSymbol;
     166             :   IPDBRawSymbol *RawSymbol = nullptr;
     167           1 : };
     168           1 : 
     169           1 : } // namespace llvm
     170             : }
     171             : 
     172             : #endif

Generated by: LCOV version 1.13