LLVM  10.0.0svn
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 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
std::unique_ptr< IPDBEnumChildren< PDBSymbolCompiland > > getCompilands() const override
PDB_Checksum
Specifies the hash algorithm that a source file from a PDB was hashed with.
Definition: PDBTypes.h:117
uint32_t getUniqueId() const override
std::string getChecksum() const override
std::string invokeBstrMethod(Obj &Object, HRESULT(__stdcall Obj::*Func)(BSTR *))
Definition: DIAUtils.h:16
PDB_Checksum getChecksumType() const override
DIASourceFile(const DIASession &Session, CComPtr< IDiaSourceFile > DiaSourceFile)
std::string getFileName() const override