[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:12:20 PDT 2021


thakis created this revision.
thakis added a reviewer: lld-macho.
Herald added a reviewer: int3.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
thakis requested review of this revision.

Minor cleanup, no behavior change.


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")
@@ -1047,8 +1047,7 @@
   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;
   }


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


More information about the llvm-commits mailing list