#include #include #include namespace DB { namespace ErrorCodes { extern const int LOGICAL_ERROR; } namespace { template struct BitNotImpl { using ResultType = typename NumberTraits::ResultOfBitNot::Type; static constexpr bool allow_string_or_fixed_string = true; static inline ResultType NO_SANITIZE_UNDEFINED apply(A a) { return ~static_cast(a); } #if USE_EMBEDDED_COMPILER static constexpr bool compilable = true; static inline llvm::Value * compile(llvm::IRBuilder<> & b, llvm::Value * arg, bool) { if (!arg->getType()->isIntegerTy()) throw Exception(ErrorCodes::LOGICAL_ERROR, "BitNotImpl expected an integral type"); return b.CreateNot(arg); } #endif }; struct NameBitNot { static constexpr auto name = "bitNot"; }; using FunctionBitNot = FunctionUnaryArithmetic; } template <> struct FunctionUnaryArithmeticMonotonicity { static bool has() { return false; } static IFunction::Monotonicity get(const Field &, const Field &) { return {}; } }; REGISTER_FUNCTION(BitNot) { factory.registerFunction(); } }