LLVM 19.0.0git
DIASourceFile.cpp
Go to the documentation of this file.
1//===- DIASourceFile.cpp - DIA implementation of IPDBSourceFile -*- 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
15
16using namespace llvm;
17using namespace llvm::pdb;
18
20 CComPtr<IDiaSourceFile> DiaSourceFile)
21 : Session(PDBSession), SourceFile(DiaSourceFile) {}
22
23std::string DIASourceFile::getFileName() const {
24 return invokeBstrMethod(*SourceFile, &IDiaSourceFile::get_fileName);
25}
26
28 DWORD Id;
29 return (S_OK == SourceFile->get_uniqueId(&Id)) ? Id : 0;
30}
31
32std::string DIASourceFile::getChecksum() const {
33 DWORD ByteSize = 0;
34 HRESULT Result = SourceFile->get_checksum(0, &ByteSize, nullptr);
35 if (ByteSize == 0)
36 return std::string();
37 std::vector<BYTE> ChecksumBytes(ByteSize);
38 Result = SourceFile->get_checksum(ByteSize, &ByteSize, &ChecksumBytes[0]);
39 if (S_OK != Result)
40 return std::string();
41 return std::string(ChecksumBytes.begin(), ChecksumBytes.end());
42}
43
45 DWORD Type;
46 HRESULT Result = SourceFile->get_checksumType(&Type);
47 if (S_OK != Result)
48 return PDB_Checksum::None;
49 return static_cast<PDB_Checksum>(Type);
50}
51
52std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
54 CComPtr<IDiaEnumSymbols> DiaEnumerator;
55 HRESULT Result = SourceFile->get_compilands(&DiaEnumerator);
56 if (S_OK != Result)
57 return nullptr;
58
59 auto Enumerator = std::unique_ptr<IPDBEnumSymbols>(
60 new DIAEnumSymbols(Session, DiaEnumerator));
61 return std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>(
63}
std::string invokeBstrMethod(Obj &Object, HRESULT(__stdcall Obj::*Func)(BSTR *))
Definition: DIAUtils.h:16
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
uint32_t getUniqueId() const override
std::string getFileName() const override
std::unique_ptr< IPDBEnumChildren< PDBSymbolCompiland > > getCompilands() const override
DIASourceFile(const DIASession &Session, CComPtr< IDiaSourceFile > DiaSourceFile)
std::string getChecksum() const override
PDB_Checksum getChecksumType() const override
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