LLVM  10.0.0svn
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"
15 #include "llvm/Object/Error.h"
18 
19 using namespace llvm;
20 using namespace MachO;
21 using namespace object;
22 
23 TapiUniversal::TapiUniversal(MemoryBufferRef Source, Error &Err)
24  : Binary(ID_TapiUniversal, Source) {
25  auto Result = TextAPIReader::get(Source);
26  ErrorAsOutParameter ErrAsOuParam(&Err);
27  if (!Result) {
28  Err = Result.takeError();
29  return;
30  }
31  ParsedFile = std::move(Result.get());
32 
33  auto Archs = ParsedFile->getArchitectures();
34  for (auto Arch : Archs)
35  Architectures.emplace_back(Arch);
36 }
37 
39 
42  return std::unique_ptr<TapiFile>(new TapiFile(Parent->getMemoryBufferRef(),
43  *Parent->ParsedFile.get(),
44  Parent->Architectures[Index]));
45 }
46 
49  Error Err = Error::success();
50  std::unique_ptr<TapiUniversal> Ret(new TapiUniversal(Source, Err));
51  if (Err)
52  return std::move(Err);
53  return std::move(Ret);
54 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Tagged union holding either a T or a Error.
Definition: yaml2obj.h:21
TapiUniversal(MemoryBufferRef Source, Error &Err)
Expected< std::unique_ptr< TapiFile > > getAsObjectFile() const
static Expected< std::unique_ptr< TapiUniversal > > create(MemoryBufferRef Source)
static ErrorSuccess success()
Create a success value.
Definition: Error.h:326
Helper for Errors used as out-parameters.
Definition: Error.h:1035
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157