LLVM  14.0.0git
NativeSourceFile.cpp
Go to the documentation of this file.
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 
11 
12 using namespace llvm;
13 using namespace llvm::pdb;
14 
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 
41  return static_cast<PDB_Checksum>(Checksum.Kind);
42 }
43 
44 std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
46  return nullptr;
47 }
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::pdb::NativeSourceFile::getUniqueId
uint32_t getUniqueId() const override
Definition: NativeSourceFile.cpp:34
llvm::pdb::NativeSourceFile::NativeSourceFile
NativeSourceFile(NativeSession &Session, uint32_t FileId, const codeview::FileChecksumEntry &Checksum)
Definition: NativeSourceFile.cpp:15
llvm::pdb::NativeSession::getPDBFile
PDBFile & getPDBFile()
Definition: NativeSession.h:105
llvm::pdb::NativeSourceFile::getCompilands
std::unique_ptr< IPDBEnumChildren< PDBSymbolCompiland > > getCompilands() const override
Definition: NativeSourceFile.cpp:45
llvm::codeview::FileChecksumEntry::FileNameOffset
uint32_t FileNameOffset
Definition: DebugChecksumsSubsection.h:32
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1035
llvm::pdb::NativeSourceFile::getChecksum
std::string getChecksum() const override
Definition: NativeSourceFile.cpp:36
llvm::dwarf::toStringRef
StringRef toStringRef(const Optional< DWARFFormValue > &V, StringRef Default={})
Take an optional DWARFFormValue and try to extract a string value from it.
Definition: DWARFFormValue.h:186
llvm::codeview::FileChecksumEntry
Definition: DebugChecksumsSubsection.h:31
llvm::StringRef::str
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:245
llvm::pdb
Definition: ConcreteSymbolEnumerator.h:20
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
llvm::codeview::FileChecksumEntry::Kind
FileChecksumKind Kind
Definition: DebugChecksumsSubsection.h:33
llvm::pdb::PDBFile::getStringTable
Expected< PDBStringTable & > getStringTable()
Definition: PDBFile.cpp:368
uint32_t
llvm::pdb::NativeSourceFile::getFileName
std::string getFileName() const override
Definition: NativeSourceFile.cpp:19
llvm::pdb::PDB_Checksum
PDB_Checksum
Specifies the hash algorithm that a source file from a PDB was hashed with.
Definition: PDBTypes.h:119
NativeSourceFile.h
llvm::pdb::NativeSession
Definition: NativeSession.h:28
llvm::codeview::FileChecksumEntry::Checksum
ArrayRef< uint8_t > Checksum
Definition: DebugChecksumsSubsection.h:34
llvm::pdb::NativeSourceFile::getChecksumType
PDB_Checksum getChecksumType() const override
Definition: NativeSourceFile.cpp:40
NativeSession.h