LLVM  14.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 
16 using namespace llvm;
17 using namespace llvm::pdb;
18 
20  CComPtr<IDiaSourceFile> DiaSourceFile)
21  : Session(PDBSession), SourceFile(DiaSourceFile) {}
22 
23 std::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 
32 std::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 
52 std::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 }
llvm::pdb::DIASourceFile::getUniqueId
uint32_t getUniqueId() const override
Definition: DIASourceFile.cpp:27
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::pdb::DIASourceFile::getFileName
std::string getFileName() const override
Definition: DIASourceFile.cpp:23
DIAEnumSymbols.h
llvm::pdb::DIASession
Definition: DIASession.h:22
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::pdb::DIASourceFile::DIASourceFile
DIASourceFile(const DIASession &Session, CComPtr< IDiaSourceFile > DiaSourceFile)
Definition: DIASourceFile.cpp:19
invokeBstrMethod
std::string invokeBstrMethod(Obj &Object, HRESULT(__stdcall Obj::*Func)(BSTR *))
Definition: DIAUtils.h:16
DIAUtils.h
llvm::pdb::ConcreteSymbolEnumerator
Definition: ConcreteSymbolEnumerator.h:23
llvm::HighlightColor::Enumerator
@ Enumerator
llvm::pdb
Definition: ConcreteSymbolEnumerator.h:20
llvm::pdb::PDB_Checksum::None
@ None
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
PDBSymbolCompiland.h
llvm::AMDGPU::SDWA::DWORD
@ DWORD
Definition: SIDefines.h:653
DIASession.h
llvm::pdb::DIASourceFile::getChecksumType
PDB_Checksum getChecksumType() const override
Definition: DIASourceFile.cpp:44
DIASourceFile.h
llvm::pdb::DIASourceFile::getChecksum
std::string getChecksum() const override
Definition: DIASourceFile.cpp:32
uint32_t
llvm::pdb::DIASourceFile::getCompilands
std::unique_ptr< IPDBEnumChildren< PDBSymbolCompiland > > getCompilands() const override
Definition: DIASourceFile.cpp:53
llvm::pdb::PDB_Checksum
PDB_Checksum
Specifies the hash algorithm that a source file from a PDB was hashed with.
Definition: PDBTypes.h:119
llvm::pdb::DIAEnumSymbols
Definition: DIAEnumSymbols.h:20
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:228
ConcreteSymbolEnumerator.h