[PATCH] D43934: [ELF] - Report location for div/mod by zero.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 1 08:57:27 PST 2018


grimar added inline comments.


================
Comment at: ELF/ScriptParser.cpp:815-823
     return [=] { return L().getValue() * R().getValue(); };
-  if (Op == "/")
-    return [=] { return div(L(), R()); };
-  if (Op == "%")
-    return [=] { return mod(L(), R()); };
+  if (Op == "/") {
+    std::string Loc = getCurrentLocation();
+    return [=] { return div(L(), R(), Loc); };
+  }
+  if (Op == "%") {
+    std::string Loc = getCurrentLocation();
----------------
ruiu wrote:
> You probably should inline these functions. They are called only once.
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.


https://reviews.llvm.org/D43934





More information about the llvm-commits mailing list