[PATCH] D81887: [lld-macho] Refactor segment/section creation, sorting, and merging

Kellie Medlin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 18 10:19:05 PDT 2020


Ktwu added a comment.

This is nice; thanks for the cleanup!



================
Comment at: lld/MachO/Writer.cpp:337
 
+static int segmentOrder(OutputSegment *seg) {
+  return StringSwitch<int>(seg->name)
----------------
Why move the ordering functions back into the writer?


================
Comment at: lld/MachO/Writer.cpp:355
+    return StringSwitch<int>(osec->name)
+        .Case(section_names::binding, std::numeric_limits<int>::min())
+        .Case(section_names::export_, std::numeric_limits<int>::min() + 1)
----------------
Why use std::numeric_limits instead of constants like -3, -2, -1, 0? Magic numbers suck but std::numeric_limits<int>::min() seems sort of verbose.

Nit: cache std::numeric_limits<int>::min() in a temp variable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81887





More information about the llvm-commits mailing list