LLVM  10.0.0svn
DbiModuleDescriptor.cpp
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
8 
12 #include "llvm/Support/Endian.h"
13 #include "llvm/Support/Error.h"
15 #include <cstdint>
16 
17 using namespace llvm;
18 using namespace llvm::pdb;
19 using namespace llvm::support;
20 
22 
24  default;
25 
27 
30  BinaryStreamReader Reader(Stream);
31  if (auto EC = Reader.readObject(Info.Layout))
32  return EC;
33 
34  if (auto EC = Reader.readCString(Info.ModuleName))
35  return EC;
36 
37  if (auto EC = Reader.readCString(Info.ObjFileName))
38  return EC;
39  return Error::success();
40 }
41 
43  return (Layout->Flags & ModInfoFlags::HasECFlagMask) != 0;
44 }
45 
47  return (Layout->Flags & ModInfoFlags::TypeServerIndexMask) >>
49 }
50 
52  return Layout->SC;
53 }
54 
56  return Layout->ModDiStream;
57 }
58 
60  return Layout->SymBytes;
61 }
62 
64  return Layout->C11Bytes;
65 }
66 
68  return Layout->C13Bytes;
69 }
70 
72  return Layout->NumFiles;
73 }
74 
76  return Layout->SrcFileNameNI;
77 }
78 
80  return Layout->PdbFilePathNI;
81 }
82 
83 StringRef DbiModuleDescriptor::getModuleName() const { return ModuleName; }
84 
85 StringRef DbiModuleDescriptor::getObjFileName() const { return ObjFileName; }
86 
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;
93 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
static const uint16_t HasECFlagMask
uint16_t fWritten : 1; // True if DbiModuleDescriptor is dirty uint16_t fECEnabled : 1; // Is EC symb...
Definition: RawTypes.h:204
Error readObject(const T *&Dest)
Get a pointer to an object of type T from the underlying stream, as if by memcpy, and store the resul...
const SectionContrib & getSectionContrib() const
Error readCString(StringRef &Dest)
Read a null terminated string from Dest.
static Error initialize(BinaryStreamRef Stream, DbiModuleDescriptor &Info)
Analysis containing CSE Info
Definition: CSEInfo.cpp:20
The header preceding each entry in the Module Info substream of the DBI stream.
Definition: RawTypes.h:212
static const uint16_t TypeServerIndexShift
Definition: RawTypes.h:207
static ErrorSuccess success()
Create a success value.
Definition: Error.h:326
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:133
uint32_t Size
Definition: Profile.cpp:46
static const uint16_t TypeServerIndexMask
Definition: RawTypes.h:206
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48