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