| 142 | #define HAVE_BUILTIN_ADD_OVERFLOW |
| 143 | template<typename RESULT_T> |
| 144 | DecimalValue<RESULT_T> BuiltinAdd(const Decimal16Value& val, int this_scale, |
| 145 | const Decimal16Value& other, int other_scale, int result_precision, int result_scale, |
| 146 | bool* overflow) { |
| 147 | DCHECK_EQ(result_scale, std::max(this_scale, other_scale)); |
| 148 | RESULT_T x = 0; |
| 149 | RESULT_T y = 0; |
| 150 | *overflow |= AdjustToSameScale(val, this_scale, other, other_scale, |
| 151 | result_precision, &x, &y); |
| 152 | if (sizeof(RESULT_T) == 16 && result_precision == ColumnType::MAX_PRECISION) { |
| 153 | RESULT_T result = 0; |
| 154 | *overflow |= __builtin_add_overflow(x, y, &result); |
| 155 | *overflow |= abs(result) > MAX_UNSCALED_DECIMAL16; |
| 156 | return DecimalValue<RESULT_T>(result); |
| 157 | } else { |
| 158 | DCHECK(!*overflow) << "Cannot overflow unless result is Decimal16Value"; |
| 159 | } |
| 160 | return DecimalValue<RESULT_T>(x + y); |
| 161 | } |
| 162 | #endif |
| 163 | |
| 164 | template<typename RESULT_T> |
nothing calls this directly
no test coverage detected