This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Report location for div/mod by zero.
ClosedPublic

Authored by grimar on Mar 1 2018, 2:34 AM.

Details

Summary

"division by zero" or "modulo by zero" are not
very informative errors and even probably confusing
as does not let to know that error is coming from linker script.
Patch adds location reporting.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Mar 1 2018, 2:34 AM
ruiu added inline comments.Mar 1 2018, 8:52 AM
ELF/ScriptParser.cpp
815–823 ↗(On Diff #136485)

You probably should inline these functions. They are called only once.

grimar added inline comments.Mar 1 2018, 8:55 AM
ELF/ScriptParser.cpp
815–823 ↗(On Diff #136485)

Do you mean following ?

return [=] { return mod(L(), R(), getCurrentLocation()); };

It is not the same. Functor is called much later, and location will be unavailable,
we can't get it from inside.

ruiu added inline comments.Mar 1 2018, 9:26 AM
ELF/ScriptParser.cpp
815–823 ↗(On Diff #136485)

No what I mean is to inline div and mod here.

grimar added inline comments.Mar 1 2018, 9:30 AM
ELF/ScriptParser.cpp
815–823 ↗(On Diff #136485)

Ah, OK. Will update diff tomorrow with that change, thanks !

grimar updated this revision to Diff 136687.Mar 2 2018, 12:31 AM
  • Addressed review comments.
ruiu accepted this revision.Mar 2 2018, 1:35 PM

LGTM

ELF/ScriptParser.cpp
808 ↗(On Diff #136687)

nit: my preference is to use -> uint64_t instead of type casting a return value.

This revision is now accepted and ready to land.Mar 2 2018, 1:35 PM
This revision was automatically updated to reflect the committed changes.