LLVM
20.0.0git
lib
Object
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
13
#include "
llvm/Object/TapiUniversal.h
"
14
#include "
llvm/ADT/StringRef.h
"
15
#include "
llvm/Object/TapiFile.h
"
16
#include "
llvm/TextAPI/TextAPIReader.h
"
17
18
using namespace
llvm
;
19
using namespace
MachO;
20
using namespace
object;
21
22
TapiUniversal::TapiUniversal
(
MemoryBufferRef
Source,
Error
&Err)
23
:
Binary
(ID_TapiUniversal, Source) {
24
Expected<std::unique_ptr<InterfaceFile>
> Result =
TextAPIReader::get
(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
44
TapiUniversal::~TapiUniversal
() =
default
;
45
46
Expected<std::unique_ptr<TapiFile>
>
47
TapiUniversal::ObjectForArch::getAsObjectFile
()
const
{
48
return
std::make_unique<TapiFile>(Parent->
getMemoryBufferRef
(),
49
*Parent->ParsedFile,
50
Parent->Libraries[Index].Arch);
51
}
52
53
Expected<std::unique_ptr<TapiUniversal>
>
54
TapiUniversal::create
(
MemoryBufferRef
Source) {
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
}
Name
std::string Name
Definition:
ELFObjHandler.cpp:77
StringRef.h
TapiFile.h
TapiUniversal.h
TextAPIReader.h
llvm::ErrorAsOutParameter
Helper for Errors used as out-parameters.
Definition:
Error.h:1130
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition:
Error.h:160
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition:
Error.h:337
llvm::Expected
Tagged union holding either a T or a Error.
Definition:
Error.h:481
llvm::MachO::TextAPIReader::get
static Expected< std::unique_ptr< InterfaceFile > > get(MemoryBufferRef InputBuffer)
Parse and get an InterfaceFile that represents the full library.
Definition:
TextStub.cpp:1099
llvm::MemoryBufferRef
Definition:
MemoryBufferRef.h:22
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:51
llvm::object::Binary
Definition:
Binary.h:32
llvm::object::Binary::getMemoryBufferRef
MemoryBufferRef getMemoryBufferRef() const
Definition:
Binary.cpp:43
llvm::object::TapiUniversal::ObjectForArch::getAsObjectFile
Expected< std::unique_ptr< TapiFile > > getAsObjectFile() const
Definition:
TapiUniversal.cpp:47
llvm::object::TapiUniversal
Definition:
TapiUniversal.h:28
llvm::object::TapiUniversal::~TapiUniversal
~TapiUniversal() override
llvm::object::TapiUniversal::TapiUniversal
TapiUniversal(MemoryBufferRef Source, Error &Err)
Definition:
TapiUniversal.cpp:22
llvm::object::TapiUniversal::create
static Expected< std::unique_ptr< TapiUniversal > > create(MemoryBufferRef Source)
Definition:
TapiUniversal.cpp:54
llvm::MachO::Architecture
Architecture
Defines the architecture slices that are supported by Text-based Stub files.
Definition:
Architecture.h:27
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:18
Generated on Fri Dec 20 2024 03:27:57 for LLVM by
1.9.6