LLVM 23.0.0git
CheckedArithmetic.h File Reference
#include "llvm/ADT/APInt.h"
#include <optional>
#include <type_traits>

Go to the source code of this file.

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
namespace  llvm::detail
 A self-contained host- and target-independent arbitrary-precision floating-point software implementation.

Functions

template<typename T, typename F>
std::enable_if_t< std::is_integral_v< T > &&sizeof(T) *8<=64, std::optional< T > > llvm::detail::checkedOp (T LHS, T RHS, F Op, bool Signed=true)
 Utility function to apply a given method of APInt F to LHS and RHS.
template<typename T>
std::enable_if_t< std::is_signed_v< T >, std::optional< T > > llvm::checkedAdd (T LHS, T RHS)
 Add two signed integers LHS and RHS.
template<typename T>
std::enable_if_t< std::is_signed_v< T >, std::optional< T > > llvm::checkedSub (T LHS, T RHS)
 Subtract two signed integers LHS and RHS.
template<typename T>
std::enable_if_t< std::is_signed_v< T >, std::optional< T > > llvm::checkedMul (T LHS, T RHS)
 Multiply two signed integers LHS and RHS.
template<typename T>
std::enable_if_t< std::is_signed_v< T >, std::optional< T > > llvm::checkedMulAdd (T A, T B, T C)
 Multiply A and B, and add C to the resulting product.
template<typename T>
std::enable_if_t< std::is_unsigned_v< T >, std::optional< T > > llvm::checkedAddUnsigned (T LHS, T RHS)
 Add two unsigned integers LHS and RHS.
template<typename T>
std::enable_if_t< std::is_unsigned_v< T >, std::optional< T > > llvm::checkedMulUnsigned (T LHS, T RHS)
 Multiply two unsigned integers LHS and RHS.
template<typename T>
std::enable_if_t< std::is_unsigned_v< T >, std::optional< T > > llvm::checkedMulAddUnsigned (T A, T B, T C)
 Multiply unsigned integers A and B, and add C to the resulting product.