[llvm] big archive recognition by the llvm-symbolizer (PR #150401)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 24 03:52:45 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
index 5144085f3..281c42782 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
@@ -30,9 +30,9 @@
 #include <vector>
 
 #if defined(_AIX)
-#  define SYMBOLIZE_AIX 1
+#define SYMBOLIZE_AIX 1
 #else
-#  define SYMBOLIZE_AIX 0
+#define SYMBOLIZE_AIX 0
 #endif
 
 namespace llvm {
@@ -210,9 +210,9 @@ private:
 
   /// Return a pointer to object file at specified path, for a specified
   /// architecture that is present inside an archive file
-  Expected<ObjectFile *> getOrCreateObjectFromArchive(StringRef ArchivePath,
-                                                      StringRef MemberName,
-                                                      const std::string &ArchName);   
+  Expected<ObjectFile *>
+  getOrCreateObjectFromArchive(StringRef ArchivePath, StringRef MemberName,
+                               const std::string &ArchName);
 
   /// Update the LRU cache order when a binary is accessed.
   void recordAccess(CachedBinary &Bin);
@@ -239,19 +239,20 @@ private:
       ObjectForUBPathAndArch;
 
   struct ArchiveCacheKey {
-    std::string ArchivePath;  // Storage for StringRef
-    std::string MemberName;   // Storage for StringRef
-    std::string ArchName;     // Storage for StringRef
+    std::string ArchivePath; // Storage for StringRef
+    std::string MemberName;  // Storage for StringRef
+    std::string ArchName;    // Storage for StringRef
 
     // Required for map comparison
     bool operator<(const ArchiveCacheKey &Other) const {
-      return std::tie(ArchivePath, MemberName, ArchName) < 
+      return std::tie(ArchivePath, MemberName, ArchName) <
              std::tie(Other.ArchivePath, Other.MemberName, Other.ArchName);
     }
   };
 
-  std::map<ArchiveCacheKey, std::unique_ptr<ObjectFile>> ObjectForArchivePathAndArch;
-  
+  std::map<ArchiveCacheKey, std::unique_ptr<ObjectFile>>
+      ObjectForArchivePathAndArch;
+
   Options Opts;
 
   std::unique_ptr<BuildIDFetcher> BIDFetcher;
diff --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
index 6dddc3a70..6320b889f 100644
--- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -21,6 +21,7 @@
 #include "llvm/DebugInfo/PDB/PDBContext.h"
 #include "llvm/DebugInfo/Symbolize/SymbolizableObjectFile.h"
 #include "llvm/Demangle/Demangle.h"
+#include "llvm/Object/Archive.h"
 #include "llvm/Object/BuildID.h"
 #include "llvm/Object/COFF.h"
 #include "llvm/Object/ELFObjectFile.h"
@@ -33,7 +34,6 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Object/Archive.h"
 #include <cassert>
 #include <cstring>
 
@@ -564,16 +564,14 @@ LLVMSymbolizer::getOrCreateObjectPair(const std::string &Path,
   std::string DbgObjPath = DbgObj->getFileName().str();
   auto BinIter = BinaryForPath.find(DbgObjPath);
   if (BinIter != BinaryForPath.end()) {
-    BinIter->second.pushEvictor([this, I = Pair.first]() {
-    ObjectPairForPathArch.erase(I);
-    });
+    BinIter->second.pushEvictor(
+        [this, I = Pair.first]() { ObjectPairForPathArch.erase(I); });
   }
   return Res;
 }
 
-Expected<ObjectFile *> LLVMSymbolizer::getOrCreateObjectFromArchive(StringRef ArchivePath, 
-                                                                    StringRef MemberName, 
-                                                                    const std::string &ArchName) {
+Expected<ObjectFile *> LLVMSymbolizer::getOrCreateObjectFromArchive(
+    StringRef ArchivePath, StringRef MemberName, const std::string &ArchName) {
   Binary *Bin = nullptr;
   auto Pair = BinaryForPath.emplace(ArchivePath.str(), OwningBinary<Binary>());
   if (!Pair.second) {
@@ -598,18 +596,20 @@ Expected<ObjectFile *> LLVMSymbolizer::getOrCreateObjectFromArchive(StringRef Ar
 
   object::Archive *Archive = cast<object::Archive>(Bin);
   Error Err = Error::success();
-  
-  // On AIX, archives can contain multiple members with same name but different types
-  // We need to check all matches and find one that matches both name and architecture
+
+  // On AIX, archives can contain multiple members with same name but different
+  // types We need to check all matches and find one that matches both name and
+  // architecture
   for (auto &Child : Archive->children(Err, /*SkipInternal=*/true)) {
     Expected<StringRef> NameOrErr = Child.getName();
     if (!NameOrErr)
-      continue; 
+      continue;
     if (*NameOrErr == llvm::sys::path::filename(MemberName)) {
-      Expected<std::unique_ptr<object::Binary>> MemberOrErr = Child.getAsBinary();
+      Expected<std::unique_ptr<object::Binary>> MemberOrErr =
+          Child.getAsBinary();
       if (!MemberOrErr)
-        continue; 
-      
+        continue;
+
       std::unique_ptr<object::Binary> Binary = std::move(*MemberOrErr);
       if (auto *Obj = dyn_cast<object::ObjectFile>(Binary.get())) {
 #if defined(_AIX)
@@ -625,11 +625,13 @@ Expected<ObjectFile *> LLVMSymbolizer::getOrCreateObjectFromArchive(StringRef Ar
           return I->second.get();
 
         auto CachedObj = std::unique_ptr<ObjectFile>(Obj);
-        auto NewEntry = ObjectForArchivePathAndArch.emplace(
-            CacheKey, std::move(CachedObj));
+        auto NewEntry =
+            ObjectForArchivePathAndArch.emplace(CacheKey, std::move(CachedObj));
         Binary.release();
-        BinaryForPath.find(ArchivePath.str())->second.pushEvictor(
-            [this, Iter = NewEntry.first]() { ObjectForArchivePathAndArch.erase(Iter); });
+        BinaryForPath.find(ArchivePath.str())
+            ->second.pushEvictor([this, Iter = NewEntry.first]() {
+              ObjectForArchivePathAndArch.erase(Iter);
+            });
         return NewEntry.first->second.get();
       }
     }
@@ -642,13 +644,15 @@ Expected<ObjectFile *> LLVMSymbolizer::getOrCreateObjectFromArchive(StringRef Ar
 Expected<ObjectFile *>
 LLVMSymbolizer::getOrCreateObject(const std::string &Path,
                                   const std::string &ArchName) {
-  // First check for archive(member) format - more efficient to check closing paren first
+  // First check for archive(member) format - more efficient to check closing
+  // paren first
   size_t CloseParen = Path.rfind(')');
   if (CloseParen != std::string::npos && CloseParen == Path.length() - 1) {
     size_t OpenParen = Path.rfind('(', CloseParen);
     if (OpenParen != std::string::npos) {
       StringRef ArchivePath = StringRef(Path).substr(0, OpenParen);
-      StringRef MemberName = StringRef(Path).substr(OpenParen + 1, CloseParen - OpenParen - 1);
+      StringRef MemberName =
+          StringRef(Path).substr(OpenParen + 1, CloseParen - OpenParen - 1);
       return getOrCreateObjectFromArchive(ArchivePath, MemberName, ArchName);
     }
   }
@@ -803,10 +807,8 @@ LLVMSymbolizer::getOrCreateModuleInfo(StringRef ModuleName) {
   if (ModuleOrErr) {
     auto I = Modules.find(ModuleName);
     auto BinIter = BinaryForPath.find(BinaryName);
-    if (BinIter != BinaryForPath.end()) 
-      BinIter->second.pushEvictor([this, I]() {
-      Modules.erase(I);
-    });
+    if (BinIter != BinaryForPath.end())
+      BinIter->second.pushEvictor([this, I]() { Modules.erase(I); });
   }
   return ModuleOrErr;
 }

``````````

</details>


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


More information about the llvm-commits mailing list