LLVM 20.0.0git
InjectedSourceStream.cpp
Go to the documentation of this file.
1//===- InjectedSourceStream.cpp - PDB Headerblock Stream Access -----------===//
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
10
17
18using namespace llvm;
19using namespace llvm::msf;
20using namespace llvm::support;
21using namespace llvm::pdb;
22
24 std::unique_ptr<MappedBlockStream> Stream)
25 : Stream(std::move(Stream)) {}
26
28 BinaryStreamReader Reader(*Stream);
29
30 if (auto EC = Reader.readObject(Header))
31 return EC;
32
33 if (Header->Version !=
35 return make_error<RawError>(raw_error_code::corrupt_file,
36 "Invalid headerblock header version");
37
38 if (auto EC = InjectedSourceTable.load(Reader))
39 return EC;
40
41 for (const auto& Entry : *this) {
42 if (Entry.second.Size != sizeof(SrcHeaderBlockEntry))
43 return make_error<RawError>(raw_error_code::corrupt_file,
44 "Invalid headerbock entry size");
45 if (Entry.second.Version !=
47 return make_error<RawError>(raw_error_code::corrupt_file,
48 "Invalid headerbock entry version");
49
50 // Check that all name references are valid.
51 auto Name = Strings.getStringForID(Entry.second.FileNI);
52 if (!Name)
53 return Name.takeError();
54 auto ObjName = Strings.getStringForID(Entry.second.ObjNI);
55 if (!ObjName)
56 return ObjName.takeError();
57 auto VName = Strings.getStringForID(Entry.second.VFileNI);
58 if (!VName)
59 return VName.takeError();
60 }
61
62 assert(Reader.bytesRemaining() == 0);
63 return Error::success();
64}
std::string Name
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Provides read only access to a subclass of BinaryStream.
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 bytesRemaining() const
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:337
Error load(BinaryStreamReader &Stream)
Definition: HashTable.h:116
Error reload(const PDBStringTable &Strings)
InjectedSourceStream(std::unique_ptr< msf::MappedBlockStream > Stream)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1856
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
A single file record entry within the /src/headerblock stream.
Definition: RawTypes.h:331
support::ulittle32_t Version
Definition: RawTypes.h:322