LLVM 17.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
14using namespace llvm;
15using namespace llvm::pdb;
16
18 const codeview::FileChecksumEntry &Checksum)
19 : Session(Session), FileId(FileId), Checksum(Checksum) {}
20
21std::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
36uint32_t NativeSourceFile::getUniqueId() const { return FileId; }
37
38std::string NativeSourceFile::getChecksum() const {
39 return toStringRef(Checksum.Checksum).str();
40}
41
43 return static_cast<PDB_Checksum>(Checksum.Kind);
44}
45
46std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
48 return nullptr;
49}
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:222
std::string getChecksum() const override
NativeSourceFile(NativeSession &Session, uint32_t FileId, const codeview::FileChecksumEntry &Checksum)
PDB_Checksum getChecksumType() const override
std::string getFileName() const override
std::unique_ptr< IPDBEnumChildren< PDBSymbolCompiland > > getCompilands() const override
uint32_t getUniqueId() const override
Expected< PDBStringTable & > getStringTable()
Definition: PDBFile.cpp:367
StringRef toStringRef(const std::optional< DWARFFormValue > &V, StringRef Default={})
Take an optional DWARFFormValue and try to extract a string value from it.
PDB_Checksum
Specifies the hash algorithm that a source file from a PDB was hashed with.
Definition: PDBTypes.h:119
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1043