Path: blob/main/contrib/llvm-project/llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp
35271 views
//===- DebugCrossExSubsection.cpp -----------------------------------------===//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/CodeView/DebugCrossExSubsection.h"9#include "llvm/DebugInfo/CodeView/CodeViewError.h"10#include "llvm/Support/BinaryStreamReader.h"11#include "llvm/Support/BinaryStreamWriter.h"12#include "llvm/Support/Error.h"13#include <cstdint>1415using namespace llvm;16using namespace llvm::codeview;1718Error DebugCrossModuleExportsSubsectionRef::initialize(19BinaryStreamReader Reader) {20if (Reader.bytesRemaining() % sizeof(CrossModuleExport) != 0)21return make_error<CodeViewError>(22cv_error_code::corrupt_record,23"Cross Scope Exports section is an invalid size!");2425uint32_t Size = Reader.bytesRemaining() / sizeof(CrossModuleExport);26return Reader.readArray(References, Size);27}2829Error DebugCrossModuleExportsSubsectionRef::initialize(BinaryStreamRef Stream) {30BinaryStreamReader Reader(Stream);31return initialize(Reader);32}3334void DebugCrossModuleExportsSubsection::addMapping(uint32_t Local,35uint32_t Global) {36Mappings[Local] = Global;37}3839uint32_t DebugCrossModuleExportsSubsection::calculateSerializedSize() const {40return Mappings.size() * sizeof(CrossModuleExport);41}4243Error DebugCrossModuleExportsSubsection::commit(44BinaryStreamWriter &Writer) const {45for (const auto &M : Mappings) {46if (auto EC = Writer.writeInteger(M.first))47return EC;48if (auto EC = Writer.writeInteger(M.second))49return EC;50}51return Error::success();52}535455