llvm-project/llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp
serge-sans-paille 81cde474e2 Cleanup LLVMDebugInfoCodeView headers
Major user-facing changes:

Many headers in llvm/DebugInfo/CodeView no longer include
llvm/Support/BinaryStreamReader.h or llvm/Support/BinaryStreamWriter.h,
those headers may need to be included manually.

Several headers in llvm/DebugInfo/CodeView no longer include
llvm/DebugInfo/CodeView/EnumTables.h or llvm/DebugInfo/CodeView/CodeView.h,
those headers may need to be included manually.

Some statistics:
$ clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/DebugInfo/CodeView/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l
after:  2794466
before: 2832765

Discourse thread on the topic: https://discourse.llvm.org/t/include-what-you-use-include-cleanup/

Differential Revision: https://reviews.llvm.org/D119092
2022-02-08 16:00:36 +01:00

54 lines
1.8 KiB
C++

//===- DebugCrossExSubsection.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/Support/BinaryStreamReader.h"
#include "llvm/Support/BinaryStreamWriter.h"
#include "llvm/Support/Error.h"
#include <cstdint>
using namespace llvm;
using namespace llvm::codeview;
Error DebugCrossModuleExportsSubsectionRef::initialize(
BinaryStreamReader Reader) {
if (Reader.bytesRemaining() % sizeof(CrossModuleExport) != 0)
return make_error<CodeViewError>(
cv_error_code::corrupt_record,
"Cross Scope Exports section is an invalid size!");
uint32_t Size = Reader.bytesRemaining() / sizeof(CrossModuleExport);
return Reader.readArray(References, Size);
}
Error DebugCrossModuleExportsSubsectionRef::initialize(BinaryStreamRef Stream) {
BinaryStreamReader Reader(Stream);
return initialize(Reader);
}
void DebugCrossModuleExportsSubsection::addMapping(uint32_t Local,
uint32_t Global) {
Mappings[Local] = Global;
}
uint32_t DebugCrossModuleExportsSubsection::calculateSerializedSize() const {
return Mappings.size() * sizeof(CrossModuleExport);
}
Error DebugCrossModuleExportsSubsection::commit(
BinaryStreamWriter &Writer) const {
for (const auto &M : Mappings) {
if (auto EC = Writer.writeInteger(M.first))
return EC;
if (auto EC = Writer.writeInteger(M.second))
return EC;
}
return Error::success();
}