xref: /freebsd/contrib/llvm-project/llvm/lib/DebugInfo/PDB/Native/NativeSourceFile.cpp (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
1 //===- NativeSourceFile.cpp - Native line number implementaiton -*- 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/DebugInfo/PDB/Native/NativeSession.h"
11 
12 using namespace llvm;
13 using namespace llvm::pdb;
14 
15 NativeSourceFile::NativeSourceFile(NativeSession &Session, uint32_t FileId,
16                                    const codeview::FileChecksumEntry &Checksum)
17     : Session(Session), FileId(FileId), Checksum(Checksum) {}
18 
19 std::string NativeSourceFile::getFileName() const {
20   auto ST = Session.getPDBFile().getStringTable();
21   if (!ST) {
22     consumeError(ST.takeError());
23     return "";
24   }
25   auto FileName = ST->getStringTable().getString(Checksum.FileNameOffset);
26   if (!FileName) {
27     consumeError(FileName.takeError());
28     return "";
29   }
30 
31   return std::string(FileName.get());
32 }
33 
34 uint32_t NativeSourceFile::getUniqueId() const { return FileId; }
35 
36 std::string NativeSourceFile::getChecksum() const {
37   return toStringRef(Checksum.Checksum).str();
38 }
39 
40 PDB_Checksum NativeSourceFile::getChecksumType() const {
41   return static_cast<PDB_Checksum>(Checksum.Kind);
42 }
43 
44 std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
45 NativeSourceFile::getCompilands() const {
46   return nullptr;
47 }
48