]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r301441, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / DebugInfo / PDB / Native / NativeExeSymbol.cpp
1 //===- NativeExeSymbol.cpp - native impl for PDBSymbolExe -------*- 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/PDB/Native/NativeExeSymbol.h"
11
12 #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
13 #include "llvm/DebugInfo/PDB/Native/InfoStream.h"
14 #include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
15 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
16
17 namespace llvm {
18 namespace pdb {
19
20 NativeExeSymbol::NativeExeSymbol(NativeSession &Session)
21     : NativeRawSymbol(Session), File(Session.getPDBFile()) {}
22
23 std::unique_ptr<IPDBEnumSymbols>
24 NativeExeSymbol::findChildren(PDB_SymType Type) const {
25   switch (Type) {
26   case PDB_SymType::Compiland: {
27     auto Dbi = File.getPDBDbiStream();
28     if (Dbi) {
29       const auto Modules = Dbi->modules();
30       return std::unique_ptr<IPDBEnumSymbols>(
31           new NativeEnumModules(Session, Modules));
32     }
33     consumeError(Dbi.takeError());
34     break;
35   }
36   default:
37     break;
38   }
39   return nullptr;
40 }
41
42 uint32_t NativeExeSymbol::getAge() const {
43   auto IS = File.getPDBInfoStream();
44   if (IS)
45     return IS->getAge();
46   consumeError(IS.takeError());
47   return 0;
48 }
49
50 std::string NativeExeSymbol::getSymbolsFileName() const {
51   return File.getFilePath();
52 }
53
54 PDB_UniqueId NativeExeSymbol::getGuid() const {
55   auto IS = File.getPDBInfoStream();
56   if (IS)
57     return IS->getGuid();
58   consumeError(IS.takeError());
59   return PDB_UniqueId{{0}};
60 }
61
62 bool NativeExeSymbol::hasCTypes() const {
63   auto Dbi = File.getPDBDbiStream();
64   if (Dbi)
65     return Dbi->hasCTypes();
66   consumeError(Dbi.takeError());
67   return false;
68 }
69
70 bool NativeExeSymbol::hasPrivateSymbols() const {
71   auto Dbi = File.getPDBDbiStream();
72   if (Dbi)
73     return !Dbi->isStripped();
74   consumeError(Dbi.takeError());
75   return false;
76 }
77
78 } // namespace pdb
79 } // namespace llvm