[PATCH] D103774: [lld/mac] Use fewer magic numbers in magic $ld$ handling code

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 6 13:18:24 PDT 2021


thakis updated this revision to Diff 350130.
thakis edited the summary of this revision.
thakis added a comment.

more


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103774/new/

https://reviews.llvm.org/D103774

Files:
  lld/MachO/InputFiles.cpp


Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -980,7 +980,7 @@
 
   StringRef action;
   StringRef name;
-  std::tie(action, name) = originalName.drop_front(4 /* $ld$ */).split('$');
+  std::tie(action, name) = originalName.drop_front(strlen("$ld$")).split('$');
   if (action == "previous")
     handleLDPreviousSymbol(name, originalName);
   else if (action == "install_name")
@@ -1003,8 +1003,8 @@
   std::tie(compatVersion, name) = name.split('$');
   std::tie(platformStr, name) = name.split('$');
   std::tie(startVersion, name) = name.split('$');
-  std::tie(endVersion, symbolName) = name.split('$');
-  std::tie(symbolName, rest) = symbolName.split('$');
+  std::tie(endVersion, name) = name.split('$');
+  std::tie(symbolName, rest) = name.split('$');
   // TODO: ld64 contains some logic for non-empty symbolName as well.
   if (!symbolName.empty())
     return;
@@ -1047,14 +1047,10 @@
   StringRef condition, installName;
   std::tie(condition, installName) = name.split('$');
   VersionTuple version;
-  if (!condition.startswith("os") ||
-      version.tryParse(condition.drop_front(2 /* os */))) {
+  if (!condition.consume_front("os") || version.tryParse(condition))
     warn("failed to parse os version, symbol '" + originalName + "' ignored");
-    return;
-  }
-  if (version != config->platformInfo.minimum)
-    return;
-  dylibName = saver.save(installName);
+  else if (version == config->platformInfo.minimum)
+    dylibName = saver.save(installName);
 }
 
 ArchiveFile::ArchiveFile(std::unique_ptr<object::Archive> &&f)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103774.350130.patch
Type: text/x-patch
Size: 1662 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210606/78fdfa92/attachment.bin>


More information about the llvm-commits mailing list