LLVM  15.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 
13 
14 using namespace llvm;
15 using namespace llvm::pdb;
16 
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 
43  return static_cast<PDB_Checksum>(Checksum.Kind);
44 }
45 
46 std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
48  return nullptr;
49 }
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::pdb::NativeSourceFile::getUniqueId
uint32_t getUniqueId() const override
Definition: NativeSourceFile.cpp:36
llvm::pdb::NativeSourceFile::NativeSourceFile
NativeSourceFile(NativeSession &Session, uint32_t FileId, const codeview::FileChecksumEntry &Checksum)
Definition: NativeSourceFile.cpp:17
llvm::pdb::NativeSession::getPDBFile
PDBFile & getPDBFile()
Definition: NativeSession.h:109
llvm::pdb::NativeSourceFile::getCompilands
std::unique_ptr< IPDBEnumChildren< PDBSymbolCompiland > > getCompilands() const override
Definition: NativeSourceFile.cpp:47
llvm::codeview::FileChecksumEntry::FileNameOffset
uint32_t FileNameOffset
Definition: DebugChecksumsSubsection.h:34
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1043
llvm::pdb::NativeSourceFile::getChecksum
std::string getChecksum() const override
Definition: NativeSourceFile.cpp:38
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:193
llvm::codeview::FileChecksumEntry
Definition: DebugChecksumsSubsection.h:33
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:35
llvm::pdb::PDBFile::getStringTable
Expected< PDBStringTable & > getStringTable()
Definition: PDBFile.cpp:367
uint32_t
llvm::pdb::NativeSourceFile::getFileName
std::string getFileName() const override
Definition: NativeSourceFile.cpp:21
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:32
PDBStringTable.h
llvm::codeview::FileChecksumEntry::Checksum
ArrayRef< uint8_t > Checksum
Definition: DebugChecksumsSubsection.h:36
PDBFile.h
llvm::pdb::NativeSourceFile::getChecksumType
PDB_Checksum getChecksumType() const override
Definition: NativeSourceFile.cpp:42
NativeSession.h