1 //===- DebugCrossExSubsection.cpp -----------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
11 #include "llvm/DebugInfo/CodeView/CodeViewError.h"
12 #include "llvm/Support/BinaryStreamWriter.h"
13 #include "llvm/Support/Error.h"
17 using namespace llvm::codeview
;
19 Error
DebugCrossModuleExportsSubsectionRef::initialize(
20 BinaryStreamReader Reader
) {
21 if (Reader
.bytesRemaining() % sizeof(CrossModuleExport
) != 0)
22 return make_error
<CodeViewError
>(
23 cv_error_code::corrupt_record
,
24 "Cross Scope Exports section is an invalid size!");
26 uint32_t Size
= Reader
.bytesRemaining() / sizeof(CrossModuleExport
);
27 return Reader
.readArray(References
, Size
);
30 Error
DebugCrossModuleExportsSubsectionRef::initialize(BinaryStreamRef Stream
) {
31 BinaryStreamReader
Reader(Stream
);
32 return initialize(Reader
);
35 void DebugCrossModuleExportsSubsection::addMapping(uint32_t Local
,
37 Mappings
[Local
] = Global
;
40 uint32_t DebugCrossModuleExportsSubsection::calculateSerializedSize() const {
41 return Mappings
.size() * sizeof(CrossModuleExport
);
44 Error
DebugCrossModuleExportsSubsection::commit(
45 BinaryStreamWriter
&Writer
) const {
46 for (const auto &M
: Mappings
) {
47 if (auto EC
= Writer
.writeInteger(M
.first
))
49 if (auto EC
= Writer
.writeInteger(M
.second
))
52 return Error::success();