LLVM  4.0.0
InfoStream.cpp
Go to the documentation of this file.
1 //===- InfoStream.cpp - PDB Info Stream (Stream 1) Access -------*- C++ -*-===//
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 
11 #include "llvm/ADT/BitVector.h"
12 #include "llvm/ADT/SmallVector.h"
19 
20 using namespace llvm;
21 using namespace llvm::codeview;
22 using namespace llvm::msf;
23 using namespace llvm::pdb;
24 
25 InfoStream::InfoStream(std::unique_ptr<MappedBlockStream> Stream)
26  : Stream(std::move(Stream)) {}
27 
29  StreamReader Reader(*Stream);
30 
31  const InfoStreamHeader *H;
32  if (auto EC = Reader.readObject(H))
33  return joinErrors(
34  std::move(EC),
35  make_error<RawError>(raw_error_code::corrupt_file,
36  "PDB Stream does not contain a header."));
37 
38  switch (H->Version) {
39  case PdbImplVC70:
40  case PdbImplVC80:
41  case PdbImplVC110:
42  case PdbImplVC140:
43  break;
44  default:
45  return make_error<RawError>(raw_error_code::corrupt_file,
46  "Unsupported PDB stream version.");
47  }
48 
49  Version = H->Version;
50  Signature = H->Signature;
51  Age = H->Age;
52  Guid = H->Guid;
53 
54  return NamedStreams.load(Reader);
55 }
56 
58  uint32_t Result;
59  if (!NamedStreams.tryGetValue(Name, Result))
60  return 0;
61  return Result;
62 }
63 
66  return NamedStreams.entries();
67 }
68 
70  return static_cast<PdbRaw_ImplVer>(Version);
71 }
72 
73 uint32_t InfoStream::getSignature() const { return Signature; }
74 
75 uint32_t InfoStream::getAge() const { return Age; }
76 
77 PDB_UniqueId InfoStream::getGuid() const { return Guid; }
support::ulittle32_t Version
Definition: RawTypes.h:299
iterator_range< StringMapConstIterator< uint32_t > > entries() const
Definition: NameMap.cpp:152
uint32_t getAge() const
Definition: InfoStream.cpp:75
support::ulittle32_t Signature
Definition: RawTypes.h:300
Error load(msf::StreamReader &Stream)
Definition: NameMap.cpp:27
uint32_t getSignature() const
Definition: InfoStream.cpp:73
bool tryGetValue(StringRef Name, uint32_t &Value) const
Definition: NameMap.cpp:157
iterator_range< StringMapConstIterator< uint32_t > > named_streams() const
Definition: InfoStream.cpp:65
support::ulittle32_t Age
Definition: RawTypes.h:301
Defines a 128-bit unique identifier.
Definition: RawTypes.h:265
#define H(x, y, z)
Definition: MD5.cpp:53
PDB_UniqueId getGuid() const
Definition: InfoStream.cpp:77
PdbRaw_ImplVer getVersion() const
Definition: InfoStream.cpp:69
The header preceeding the global PDB Stream (Stream 1)
Definition: RawTypes.h:298
A range adaptor for a pair of iterators.
Error joinErrors(Error E1, Error E2)
Concatenate errors.
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
uint32_t getNamedStreamIndex(llvm::StringRef Name) const
Definition: InfoStream.cpp:57
Error readObject(const T *&Dest)
Definition: StreamReader.h:53