[PATCH] D140059: [APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project/issues/59515

Peter Rong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 17 13:23:13 PST 2022


Peter marked 2 inline comments as done.
Peter added inline comments.


================
Comment at: llvm/include/llvm/ADT/APSInt.h:104
+  std::optional<int64_t> tryExtValue() const {
+    return isRepresentableByInt64() ? std::optional<int64_t>(getExtValue())
+                                    : std::nullopt;
----------------
tschuett wrote:
> You don't need the constructor. `getExtValue()`should work.
Yes I do, otherwise the static type of the two branch don't match, as discussed here: https://reviews.llvm.org/D139683

```
llvm/include/llvm/ADT/APInt.h:1500:36: error: incompatible operand types ('uint64_t' (aka 'unsigned long') and 'const std::nullopt_t')
    return (getActiveBits() <= 64) ? getZExtValue() : std::nullopt;
                                   ^ ~~~~~~~~~~~~~~   ~~~~~~~~~~~~
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140059



More information about the llvm-commits mailing list