LLVM 20.0.0git
TapiUniversal.cpp
Go to the documentation of this file.
1//===- TapiUniversal.cpp --------------------------------------------------===//
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//
9// This file defines the Text-based Dynamic Library Stub format.
10//
11//===----------------------------------------------------------------------===//
12
14#include "llvm/ADT/StringRef.h"
17
18using namespace llvm;
19using namespace MachO;
20using namespace object;
21
23 : Binary(ID_TapiUniversal, Source) {
25 ErrorAsOutParameter ErrAsOuParam(Err);
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 StringRef Name = File->getInstallName();
34 for (const Architecture Arch : File->getArchitectures())
35 Libraries.emplace_back(Library({Name, Arch}));
36 };
37
38 FlattenObjectInfo(ParsedFile);
39 // Get inlined documents from tapi file.
40 for (const std::shared_ptr<InterfaceFile> &File : ParsedFile->documents())
41 FlattenObjectInfo(File);
42}
43
45
48 return std::make_unique<TapiFile>(Parent->getMemoryBufferRef(),
49 *Parent->ParsedFile,
50 Parent->Libraries[Index].Arch);
51}
52
55 Error Err = Error::success();
56 std::unique_ptr<TapiUniversal> Ret(new TapiUniversal(Source, Err));
57 if (Err)
58 return std::move(Err);
59 return std::move(Ret);
60}
std::string Name
Helper for Errors used as out-parameters.
Definition: Error.h:1130
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:337
Tagged union holding either a T or a Error.
Definition: Error.h:481
static Expected< std::unique_ptr< InterfaceFile > > get(MemoryBufferRef InputBuffer)
Parse and get an InterfaceFile that represents the full library.
Definition: TextStub.cpp:1099
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
MemoryBufferRef getMemoryBufferRef() const
Definition: Binary.cpp:43
Expected< std::unique_ptr< TapiFile > > getAsObjectFile() const
TapiUniversal(MemoryBufferRef Source, Error &Err)
static Expected< std::unique_ptr< TapiUniversal > > create(MemoryBufferRef Source)
Architecture
Defines the architecture slices that are supported by Text-based Stub files.
Definition: Architecture.h:27
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18