1 //===- DIASourceFile.cpp - DIA implementation of IPDBSourceFile -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/DebugInfo/PDB/DIA/DIASourceFile.h"
11 #include "llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h"
12 #include "llvm/DebugInfo/PDB/DIA/DIAEnumSymbols.h"
13 #include "llvm/DebugInfo/PDB/DIA/DIASession.h"
14 #include "llvm/DebugInfo/PDB/DIA/DIAUtils.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
18 using namespace llvm::pdb;
20 DIASourceFile::DIASourceFile(const DIASession &PDBSession,
21 CComPtr<IDiaSourceFile> DiaSourceFile)
22 : Session(PDBSession), SourceFile(DiaSourceFile) {}
24 std::string DIASourceFile::getFileName() const {
25 return invokeBstrMethod(*SourceFile, &IDiaSourceFile::get_fileName);
28 uint32_t DIASourceFile::getUniqueId() const {
30 return (S_OK == SourceFile->get_uniqueId(&Id)) ? Id : 0;
33 std::string DIASourceFile::getChecksum() const {
35 HRESULT Result = SourceFile->get_checksum(0, &ByteSize, nullptr);
38 std::vector<BYTE> ChecksumBytes(ByteSize);
39 Result = SourceFile->get_checksum(ByteSize, &ByteSize, &ChecksumBytes[0]);
42 return std::string(ChecksumBytes.begin(), ChecksumBytes.end());
45 PDB_Checksum DIASourceFile::getChecksumType() const {
47 HRESULT Result = SourceFile->get_checksumType(&Type);
49 return PDB_Checksum::None;
50 return static_cast<PDB_Checksum>(Type);
53 std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
54 DIASourceFile::getCompilands() const {
55 CComPtr<IDiaEnumSymbols> DiaEnumerator;
56 HRESULT Result = SourceFile->get_compilands(&DiaEnumerator);
60 auto Enumerator = std::unique_ptr<IPDBEnumSymbols>(
61 new DIAEnumSymbols(Session, DiaEnumerator));
62 return std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>(
63 new ConcreteSymbolEnumerator<PDBSymbolCompiland>(std::move(Enumerator)));