Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Object/TapiUniversal.cpp
Show All 16 Lines | |||||
#include "llvm/TextAPI/MachO/TextAPIReader.h" | #include "llvm/TextAPI/MachO/TextAPIReader.h" | ||||
using namespace llvm; | using namespace llvm; | ||||
using namespace MachO; | using namespace MachO; | ||||
using namespace object; | using namespace object; | ||||
TapiUniversal::TapiUniversal(MemoryBufferRef Source, Error &Err) | TapiUniversal::TapiUniversal(MemoryBufferRef Source, Error &Err) | ||||
: Binary(ID_TapiUniversal, Source) { | : Binary(ID_TapiUniversal, Source) { | ||||
auto Result = TextAPIReader::get(Source); | Expected<std::unique_ptr<InterfaceFile>> Result = TextAPIReader::get(Source); | ||||
ErrorAsOutParameter ErrAsOuParam(&Err); | ErrorAsOutParameter ErrAsOuParam(&Err); | ||||
if (!Result) { | if (!Result) { | ||||
Err = Result.takeError(); | Err = Result.takeError(); | ||||
return; | return; | ||||
} | } | ||||
ParsedFile = std::move(Result.get()); | ParsedFile = std::move(Result.get()); | ||||
auto Archs = ParsedFile->getArchitectures(); | auto FlattenObjectInfo = [this](const auto &File) { | ||||
for (auto Arch : Archs) | StringRef Name = File->getInstallName(); | ||||
Architectures.emplace_back(Arch); | for (const Architecture Arch : File->getArchitectures()) | ||||
Libraries.emplace_back(Library({Name, Arch})); | |||||
}; | |||||
FlattenObjectInfo(ParsedFile); | |||||
// Get inlined documents from tapi file. | |||||
for (const std::shared_ptr<InterfaceFile> &File : ParsedFile->documents()) | |||||
FlattenObjectInfo(File); | |||||
} | } | ||||
jhenderson: I see `auto` was being used before in various places, but I'm not a fan where it's not clear… | |||||
TapiUniversal::~TapiUniversal() = default; | TapiUniversal::~TapiUniversal() = default; | ||||
Expected<std::unique_ptr<TapiFile>> | Expected<std::unique_ptr<TapiFile>> | ||||
TapiUniversal::ObjectForArch::getAsObjectFile() const { | TapiUniversal::ObjectForArch::getAsObjectFile() const { | ||||
return std::unique_ptr<TapiFile>(new TapiFile(Parent->getMemoryBufferRef(), | return std::unique_ptr<TapiFile>(new TapiFile(Parent->getMemoryBufferRef(), | ||||
*Parent->ParsedFile.get(), | *Parent->ParsedFile.get(), | ||||
Parent->Architectures[Index])); | Parent->Libraries[Index].Arch)); | ||||
} | } | ||||
Expected<std::unique_ptr<TapiUniversal>> | Expected<std::unique_ptr<TapiUniversal>> | ||||
TapiUniversal::create(MemoryBufferRef Source) { | TapiUniversal::create(MemoryBufferRef Source) { | ||||
Error Err = Error::success(); | Error Err = Error::success(); | ||||
std::unique_ptr<TapiUniversal> Ret(new TapiUniversal(Source, Err)); | std::unique_ptr<TapiUniversal> Ret(new TapiUniversal(Source, Err)); | ||||
if (Err) | if (Err) | ||||
return std::move(Err); | return std::move(Err); | ||||
return std::move(Ret); | return std::move(Ret); | ||||
} | } |
I see auto was being used before in various places, but I'm not a fan where it's not clear what the type is (which is the case in almost every instance in these two blocks). However, I'm not familiar with this area of the code base (i.e. the tapi stuff), so feel free to ignore me if this is common style in this area.