Path: blob/main/contrib/llvm-project/llvm/lib/DebugInfo/PDB/DIA/DIADataStream.cpp
35294 views
//===- DIADataStream.cpp - DIA implementation of IPDBDataStream -*- 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/DIADataStream.h"9#include "llvm/DebugInfo/PDB/DIA/DIAUtils.h"1011using namespace llvm;12using namespace llvm::pdb;1314DIADataStream::DIADataStream(CComPtr<IDiaEnumDebugStreamData> DiaStreamData)15: StreamData(DiaStreamData) {}1617uint32_t DIADataStream::getRecordCount() const {18LONG Count = 0;19return (S_OK == StreamData->get_Count(&Count)) ? Count : 0;20}2122std::string DIADataStream::getName() const {23return invokeBstrMethod(*StreamData, &IDiaEnumDebugStreamData::get_name);24}2526std::optional<DIADataStream::RecordType>27DIADataStream::getItemAtIndex(uint32_t Index) const {28RecordType Record;29DWORD RecordSize = 0;30StreamData->Item(Index, 0, &RecordSize, nullptr);31if (RecordSize == 0)32return std::nullopt;3334Record.resize(RecordSize);35if (S_OK != StreamData->Item(Index, RecordSize, &RecordSize, &Record[0]))36return std::nullopt;37return Record;38}3940bool DIADataStream::getNext(RecordType &Record) {41Record.clear();42DWORD RecordSize = 0;43ULONG CountFetched = 0;44StreamData->Next(1, 0, &RecordSize, nullptr, &CountFetched);45if (RecordSize == 0)46return false;4748Record.resize(RecordSize);49if (S_OK ==50StreamData->Next(1, RecordSize, &RecordSize, &Record[0], &CountFetched))51return false;52return true;53}5455void DIADataStream::reset() { StreamData->Reset(); }565758