Skip to content
Commit 55968109 authored by Peter Rong's avatar Peter Rong
Browse files

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

Currently, APInt::getSExtValue and getZExtValue crashes on values with more than 64 bits.
Users may accidently crash the compiler with this setting when the integer may be i128.
As shown in https://github.com/llvm/llvm-project/issues/59316

In this patch we provide a trySExtValue and tryZExtValue to return an Optional, the user
needs to explictly unwrap it and condsier the possibility where there my no value in it.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D139683
parent 80f2f1ea
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment