[llvm] d80210f - [dsymutil] Store possible Swift reflection sections in an array

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 17 12:40:14 PDT 2022


Author: Benjamin Kramer
Date: 2022-03-17T20:37:39+01:00
New Revision: d80210fc905781780979fe22070f94dea8c86115

URL: https://github.com/llvm/llvm-project/commit/d80210fc905781780979fe22070f94dea8c86115
DIFF: https://github.com/llvm/llvm-project/commit/d80210fc905781780979fe22070f94dea8c86115.diff

LOG: [dsymutil] Store possible Swift reflection sections in an array

No need for a unordered_map of enum, which is also broken in GCC before
6.1. No functionality change intended.

Added: 
    

Modified: 
    llvm/tools/dsymutil/DwarfLinkerForBinary.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
index 76dac490f7eee..8b40816368deb 100644
--- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -507,7 +507,8 @@ void DwarfLinkerForBinary::copySwiftReflectionMetadata(
   if (auto *MO = dyn_cast<llvm::object::MachOObjectFile>(OF->getBinary())) {
     // Collect the swift reflection sections before emitting them. This is
     // done so we control the order they're emitted.
-    std::unordered_map<Swift5ReflectionSectionKind, object::SectionRef>
+    std::array<Optional<object::SectionRef>,
+               Swift5ReflectionSectionKind::last + 1>
         SwiftSections;
     for (auto &Section : MO->sections()) {
       llvm::Expected<llvm::StringRef> NameOrErr =
@@ -527,9 +528,9 @@ void DwarfLinkerForBinary::copySwiftReflectionMetadata(
                                Swift5ReflectionSectionKind::fieldmd,
                                Swift5ReflectionSectionKind::reflstr};
     for (auto SectionKind : SectionKindsToEmit) {
-      if (!SwiftSections.count(SectionKind))
+      if (!SwiftSections[SectionKind])
         continue;
-      auto &Section = SwiftSections[SectionKind];
+      auto &Section = *SwiftSections[SectionKind];
       llvm::Expected<llvm::StringRef> SectionContents = Section.getContents();
       if (!SectionContents)
         continue;


        


More information about the llvm-commits mailing list