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/Error.h
"
16
#include "
llvm/Object/TapiFile.h
"
17
#include "
llvm/TextAPI/ArchitectureSet.h
"
18
#include "
llvm/TextAPI/TextAPIReader.h
"
19
20
using namespace
llvm
;
21
using namespace
MachO;
22
using namespace
object;
23
24
TapiUniversal::TapiUniversal
(
MemoryBufferRef
Source,
Error
&Err)
25
:
Binary
(ID_TapiUniversal, Source) {
26
Expected<std::unique_ptr<InterfaceFile>
> Result =
TextAPIReader::get
(Source);
27
ErrorAsOutParameter
ErrAsOuParam(&Err);
28
if
(!Result) {
29
Err = Result.takeError();
30
return
;
31
}
32
ParsedFile = std::move(Result.get());
33
34
auto
FlattenObjectInfo = [
this
](
const
auto
&File) {
35
StringRef
Name
= File->getInstallName();
36
for
(
const
Architecture
Arch : File->getArchitectures())
37
Libraries.emplace_back(Library({
Name
, Arch}));
38
};
39
40
FlattenObjectInfo(ParsedFile);
41
// Get inlined documents from tapi file.
42
for
(
const
std::shared_ptr<InterfaceFile> &File : ParsedFile->documents())
43
FlattenObjectInfo(File);
44
}
45
46
TapiUniversal::~TapiUniversal
() =
default
;
47
48
Expected<std::unique_ptr<TapiFile>
>
49
TapiUniversal::ObjectForArch::getAsObjectFile
()
const
{
50
return
std::make_unique<TapiFile>(Parent->
getMemoryBufferRef
(),
51
*Parent->ParsedFile,
52
Parent->Libraries[
Index
].Arch);
53
}
54
55
Expected<std::unique_ptr<TapiUniversal>
>
56
TapiUniversal::create
(
MemoryBufferRef
Source) {
57
Error
Err =
Error::success
();
58
std::unique_ptr<TapiUniversal> Ret(
new
TapiUniversal
(Source, Err));
59
if
(Err)
60
return
std::move(Err);
61
return
std::move(Ret);
62
}
ArchitectureSet.h
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:50
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:49
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:24
llvm::object::TapiUniversal::create
static Expected< std::unique_ptr< TapiUniversal > > create(MemoryBufferRef Source)
Definition:
TapiUniversal.cpp:56
Error.h
llvm::MachO::Architecture
Architecture
Defines the architecture slices that are supported by Text-based Stub files.
Definition:
Architecture.h:27
llvm::dwarf::Index
Index
Definition:
Dwarf.h:875
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:18
Generated on Mon Nov 25 2024 04:49:28 for LLVM by
1.9.6