Path: blob/main/contrib/llvm-project/llvm/lib/DebugInfo/PDB/DIA/DIASourceFile.cpp
35293 views
//===- DIASourceFile.cpp - DIA implementation of IPDBSourceFile -*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/DebugInfo/PDB/DIA/DIASourceFile.h"9#include "llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h"10#include "llvm/DebugInfo/PDB/DIA/DIAEnumSymbols.h"11#include "llvm/DebugInfo/PDB/DIA/DIASession.h"12#include "llvm/DebugInfo/PDB/DIA/DIAUtils.h"13#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"1415using namespace llvm;16using namespace llvm::pdb;1718DIASourceFile::DIASourceFile(const DIASession &PDBSession,19CComPtr<IDiaSourceFile> DiaSourceFile)20: Session(PDBSession), SourceFile(DiaSourceFile) {}2122std::string DIASourceFile::getFileName() const {23return invokeBstrMethod(*SourceFile, &IDiaSourceFile::get_fileName);24}2526uint32_t DIASourceFile::getUniqueId() const {27DWORD Id;28return (S_OK == SourceFile->get_uniqueId(&Id)) ? Id : 0;29}3031std::string DIASourceFile::getChecksum() const {32DWORD ByteSize = 0;33HRESULT Result = SourceFile->get_checksum(0, &ByteSize, nullptr);34if (ByteSize == 0)35return std::string();36std::vector<BYTE> ChecksumBytes(ByteSize);37Result = SourceFile->get_checksum(ByteSize, &ByteSize, &ChecksumBytes[0]);38if (S_OK != Result)39return std::string();40return std::string(ChecksumBytes.begin(), ChecksumBytes.end());41}4243PDB_Checksum DIASourceFile::getChecksumType() const {44DWORD Type;45HRESULT Result = SourceFile->get_checksumType(&Type);46if (S_OK != Result)47return PDB_Checksum::None;48return static_cast<PDB_Checksum>(Type);49}5051std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>52DIASourceFile::getCompilands() const {53CComPtr<IDiaEnumSymbols> DiaEnumerator;54HRESULT Result = SourceFile->get_compilands(&DiaEnumerator);55if (S_OK != Result)56return nullptr;5758auto Enumerator = std::unique_ptr<IPDBEnumSymbols>(59new DIAEnumSymbols(Session, DiaEnumerator));60return std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>(61new ConcreteSymbolEnumerator<PDBSymbolCompiland>(std::move(Enumerator)));62}636465