1 | //===- NativeSourceFile.cpp - Native line number implementation -*- C++ -*-===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "llvm/DebugInfo/PDB/Native/NativeSourceFile.h" |
10 | #include "llvm/ADT/StringExtras.h" |
11 | #include "llvm/DebugInfo/PDB/Native/NativeSession.h" |
12 | #include "llvm/DebugInfo/PDB/Native/PDBFile.h" |
13 | #include "llvm/DebugInfo/PDB/Native/PDBStringTable.h" |
14 | |
15 | using namespace llvm; |
16 | using namespace llvm::pdb; |
17 | |
18 | NativeSourceFile::NativeSourceFile(NativeSession &Session, uint32_t FileId, |
19 | const codeview::FileChecksumEntry &Checksum) |
20 | : Session(Session), FileId(FileId), Checksum(Checksum) {} |
21 | |
22 | std::string NativeSourceFile::getFileName() const { |
23 | auto ST = Session.getPDBFile().getStringTable(); |
24 | if (!ST) { |
25 | consumeError(Err: ST.takeError()); |
26 | return ""; |
27 | } |
28 | auto FileName = ST->getStringTable().getString(Offset: Checksum.FileNameOffset); |
29 | if (!FileName) { |
30 | consumeError(Err: FileName.takeError()); |
31 | return ""; |
32 | } |
33 | |
34 | return std::string(FileName.get()); |
35 | } |
36 | |
37 | uint32_t NativeSourceFile::getUniqueId() const { return FileId; } |
38 | |
39 | std::string NativeSourceFile::getChecksum() const { |
40 | return toStringRef(Input: Checksum.Checksum).str(); |
41 | } |
42 | |
43 | PDB_Checksum NativeSourceFile::getChecksumType() const { |
44 | return static_cast<PDB_Checksum>(Checksum.Kind); |
45 | } |
46 | |
47 | std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> |
48 | NativeSourceFile::getCompilands() const { |
49 | return nullptr; |
50 | } |
51 |