@@ -3194,17 +3194,17 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
3194
3194
GetCompilerType ().IsPointerType () || GetCompilerType ().IsNullPtrType ();
3195
3195
bool is_float = GetCompilerType ().IsFloat ();
3196
3196
bool is_integer = GetCompilerType ().IsInteger ();
3197
+ ExecutionContext exe_ctx (GetExecutionContextRef ());
3197
3198
3198
- if (!type.IsScalarType ()) {
3199
- m_error = Status::FromErrorString ( " target type must be a scalar " );
3200
- return GetSP ();
3201
- }
3199
+ if (!type.IsScalarType ())
3200
+ return ValueObjectConstResult::Create (
3201
+ exe_ctx. GetBestExecutionContextScope (),
3202
+ Status::FromErrorString ( " target type must be a scalar " ));
3202
3203
3203
- if (!is_scalar && !is_enum && !is_pointer) {
3204
- m_error =
3205
- Status::FromErrorString (" argument must be a scalar, enum, or pointer" );
3206
- return GetSP ();
3207
- }
3204
+ if (!is_scalar && !is_enum && !is_pointer)
3205
+ return ValueObjectConstResult::Create (
3206
+ exe_ctx.GetBestExecutionContextScope (),
3207
+ Status::FromErrorString (" argument must be a scalar, enum, or pointer" ));
3208
3208
3209
3209
lldb::TargetSP target = GetTargetSP ();
3210
3210
uint64_t type_byte_size = 0 ;
@@ -3215,16 +3215,15 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
3215
3215
val_byte_size = temp.value ();
3216
3216
3217
3217
if (is_pointer) {
3218
- if (!type.IsInteger () && !type.IsBoolean ()) {
3219
- m_error =
3220
- Status::FromErrorString (" target type must be an integer or boolean" );
3221
- return GetSP ();
3222
- }
3223
- if (!type.IsBoolean () && type_byte_size < val_byte_size) {
3224
- m_error = Status::FromErrorString (
3225
- " target type cannot be smaller than the pointer type" );
3226
- return GetSP ();
3227
- }
3218
+ if (!type.IsInteger () && !type.IsBoolean ())
3219
+ return ValueObjectConstResult::Create (
3220
+ exe_ctx.GetBestExecutionContextScope (),
3221
+ Status::FromErrorString (" target type must be an integer or boolean" ));
3222
+ if (!type.IsBoolean () && type_byte_size < val_byte_size)
3223
+ return ValueObjectConstResult::Create (
3224
+ exe_ctx.GetBestExecutionContextScope (),
3225
+ Status::FromErrorString (
3226
+ " target type cannot be smaller than the pointer type" ));
3228
3227
}
3229
3228
3230
3229
if (type.IsBoolean ()) {
@@ -3236,12 +3235,12 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
3236
3235
if (float_value_or_err)
3237
3236
return ValueObject::CreateValueObjectFromBool (
3238
3237
target, !float_value_or_err->isZero (), " result" );
3239
- else {
3240
- m_error = Status::FromErrorStringWithFormat (
3241
- " cannot get value as APFloat: %s " ,
3242
- llvm::toString (float_value_or_err. takeError ()). c_str ());
3243
- return GetSP ();
3244
- }
3238
+ else
3239
+ return ValueObjectConstResult::Create (
3240
+ exe_ctx. GetBestExecutionContextScope () ,
3241
+ Status::FromErrorStringWithFormat (
3242
+ " cannot get value as APFloat: %s " ,
3243
+ llvm::toString (float_value_or_err. takeError ()). c_str ()));
3245
3244
}
3246
3245
}
3247
3246
@@ -3255,13 +3254,12 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
3255
3254
int_value_or_err->extOrTrunc (type_byte_size * CHAR_BIT);
3256
3255
return ValueObject::CreateValueObjectFromAPInt (target, ext, type,
3257
3256
" result" );
3258
- } else {
3259
- m_error = Status::FromErrorStringWithFormat (
3260
- " cannot get value as APSInt: %s" ,
3261
- llvm::toString (int_value_or_err.takeError ()).c_str ());
3262
- ;
3263
- return GetSP ();
3264
- }
3257
+ } else
3258
+ return ValueObjectConstResult::Create (
3259
+ exe_ctx.GetBestExecutionContextScope (),
3260
+ Status::FromErrorStringWithFormat (
3261
+ " cannot get value as APSInt: %s" ,
3262
+ llvm::toString (int_value_or_err.takeError ()).c_str ()));
3265
3263
} else if (is_scalar && is_float) {
3266
3264
llvm::APSInt integer (type_byte_size * CHAR_BIT, !type.IsSigned ());
3267
3265
bool is_exact;
@@ -3273,12 +3271,12 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
3273
3271
3274
3272
// Casting floating point values that are out of bounds of the target
3275
3273
// type is undefined behaviour.
3276
- if (status & llvm::APFloatBase::opInvalidOp) {
3277
- m_error = Status::FromErrorStringWithFormat (
3278
- " invalid type cast detected: %s " ,
3279
- llvm::toString (float_value_or_err. takeError ()). c_str ());
3280
- return GetSP ();
3281
- }
3274
+ if (status & llvm::APFloatBase::opInvalidOp)
3275
+ return ValueObjectConstResult::Create (
3276
+ exe_ctx. GetBestExecutionContextScope () ,
3277
+ Status::FromErrorStringWithFormat (
3278
+ " invalid type cast detected: %s " ,
3279
+ llvm::toString (float_value_or_err. takeError ()). c_str ()));
3282
3280
return ValueObject::CreateValueObjectFromAPInt (target, integer, type,
3283
3281
" result" );
3284
3282
}
@@ -3297,10 +3295,11 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
3297
3295
return ValueObject::CreateValueObjectFromAPFloat (target, f, type,
3298
3296
" result" );
3299
3297
} else {
3300
- m_error = Status::FromErrorStringWithFormat (
3301
- " cannot get value as APSInt: %s" ,
3302
- llvm::toString (int_value_or_err.takeError ()).c_str ());
3303
- return GetSP ();
3298
+ return ValueObjectConstResult::Create (
3299
+ exe_ctx.GetBestExecutionContextScope (),
3300
+ Status::FromErrorStringWithFormat (
3301
+ " cannot get value as APSInt: %s" ,
3302
+ llvm::toString (int_value_or_err.takeError ()).c_str ()));
3304
3303
}
3305
3304
} else {
3306
3305
if (is_integer) {
@@ -3312,10 +3311,11 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
3312
3311
return ValueObject::CreateValueObjectFromAPFloat (target, f, type,
3313
3312
" result" );
3314
3313
} else {
3315
- m_error = Status::FromErrorStringWithFormat (
3316
- " cannot get value as APSInt: %s" ,
3317
- llvm::toString (int_value_or_err.takeError ()).c_str ());
3318
- return GetSP ();
3314
+ return ValueObjectConstResult::Create (
3315
+ exe_ctx.GetBestExecutionContextScope (),
3316
+ Status::FromErrorStringWithFormat (
3317
+ " cannot get value as APSInt: %s" ,
3318
+ llvm::toString (int_value_or_err.takeError ()).c_str ()));
3319
3319
}
3320
3320
}
3321
3321
if (is_float) {
@@ -3327,34 +3327,37 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
3327
3327
return ValueObject::CreateValueObjectFromAPFloat (target, f, type,
3328
3328
" result" );
3329
3329
} else {
3330
- m_error = Status::FromErrorStringWithFormat (
3331
- " cannot get value as APFloat: %s" ,
3332
- llvm::toString (float_value_or_err.takeError ()).c_str ());
3333
- return GetSP ();
3330
+ return ValueObjectConstResult::Create (
3331
+ exe_ctx.GetBestExecutionContextScope (),
3332
+ Status::FromErrorStringWithFormat (
3333
+ " cannot get value as APFloat: %s" ,
3334
+ llvm::toString (float_value_or_err.takeError ()).c_str ()));
3334
3335
}
3335
3336
}
3336
3337
}
3337
3338
}
3338
3339
3339
- m_error = Status::FromErrorString (" Unable to perform requested cast" );
3340
- return GetSP ();
3340
+ return ValueObjectConstResult::Create (
3341
+ exe_ctx.GetBestExecutionContextScope (),
3342
+ Status::FromErrorString (" Unable to perform requested cast" ));
3341
3343
}
3342
3344
3343
3345
lldb::ValueObjectSP ValueObject::CastToEnumType (CompilerType type) {
3344
3346
bool is_enum = GetCompilerType ().IsEnumerationType ();
3345
3347
bool is_integer = GetCompilerType ().IsInteger ();
3346
3348
bool is_float = GetCompilerType ().IsFloat ();
3349
+ ExecutionContext exe_ctx (GetExecutionContextRef ());
3347
3350
3348
- if (!is_enum && !is_integer && !is_float) {
3349
- m_error = Status::FromErrorString (
3350
- " argument must be an integer, a float, or an enum " );
3351
- return GetSP ();
3352
- }
3351
+ if (!is_enum && !is_integer && !is_float)
3352
+ return ValueObjectConstResult::Create (
3353
+ exe_ctx. GetBestExecutionContextScope (),
3354
+ Status::FromErrorString (
3355
+ " argument must be an integer, a float, or an enum " ));
3353
3356
3354
- if (!type.IsEnumerationType ()) {
3355
- m_error = Status::FromErrorString ( " target type must be an enum " );
3356
- return GetSP ();
3357
- }
3357
+ if (!type.IsEnumerationType ())
3358
+ return ValueObjectConstResult::Create (
3359
+ exe_ctx. GetBestExecutionContextScope (),
3360
+ Status::FromErrorString ( " target type must be an enum " ));
3358
3361
3359
3362
lldb::TargetSP target = GetTargetSP ();
3360
3363
uint64_t byte_size = 0 ;
@@ -3371,34 +3374,35 @@ lldb::ValueObjectSP ValueObject::CastToEnumType(CompilerType type) {
3371
3374
3372
3375
// Casting floating point values that are out of bounds of the target
3373
3376
// type is undefined behaviour.
3374
- if (status & llvm::APFloatBase::opInvalidOp) {
3375
- m_error = Status::FromErrorStringWithFormat (
3376
- " invalid type cast detected: %s " ,
3377
- llvm::toString (value_or_err. takeError ()). c_str ());
3378
- return GetSP ();
3379
- }
3377
+ if (status & llvm::APFloatBase::opInvalidOp)
3378
+ return ValueObjectConstResult::Create (
3379
+ exe_ctx. GetBestExecutionContextScope () ,
3380
+ Status::FromErrorStringWithFormat (
3381
+ " invalid type cast detected: %s " ,
3382
+ llvm::toString (value_or_err. takeError ()). c_str ()));
3380
3383
return ValueObject::CreateValueObjectFromAPInt (target, integer, type,
3381
3384
" result" );
3382
- } else {
3383
- m_error = Status::FromErrorString ( " cannot get value as APFloat " );
3384
- return GetSP ();
3385
- }
3385
+ } else
3386
+ return ValueObjectConstResult::Create (
3387
+ exe_ctx. GetBestExecutionContextScope (),
3388
+ Status::FromErrorString ( " cannot get value as APFloat " ));
3386
3389
} else {
3387
3390
// Get the value as APSInt and extend or truncate it to the requested size.
3388
3391
auto value_or_err = GetValueAsAPSInt ();
3389
3392
if (value_or_err) {
3390
3393
llvm::APSInt ext = value_or_err->extOrTrunc (byte_size * CHAR_BIT);
3391
3394
return ValueObject::CreateValueObjectFromAPInt (target, ext, type,
3392
3395
" result" );
3393
- } else {
3394
- m_error = Status::FromErrorStringWithFormat (
3395
- " cannot get value as APSInt: %s " ,
3396
- llvm::toString (value_or_err. takeError ()). c_str ());
3397
- return GetSP ();
3398
- }
3396
+ } else
3397
+ return ValueObjectConstResult::Create (
3398
+ exe_ctx. GetBestExecutionContextScope () ,
3399
+ Status::FromErrorStringWithFormat (
3400
+ " cannot get value as APSInt: %s " ,
3401
+ llvm::toString (value_or_err. takeError ()). c_str ()));
3399
3402
}
3400
- m_error = Status::FromErrorString (" Cannot perform requested cast" );
3401
- return GetSP ();
3403
+ return ValueObjectConstResult::Create (
3404
+ exe_ctx.GetBestExecutionContextScope (),
3405
+ Status::FromErrorString (" Cannot perform requested cast" ));
3402
3406
}
3403
3407
3404
3408
ValueObject::EvaluationPoint::EvaluationPoint () : m_mod_id(), m_exe_ctx_ref() {}
0 commit comments