Path: blob/main/contrib/llvm-project/llvm/lib/DebugInfo/PDB/DIA/DIAInjectedSource.cpp
35293 views
//===- DIAInjectedSource.cpp - DIA impl for IPDBInjectedSource --*- 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/DIAInjectedSource.h"9#include "llvm/ADT/ArrayRef.h"10#include "llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h"11#include "llvm/DebugInfo/PDB/DIA/DIASession.h"12#include "llvm/DebugInfo/PDB/DIA/DIAUtils.h"1314using namespace llvm;15using namespace llvm::pdb;1617DIAInjectedSource::DIAInjectedSource(CComPtr<IDiaInjectedSource> DiaSourceFile)18: SourceFile(DiaSourceFile) {}1920uint32_t DIAInjectedSource::getCrc32() const {21DWORD Crc;22return (S_OK == SourceFile->get_crc(&Crc)) ? Crc : 0;23}2425uint64_t DIAInjectedSource::getCodeByteSize() const {26ULONGLONG Size;27return (S_OK == SourceFile->get_length(&Size)) ? Size : 0;28}2930std::string DIAInjectedSource::getFileName() const {31return invokeBstrMethod(*SourceFile, &IDiaInjectedSource::get_filename);32}3334std::string DIAInjectedSource::getObjectFileName() const {35return invokeBstrMethod(*SourceFile, &IDiaInjectedSource::get_objectFilename);36}3738std::string DIAInjectedSource::getVirtualFileName() const {39return invokeBstrMethod(*SourceFile,40&IDiaInjectedSource::get_virtualFilename);41}4243uint32_t DIAInjectedSource::getCompression() const {44DWORD Compression = 0;45if (S_OK != SourceFile->get_sourceCompression(&Compression))46return PDB_SourceCompression::None;47return static_cast<uint32_t>(Compression);48}4950std::string DIAInjectedSource::getCode() const {51DWORD DataSize;52if (S_OK != SourceFile->get_source(0, &DataSize, nullptr))53return "";5455std::vector<uint8_t> Buffer(DataSize);56if (S_OK != SourceFile->get_source(DataSize, &DataSize, Buffer.data()))57return "";58assert(Buffer.size() == DataSize);59return std::string(reinterpret_cast<const char *>(Buffer.data()),60Buffer.size());61}626364