[PATCH] D139683: [APInt] provide a safe API for zext value and sext value.

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 17:02:31 PST 2022


lebedev.ri added inline comments.


================
Comment at: llvm/lib/Support/APInt.cpp:506-518
+Optional<uint64_t> APInt::tryZExtValue() const {
+  if (isSingleWord())
+    return Optional<uint64_t>(U.VAL);
+  return (getActiveBits() <= 64) ? Optional<uint64_t>(U.pVal[0])
+                                 : Optional<uint64_t>();
+}
+
----------------
These should just check for precondition and call the normal functions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139683



More information about the llvm-commits mailing list