[PATCH] D101077: [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

Jon Chesterfield via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 22 14:08:53 PDT 2021


JonChesterfield added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1626
     } else {
-      auto Remnant =
-          StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
-      if (Diagnose &&
-          (Remnant || CodeObjVer < MinCodeObjVer || CodeObjVer > MaxCodeObjVer))
-        D.Diag(diag::err_drv_invalid_int_value)
-            << CodeObjArg->getAsString(Args) << CodeObjArg->getValue();
+      StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
     }
----------------
yaxunl wrote:
> JonChesterfield wrote:
> > getAsInteger writes to CodeObjVer.
> can we return Optional<unsigned> and return None if there is a remnant? Then we can call this function in checkAMDGPUCodeObjectVersion
We could. It would spawn handling of the Optional<> at all the call sites though. I'll see if I can pull the search logic into a local helper.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101077



More information about the cfe-commits mailing list