LLVM 20.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
14
15using namespace llvm;
16using namespace llvm::pdb;
17
19 const codeview::FileChecksumEntry &Checksum)
20 : Session(Session), FileId(FileId), Checksum(Checksum) {}
21
22std::string NativeSourceFile::getFileName() const {
23 auto ST = Session.getPDBFile().getStringTable();
24 if (!ST) {
25 consumeError(ST.takeError());
26 return "";
27 }
28 auto FileName = ST->getStringTable().getString(Checksum.FileNameOffset);
29 if (!FileName) {
30 consumeError(FileName.takeError());
31 return "";
32 }
33
34 return std::string(FileName.get());
35}
36
37uint32_t NativeSourceFile::getUniqueId() const { return FileId; }
38
39std::string NativeSourceFile::getChecksum() const {
40 return toStringRef(Checksum.Checksum).str();
41}
42
44 return static_cast<PDB_Checksum>(Checksum.Kind);
45}
46
47std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
49 return nullptr;
50}
This file contains some functions that are useful when dealing with strings.
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:215
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:366
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:1069