[Alignment][NFC] Use Align with TargetLowering::setMinFunctionAlignment
[llvm-core.git] / lib / DebugInfo / PDB / Native / DbiModuleDescriptor.cpp
blob5095efcdee3cf20be8320efcc723760ff8e61ad5
1 //===- DbiModuleDescriptor.cpp - PDB module information -------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
10 #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
11 #include "llvm/Support/BinaryStreamReader.h"
12 #include "llvm/Support/Endian.h"
13 #include "llvm/Support/Error.h"
14 #include "llvm/Support/MathExtras.h"
15 #include <cstdint>
17 using namespace llvm;
18 using namespace llvm::pdb;
19 using namespace llvm::support;
21 DbiModuleDescriptor::DbiModuleDescriptor() = default;
23 DbiModuleDescriptor::DbiModuleDescriptor(const DbiModuleDescriptor &Info) =
24 default;
26 DbiModuleDescriptor::~DbiModuleDescriptor() = default;
28 Error DbiModuleDescriptor::initialize(BinaryStreamRef Stream,
29 DbiModuleDescriptor &Info) {
30 BinaryStreamReader Reader(Stream);
31 if (auto EC = Reader.readObject(Info.Layout))
32 return EC;
34 if (auto EC = Reader.readCString(Info.ModuleName))
35 return EC;
37 if (auto EC = Reader.readCString(Info.ObjFileName))
38 return EC;
39 return Error::success();
42 bool DbiModuleDescriptor::hasECInfo() const {
43 return (Layout->Flags & ModInfoFlags::HasECFlagMask) != 0;
46 uint16_t DbiModuleDescriptor::getTypeServerIndex() const {
47 return (Layout->Flags & ModInfoFlags::TypeServerIndexMask) >>
48 ModInfoFlags::TypeServerIndexShift;
51 const SectionContrib &DbiModuleDescriptor::getSectionContrib() const {
52 return Layout->SC;
55 uint16_t DbiModuleDescriptor::getModuleStreamIndex() const {
56 return Layout->ModDiStream;
59 uint32_t DbiModuleDescriptor::getSymbolDebugInfoByteSize() const {
60 return Layout->SymBytes;
63 uint32_t DbiModuleDescriptor::getC11LineInfoByteSize() const {
64 return Layout->C11Bytes;
67 uint32_t DbiModuleDescriptor::getC13LineInfoByteSize() const {
68 return Layout->C13Bytes;
71 uint32_t DbiModuleDescriptor::getNumberOfFiles() const {
72 return Layout->NumFiles;
75 uint32_t DbiModuleDescriptor::getSourceFileNameIndex() const {
76 return Layout->SrcFileNameNI;
79 uint32_t DbiModuleDescriptor::getPdbFilePathNameIndex() const {
80 return Layout->PdbFilePathNI;
83 StringRef DbiModuleDescriptor::getModuleName() const { return ModuleName; }
85 StringRef DbiModuleDescriptor::getObjFileName() const { return ObjFileName; }
87 uint32_t DbiModuleDescriptor::getRecordLength() const {
88 uint32_t M = ModuleName.str().size() + 1;
89 uint32_t O = ObjFileName.str().size() + 1;
90 uint32_t Size = sizeof(ModuleInfoHeader) + M + O;
91 Size = alignTo(Size, 4);
92 return Size;