[PATCH] D85501: [lld-macho] Handle command-line option -sectcreate SEG SECT FILE

Greg McGary via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 12:39:17 PDT 2020


gkm added inline comments.


================
Comment at: lld/MachO/InputFiles.cpp:313
+  isec->data = {buf, mb.getBufferSize()};
+  subsections.push_back({{0, isec}});
+}
----------------
int3 wrote:
> gkm wrote:
> > int3 wrote:
> > > nit: `subsections.emplace_back({0, isec});`
> > I followed prior practice in `InputFile::parseSections`. If I follow your recommendation, it seems I should also fix `InputFile::parseSections`, but then I am straying from the purpose of this diff into cleanup territory. Perhaps we should rather save cleanups for a separate diff, which could also include explicit `const auto`.
> I think it's worthwhile to make new code conform to the linter. That way, even if we don't explicitly do cleanups, we will still organically move to the new convention in the course of normal code churn from development. But I'm fine with migrating to `emplace` in a separate diff.
I gave-up on `subsections.emplace_back()`. None of these compiled:
```
subsections.emplace_back({{0, isec}});
subsections.emplace_back({0, isec});
subsections.emplace_back(0, isec);
```
`subsections` is a vector of maps, and the emplacement incantation is beyond me. Clues welcome. Here are the relevant decls:
```
using SubsectionMap = std::map<uint32_t, InputSection *>;
class InputFile {
  std::vector<SubsectionMap> subsections;
};
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85501



More information about the llvm-commits mailing list