aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/TapiUniversal.cpp
diff options
context:
space:
mode:
authorCyndy Ishida <cyndy_ishida@apple.com>2020-06-11 18:32:45 -0700
committerCyndy Ishida <cyndy_ishida@apple.com>2020-06-11 18:54:16 -0700
commit28fefcc83c52291fef817afbe469b4fd0a80ca20 (patch)
tree35fe435da1d85fe832e55fc6964ca88b2d5a9d8e /llvm/lib/Object/TapiUniversal.cpp
parent519b019a0a6cd50b34c90d1ec7004bb802d680e8 (diff)
downloadllvm-28fefcc83c52291fef817afbe469b4fd0a80ca20.zip
llvm-28fefcc83c52291fef817afbe469b4fd0a80ca20.tar.gz
llvm-28fefcc83c52291fef817afbe469b4fd0a80ca20.tar.bz2
[llvm][llvm-nm] add TextAPI/MachO support
Summary: This completes the needed glueing to support reading tbd files from nm. This includes specifying which slice filtering with `--arch` and a new option specifically for tbd files `--add-inlinedinfo` which will show the reexported libraries that are appended in the tbd file. Reviewers: ributzka, steven_wu, JDevlieghere, jhenderson Reviewed By: JDevlieghere Subscribers: hiraditya, MaskRay, dexonsmith, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D81614
Diffstat (limited to 'llvm/lib/Object/TapiUniversal.cpp')
-rw-r--r--llvm/lib/Object/TapiUniversal.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/Object/TapiUniversal.cpp b/llvm/lib/Object/TapiUniversal.cpp
index b3273e3..48cb949 100644
--- a/llvm/lib/Object/TapiUniversal.cpp
+++ b/llvm/lib/Object/TapiUniversal.cpp
@@ -22,7 +22,7 @@ using namespace object;
TapiUniversal::TapiUniversal(MemoryBufferRef Source, Error &Err)
: Binary(ID_TapiUniversal, Source) {
- auto Result = TextAPIReader::get(Source);
+ Expected<std::unique_ptr<InterfaceFile>> Result = TextAPIReader::get(Source);
ErrorAsOutParameter ErrAsOuParam(&Err);
if (!Result) {
Err = Result.takeError();
@@ -30,9 +30,16 @@ TapiUniversal::TapiUniversal(MemoryBufferRef Source, Error &Err)
}
ParsedFile = std::move(Result.get());
- auto Archs = ParsedFile->getArchitectures();
- for (auto Arch : Archs)
- Architectures.emplace_back(Arch);
+ auto FlattenObjectInfo = [this](const auto &File) {
+ StringRef Name = File->getInstallName();
+ 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);
}
TapiUniversal::~TapiUniversal() = default;
@@ -41,7 +48,7 @@ Expected<std::unique_ptr<TapiFile>>
TapiUniversal::ObjectForArch::getAsObjectFile() const {
return std::unique_ptr<TapiFile>(new TapiFile(Parent->getMemoryBufferRef(),
*Parent->ParsedFile.get(),
- Parent->Architectures[Index]));
+ Parent->Libraries[Index].Arch));
}
Expected<std::unique_ptr<TapiUniversal>>