[PATCH] D45418: [SimplifyLibcalls] Atoi, strtol replacements

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 16 12:45:25 PDT 2018


xbolva00 added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1720
+        strtoll(Str.str().c_str(), nullptr, CInt->getSExtValue());
+    if (errno == ERANGE)
+      return nullptr;
----------------
efriedma wrote:
> strtoll can also fail with EINVAL, if the base is invalid.  But the exact behavior isn't specified in the C standard, so probably better to check the base ourselves, explicitly.
So I will add check for base if zero or between 2 and 36.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:2329
+    case LibFunc_strtol:
+      return optimizeStrtol(CI, Builder);
     case LibFunc_printf:
----------------
efriedma wrote:
> Can you also add cases here for atol, atoll, and strtoll?  (Your current implementations should just work.)
Ok, I can add it.

Current tests in this patch are good enough or then should be new ones for atol, atoll, and strtoll too?


https://reviews.llvm.org/D45418





More information about the llvm-commits mailing list