LLVM: lib/Object/TapiUniversal.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
17
18using namespace llvm;
19using namespace MachO;
20using namespace object;
21
26 if (!Result) {
27 Err = Result.takeError();
28 return;
29 }
30 ParsedFile = std::move(Result.get());
31
32 auto FlattenObjectInfo = [this](const auto &File,
33 std::optional<size_t> DocIdx = std::nullopt) {
34 StringRef Name = File->getInstallName();
35 for (const Architecture Arch : File->getArchitectures())
36 Libraries.emplace_back(Library({Name, Arch, DocIdx}));
37 };
38 FlattenObjectInfo(ParsedFile);
39
40 size_t DocIdx = 0;
41 for (const std::shared_ptr &File : ParsedFile->documents())
42 FlattenObjectInfo(File, DocIdx++);
43}
44
46
49 const auto &InlinedDocuments = Parent->ParsedFile->documents();
50 const Library &CurrLib = Parent->Libraries[Index];
52 (isTopLevelLib() || (CurrLib.DocumentIdx.has_value() &&
53 (InlinedDocuments.size() > *CurrLib.DocumentIdx))) &&
54 "Index into documents exceeds the container for them");
56 ? Parent->ParsedFile.get()
57 : InlinedDocuments[*CurrLib.DocumentIdx].get();
58 return std::make_unique(Parent->getMemoryBufferRef(), *IF,
59 CurrLib.Arch);
60}
61
65 std::unique_ptr Ret(new TapiUniversal(Source, Err));
66 if (Err)
67 return std::move(Err);
68 return std::move(Ret);
69}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Helper for Errors used as out-parameters.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Defines the interface file.
static LLVM_ABI Expected< std::unique_ptr< InterfaceFile > > get(MemoryBufferRef InputBuffer)
Parse and get an InterfaceFile that represents the full library.
StringRef - Represent a constant reference to a string, i.e.
Binary(unsigned int Type, MemoryBufferRef Source)
bool isTopLevelLib() const
LLVM_ABI Expected< std::unique_ptr< TapiFile > > getAsObjectFile() const
Definition TapiUniversal.cpp:48
~TapiUniversal() override
TapiUniversal(MemoryBufferRef Source, Error &Err)
Definition TapiUniversal.cpp:22
static Expected< std::unique_ptr< TapiUniversal > > create(MemoryBufferRef Source)
Definition TapiUniversal.cpp:63
Architecture
Defines the architecture slices that are supported by Text-based Stub files.
This is an optimization pass for GlobalISel generic memory operations.