LLVM  10.0.0svn
DebugCrossExSubsection.cpp
Go to the documentation of this file.
1 //===- DebugCrossExSubsection.cpp -----------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
12 #include "llvm/Support/Error.h"
13 #include <cstdint>
14 
15 using namespace llvm;
16 using namespace llvm::codeview;
17 
19  BinaryStreamReader Reader) {
20  if (Reader.bytesRemaining() % sizeof(CrossModuleExport) != 0)
21  return make_error<CodeViewError>(
23  "Cross Scope Exports section is an invalid size!");
24 
25  uint32_t Size = Reader.bytesRemaining() / sizeof(CrossModuleExport);
26  return Reader.readArray(References, Size);
27 }
28 
30  BinaryStreamReader Reader(Stream);
31  return initialize(Reader);
32 }
33 
35  uint32_t Global) {
36  Mappings[Local] = Global;
37 }
38 
40  return Mappings.size() * sizeof(CrossModuleExport);
41 }
42 
44  BinaryStreamWriter &Writer) const {
45  for (const auto &M : Mappings) {
46  if (auto EC = Writer.writeInteger(M.first))
47  return EC;
48  if (auto EC = Writer.writeInteger(M.second))
49  return EC;
50  }
51  return Error::success();
52 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Provides write only access to a subclass of WritableBinaryStream.
Error commit(BinaryStreamWriter &Writer) const override
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
static ErrorSuccess success()
Create a success value.
Definition: Error.h:326
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
uint32_t Size
Definition: Profile.cpp:46
uint32_t bytesRemaining() const
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
Provides read only access to a subclass of BinaryStream.
Error readArray(ArrayRef< T > &Array, uint32_t NumElements)
Get a reference to a NumElements element array of objects of type T from the underlying stream as if ...
void addMapping(uint32_t Local, uint32_t Global)