[FuzzerMutate] Allow implicit truncation

If the fixed value 42 does not fit the integer type, truncate it.
This commit is contained in:
Nikita Popov 2025-12-11 15:52:40 +01:00
parent 1154ed8f3c
commit 8975eb3274

View File

@ -22,7 +22,8 @@ void fuzzerop::makeConstantsWithType(Type *T, std::vector<Constant *> &Cs) {
uint64_t W = IntTy->getBitWidth();
Cs.push_back(ConstantInt::get(IntTy, 0));
Cs.push_back(ConstantInt::get(IntTy, 1));
Cs.push_back(ConstantInt::get(IntTy, 42));
Cs.push_back(ConstantInt::get(IntTy, 42, /*IsSigned=*/false,
/*ImplicitTrunc=*/true));
Cs.push_back(ConstantInt::get(IntTy, APInt::getMaxValue(W)));
Cs.push_back(ConstantInt::get(IntTy, APInt::getMinValue(W)));
Cs.push_back(ConstantInt::get(IntTy, APInt::getSignedMaxValue(W)));