NativeSourceFile.cpp 1.6 KB

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