[llvm] [llvm-nm] Fix how inlined dylibs are reported from tbd files (PR #134498)

Zixu Wang via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 8 11:01:36 PDT 2025


================
@@ -29,25 +29,31 @@ TapiUniversal::TapiUniversal(MemoryBufferRef Source, Error &Err)
   }
   ParsedFile = std::move(Result.get());
 
-  auto FlattenObjectInfo = [this](const auto &File) {
+  auto FlattenObjectInfo = [this](const auto &File, size_t DocIdx) {
     StringRef Name = File->getInstallName();
     for (const Architecture Arch : File->getArchitectures())
-      Libraries.emplace_back(Library({Name, Arch}));
+      Libraries.emplace_back(Library({Name, Arch, DocIdx}));
   };
-
-  FlattenObjectInfo(ParsedFile);
+  size_t DocIdx = 0;
+  FlattenObjectInfo(ParsedFile, DocIdx);
   // Get inlined documents from tapi file.
   for (const std::shared_ptr<InterfaceFile> &File : ParsedFile->documents())
-    FlattenObjectInfo(File);
+    FlattenObjectInfo(File, DocIdx++);
----------------
zixu-w wrote:

Is it expected that both `ParsedFile` and the first file from `documents` are added with `DocIdx = 0`? If so I think it would be helpful to have doc and comments for what is a `DocumentIdx` and the logic here.

https://github.com/llvm/llvm-project/pull/134498


More information about the llvm-commits mailing list