LLVM  8.0.1
DIASourceFile.cpp
Go to the documentation of this file.
1 //===- DIASourceFile.cpp - DIA implementation of IPDBSourceFile -*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
16 
17 using namespace llvm;
18 using namespace llvm::pdb;
19 
21  CComPtr<IDiaSourceFile> DiaSourceFile)
22  : Session(PDBSession), SourceFile(DiaSourceFile) {}
23 
24 std::string DIASourceFile::getFileName() const {
25  return invokeBstrMethod(*SourceFile, &IDiaSourceFile::get_fileName);
26 }
27 
29  DWORD Id;
30  return (S_OK == SourceFile->get_uniqueId(&Id)) ? Id : 0;
31 }
32 
33 std::string DIASourceFile::getChecksum() const {
34  DWORD ByteSize = 0;
35  HRESULT Result = SourceFile->get_checksum(0, &ByteSize, nullptr);
36  if (ByteSize == 0)
37  return std::string();
38  std::vector<BYTE> ChecksumBytes(ByteSize);
39  Result = SourceFile->get_checksum(ByteSize, &ByteSize, &ChecksumBytes[0]);
40  if (S_OK != Result)
41  return std::string();
42  return std::string(ChecksumBytes.begin(), ChecksumBytes.end());
43 }
44 
46  DWORD Type;
47  HRESULT Result = SourceFile->get_checksumType(&Type);
48  if (S_OK != Result)
49  return PDB_Checksum::None;
50  return static_cast<PDB_Checksum>(Type);
51 }
52 
53 std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
55  CComPtr<IDiaEnumSymbols> DiaEnumerator;
56  HRESULT Result = SourceFile->get_compilands(&DiaEnumerator);
57  if (S_OK != Result)
58  return nullptr;
59 
60  auto Enumerator = std::unique_ptr<IPDBEnumSymbols>(
61  new DIAEnumSymbols(Session, DiaEnumerator));
62  return std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>(
64 }
This class represents lattice values for constants.
Definition: AllocatorList.h:24
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:118
uint32_t getUniqueId() const override
std::string getChecksum() const override
std::string invokeBstrMethod(Obj &Object, HRESULT(__stdcall Obj::*Func)(BSTR *))
Definition: DIAUtils.h:17
PDB_Checksum getChecksumType() const override
DIASourceFile(const DIASession &Session, CComPtr< IDiaSourceFile > DiaSourceFile)
std::string getFileName() const override