b65089dd028b6ceeb46d21b2f5fc9b0f9206d9d9
[oota-llvm.git] / include / llvm / DebugInfo / PDB / PDBSymbol.h
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_IPDBSYMBOL_H
11 #define LLVM_DEBUGINFO_PDB_IPDBSYMBOL_H
12
13 #include <memory>
14
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/Support/Casting.h"
17
18 #include "IPDBRawSymbol.h"
19 #include "PDBTypes.h"
20
21 #define FORWARD_SYMBOL_METHOD(MethodName)                                      \
22   auto MethodName() const->decltype(RawSymbol->MethodName()) {                 \
23     return RawSymbol->MethodName();                                            \
24   }
25
26 namespace llvm {
27
28 class IPDBRawSymbol;
29 class raw_ostream;
30
31 /// PDBSymbol defines the base of the inheritance hierarchy for concrete symbol
32 /// types (e.g. functions, executables, vtables, etc).  All concrete symbol
33 /// types inherit from PDBSymbol and expose the exact set of methods that are
34 /// valid for that particular symbol type, as described in the Microsoft
35 /// reference "Lexical and Class Hierarchy of Symbol Types":
36 /// https://msdn.microsoft.com/en-us/library/370hs6k4.aspx
37 class PDBSymbol {
38 protected:
39   PDBSymbol(IPDBSession &PDBSession, std::unique_ptr<IPDBRawSymbol> Symbol);
40
41 public:
42   static std::unique_ptr<PDBSymbol>
43   create(IPDBSession &PDBSession, std::unique_ptr<IPDBRawSymbol> Symbol);
44
45   virtual ~PDBSymbol();
46
47   /// Dumps the contents of a symbol a raw_ostream.  By default this will just
48   /// call dump() on the underlying RawSymbol, which allows us to discover
49   /// unknown properties, but individual implementations of PDBSymbol may
50   /// override the behavior to only dump known fields.
51   virtual void dump(llvm::raw_ostream &OS) const;
52
53   PDB_SymType getSymTag() const;
54
55   std::unique_ptr<IPDBEnumSymbols>
56   findChildren(PDB_SymType Type, StringRef Name,
57                PDB_NameSearchFlags Flags) const;
58   std::unique_ptr<IPDBEnumSymbols> findChildrenByRVA(PDB_SymType Type,
59                                                      StringRef Name,
60                                                      PDB_NameSearchFlags Flags,
61                                                      uint32_t RVA) const;
62   std::unique_ptr<IPDBEnumSymbols> findInlineFramesByRVA(uint32_t RVA) const;
63
64 protected:
65   IPDBSession &Session;
66   const std::unique_ptr<IPDBRawSymbol> RawSymbol;
67 };
68
69 } // namespace llvm
70
71 #endif