This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Minor refactor of LinkerScript file.
ClosedPublic

Authored by grimar on Feb 15 2016, 1:15 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 47958.Feb 15 2016, 1:15 AM
grimar retitled this revision from to [ELF] - Minor refactor of LinkerScript file..
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.
grimar updated this revision to Diff 48291.Feb 18 2016, 2:09 AM
grimar updated this object.

Removed all changes except one because:

  • Moving allocator inside ScriptParser was not good idea. Its much more clear to know it's lifetime is attached to LinkerScript class and not to parser. It did not work correctly I think.
  • Restored checks of Error flag where removed. That also was incorrect change, thanks to Rui Ueyama for noticing that during review of another patch.
rafael edited edge metadata.Feb 18 2016, 7:42 AM

This is similar to how MC parser is done, so it is fine with me.

Rui, what do you think?

ELF/LinkerScript.cpp
122 ↗(On Diff #48291)

Any particular reason for this order?

143 ↗(On Diff #48291)

C is only used inside the if. Move the find call there?

rafael added inline comments.Feb 18 2016, 7:44 AM
ELF/LinkerScript.cpp
143 ↗(On Diff #48291)

Actually. The if is on a repeated call to find. So just use

auto C = Cmd.find(Tok);
if (C != Cmd.end())

C->second(*this);
grimar added inline comments.Feb 18 2016, 7:53 AM
ELF/LinkerScript.cpp
122 ↗(On Diff #48291)

I think we do that in other places. Flags with flags etc.

143 ↗(On Diff #48291)

Yep, that what I wanted initially.

ruiu accepted this revision.Feb 18 2016, 12:37 PM
ruiu edited edge metadata.

LGTM with a few nits.

ELF/LinkerScript.cpp
92 ↗(On Diff #48291)

Remove this function and move the code inside the constructor.

143 ↗(On Diff #48291)

Please rename C -> It (because it is not a command but an iterator.)

144–145 ↗(On Diff #48291)

Please assign to a local variable to make the actual type explicit.

if (It != Cmd.end()) {
  std::function<void(ScriptParser &)> &Handler = It->second;
  Handler();
} else {
  setError(...);
}
This revision is now accepted and ready to land.Feb 18 2016, 12:37 PM
This revision was automatically updated to reflect the committed changes.
grimar marked 8 inline comments as done.