[Lldb-commits] [lldb] [LLDB] Add assignment to DIL. (PR #190223)
via lldb-commits
lldb-commits at lists.llvm.org
Mon May 11 11:50:21 PDT 2026
================
@@ -1241,16 +1241,30 @@ void ValueObject::SetValueFromInteger(const llvm::APInt &value, Status &error,
return;
}
+ // Make sure we're not trying to assign to a constant.
+ if (GetIsConstant()) {
+ error =
+ Status::FromErrorString("current value is not assignable (a constant)");
+ return;
+ }
+
// Verify the proposed new value is the right size.
lldb::TargetSP target = GetTargetSP();
uint64_t byte_size = 0;
- if (auto temp =
- llvm::expectedToOptional(GetCompilerType().GetByteSize(target.get())))
- byte_size = temp.value();
- if (value.getBitWidth() != byte_size * CHAR_BIT) {
- error = Status::FromErrorString(
- "illegal argument: new value should be of the same size");
- return;
+ // Exclude size check when assigning an integer 1 or 0 to a boolean.
+ if (!val_type.IsBoolean() || (!value.isOne() && !value.isZero())) {
+ if (auto temp = llvm::expectedToOptional(
+ GetCompilerType().GetByteSize(target.get())))
+ byte_size = temp.value();
+ if (value.getBitWidth() > byte_size * CHAR_BIT) {
+ // The type is too big, but maybe the value itself is small enough?
+ uint64_t u_max = (1 << (byte_size * CHAR_BIT)) - 1;
+ if (*(value.getRawData()) > u_max) {
+ error =
+ Status::FromErrorString("illegal argument: new value is too big");
----------------
cmtice wrote:
This function's return type is "void"; "error" is a reference parameter. Should it still be of type llvm::Error rather than Status?
https://github.com/llvm/llvm-project/pull/190223
More information about the lldb-commits
mailing list