NativeSourceFile.cpp 1.5 KB

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