xref: /llvm-project/llvm/lib/DebugInfo/CodeView/DebugSymbolsSubsection.cpp (revision 81cde474e2c5a6280cb693b777ddcf473825ae8a)
1591312c5SZachary Turner //===- DebugSymbolsSubsection.cpp -------------------------------*- C++ -*-===//
2591312c5SZachary Turner //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6591312c5SZachary Turner //
7591312c5SZachary Turner //===----------------------------------------------------------------------===//
8591312c5SZachary Turner 
9591312c5SZachary Turner #include "llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h"
10*81cde474Sserge-sans-paille #include "llvm/Support/BinaryStreamWriter.h"
11591312c5SZachary Turner 
12591312c5SZachary Turner using namespace llvm;
13591312c5SZachary Turner using namespace llvm::codeview;
14591312c5SZachary Turner 
initialize(BinaryStreamReader Reader)15591312c5SZachary Turner Error DebugSymbolsSubsectionRef::initialize(BinaryStreamReader Reader) {
16591312c5SZachary Turner   return Reader.readArray(Records, Reader.getLength());
17591312c5SZachary Turner }
18591312c5SZachary Turner 
calculateSerializedSize() const19591312c5SZachary Turner uint32_t DebugSymbolsSubsection::calculateSerializedSize() const {
20591312c5SZachary Turner   return Length;
21591312c5SZachary Turner }
22591312c5SZachary Turner 
commit(BinaryStreamWriter & Writer) const23591312c5SZachary Turner Error DebugSymbolsSubsection::commit(BinaryStreamWriter &Writer) const {
24591312c5SZachary Turner   for (const auto &Record : Records) {
25591312c5SZachary Turner     if (auto EC = Writer.writeBytes(Record.RecordData))
26591312c5SZachary Turner       return EC;
27591312c5SZachary Turner   }
28591312c5SZachary Turner   return Error::success();
29591312c5SZachary Turner }
30591312c5SZachary Turner 
addSymbol(CVSymbol Symbol)31591312c5SZachary Turner void DebugSymbolsSubsection::addSymbol(CVSymbol Symbol) {
32591312c5SZachary Turner   Records.push_back(Symbol);
33591312c5SZachary Turner   Length += Symbol.length();
34591312c5SZachary Turner }
35