]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp
MFV r316873: 7233 dir_is_empty should open directory with CLOEXEC
[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/ADT/STLExtras.h"
13 #include "llvm/DebugInfo/PDB/Native/DbiStream.h"
14 #include "llvm/DebugInfo/PDB/Native/InfoStream.h"
15 #include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
16 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
17
18 namespace llvm {
19 namespace pdb {
20
21 NativeExeSymbol::NativeExeSymbol(NativeSession &Session, SymIndexId SymbolId)
22     : NativeRawSymbol(Session, SymbolId), File(Session.getPDBFile()) {}
23
24 std::unique_ptr<NativeRawSymbol> NativeExeSymbol::clone() const {
25   return llvm::make_unique<NativeExeSymbol>(Session, SymbolId);
26 }
27
28 std::unique_ptr<IPDBEnumSymbols>
29 NativeExeSymbol::findChildren(PDB_SymType Type) const {
30   switch (Type) {
31   case PDB_SymType::Compiland: {
32     auto Dbi = File.getPDBDbiStream();
33     if (Dbi) {
34       const DbiModuleList &Modules = Dbi->modules();
35       return std::unique_ptr<IPDBEnumSymbols>(
36           new NativeEnumModules(Session, Modules));
37     }
38     consumeError(Dbi.takeError());
39     break;
40   }
41   case PDB_SymType::Enum:
42     return Session.createTypeEnumerator(codeview::LF_ENUM);
43   default:
44     break;
45   }
46   return nullptr;
47 }
48
49 uint32_t NativeExeSymbol::getAge() const {
50   auto IS = File.getPDBInfoStream();
51   if (IS)
52     return IS->getAge();
53   consumeError(IS.takeError());
54   return 0;
55 }
56
57 std::string NativeExeSymbol::getSymbolsFileName() const {
58   return File.getFilePath();
59 }
60
61 codeview::GUID NativeExeSymbol::getGuid() const {
62   auto IS = File.getPDBInfoStream();
63   if (IS)
64     return IS->getGuid();
65   consumeError(IS.takeError());
66   return codeview::GUID{{0}};
67 }
68
69 bool NativeExeSymbol::hasCTypes() const {
70   auto Dbi = File.getPDBDbiStream();
71   if (Dbi)
72     return Dbi->hasCTypes();
73   consumeError(Dbi.takeError());
74   return false;
75 }
76
77 bool NativeExeSymbol::hasPrivateSymbols() const {
78   auto Dbi = File.getPDBDbiStream();
79   if (Dbi)
80     return !Dbi->isStripped();
81   consumeError(Dbi.takeError());
82   return false;
83 }
84
85 } // namespace pdb
86 } // namespace llvm