LLVM  8.0.1
DbiModuleDescriptor.cpp
Go to the documentation of this file.
1 //===- DbiModuleDescriptor.cpp - PDB module information -------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
13 #include "llvm/Support/Endian.h"
14 #include "llvm/Support/Error.h"
16 #include <cstdint>
17 
18 using namespace llvm;
19 using namespace llvm::pdb;
20 using namespace llvm::support;
21 
23 
25  default;
26 
28 
31  BinaryStreamReader Reader(Stream);
32  if (auto EC = Reader.readObject(Info.Layout))
33  return EC;
34 
35  if (auto EC = Reader.readCString(Info.ModuleName))
36  return EC;
37 
38  if (auto EC = Reader.readCString(Info.ObjFileName))
39  return EC;
40  return Error::success();
41 }
42 
44  return (Layout->Flags & ModInfoFlags::HasECFlagMask) != 0;
45 }
46 
48  return (Layout->Flags & ModInfoFlags::TypeServerIndexMask) >>
50 }
51 
53  return Layout->SC;
54 }
55 
57  return Layout->ModDiStream;
58 }
59 
61  return Layout->SymBytes;
62 }
63 
65  return Layout->C11Bytes;
66 }
67 
69  return Layout->C13Bytes;
70 }
71 
73  return Layout->NumFiles;
74 }
75 
77  return Layout->SrcFileNameNI;
78 }
79 
81  return Layout->PdbFilePathNI;
82 }
83 
84 StringRef DbiModuleDescriptor::getModuleName() const { return ModuleName; }
85 
86 StringRef DbiModuleDescriptor::getObjFileName() const { return ObjFileName; }
87 
89  uint32_t M = ModuleName.str().size() + 1;
90  uint32_t O = ObjFileName.str().size() + 1;
91  uint32_t Size = sizeof(ModuleInfoHeader) + M + O;
92  Size = alignTo(Size, 4);
93  return Size;
94 }
This class represents lattice values for constants.
Definition: AllocatorList.h:24
static const uint16_t HasECFlagMask
uint16_t fWritten : 1; // True if DbiModuleDescriptor is dirty uint16_t fECEnabled : 1; // Is EC symb...
Definition: RawTypes.h:205
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...
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
Definition: MathExtras.h:685
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:21
The header preceeding each entry in the Module Info substream of the DBI stream.
Definition: RawTypes.h:213
static const uint16_t TypeServerIndexShift
Definition: RawTypes.h:208
static ErrorSuccess success()
Create a success value.
Definition: Error.h:327
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
uint32_t Size
Definition: Profile.cpp:47
static const uint16_t TypeServerIndexMask
Definition: RawTypes.h:207
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49