[llvm] [readtapi] Ensure universal dylibs record the same input path location across slices (PR #80875)

Cyndy Ishida via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 6 09:05:27 PST 2024


https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/80875

resolves: https://github.com/llvm/llvm-project/issues/80868

>From bbf847b6f79585ca059dc6cd589277343d94b15d Mon Sep 17 00:00:00 2001
From: Cyndy Ishida <cyndy_ishida at apple.com>
Date: Tue, 6 Feb 2024 09:02:43 -0800
Subject: [PATCH] [readtapi] Ensure universal dylibs record the same input path
 location

resolves: https://github.com/llvm/llvm-project/issues/80868
---
 llvm/lib/TextAPI/BinaryReader/DylibReader.cpp | 1 +
 llvm/tools/llvm-readtapi/llvm-readtapi.cpp    | 1 +
 2 files changed, 2 insertions(+)

diff --git a/llvm/lib/TextAPI/BinaryReader/DylibReader.cpp b/llvm/lib/TextAPI/BinaryReader/DylibReader.cpp
index 40b57b5e40ea33..25b9499d189577 100644
--- a/llvm/lib/TextAPI/BinaryReader/DylibReader.cpp
+++ b/llvm/lib/TextAPI/BinaryReader/DylibReader.cpp
@@ -408,6 +408,7 @@ Expected<Records> DylibReader::readFile(MemoryBufferRef Buffer,
         Results.emplace_back(std::make_shared<RecordsSlice>(RecordsSlice({T})));
         if (auto Err = load(&Obj, *Results.back(), Opt, Arch))
           return std::move(Err);
+        Results.back()->getBinaryAttrs().Path = Buffer.getBufferIdentifier();
       }
       break;
     }
diff --git a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp
index 5944b1cd1f5910..80064ed9848517 100644
--- a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp
+++ b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp
@@ -199,6 +199,7 @@ static void stubifyImpl(std::unique_ptr<InterfaceFile> IF, Context &Ctx) {
   // TODO: Add inlining and magic merge support.
   if (Ctx.OutStream == nullptr) {
     std::error_code EC;
+    assert(!IF->getPath().empty() && "Unknown output location");
     SmallString<PATH_MAX> OutputLoc = IF->getPath();
     replace_extension(OutputLoc, ".tbd");
     Ctx.OutStream = std::make_unique<llvm::raw_fd_stream>(OutputLoc, EC);



More information about the llvm-commits mailing list