@@ -3194,17 +3194,17 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
31943194 GetCompilerType ().IsPointerType () || GetCompilerType ().IsNullPtrType ();
31953195 bool is_float = GetCompilerType ().IsFloat ();
31963196 bool is_integer = GetCompilerType ().IsInteger ();
3197+ ExecutionContext exe_ctx (GetExecutionContextRef ());
31973198
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 " ));
32023203
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" ));
32083208
32093209 lldb::TargetSP target = GetTargetSP ();
32103210 uint64_t type_byte_size = 0 ;
@@ -3215,16 +3215,15 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
32153215 val_byte_size = temp.value ();
32163216
32173217 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" ));
32283227 }
32293228
32303229 if (type.IsBoolean ()) {
@@ -3236,12 +3235,12 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
32363235 if (float_value_or_err)
32373236 return ValueObject::CreateValueObjectFromBool (
32383237 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 ()));
32453244 }
32463245 }
32473246
@@ -3255,13 +3254,12 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
32553254 int_value_or_err->extOrTrunc (type_byte_size * CHAR_BIT);
32563255 return ValueObject::CreateValueObjectFromAPInt (target, ext, type,
32573256 " 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 ()));
32653263 } else if (is_scalar && is_float) {
32663264 llvm::APSInt integer (type_byte_size * CHAR_BIT, !type.IsSigned ());
32673265 bool is_exact;
@@ -3273,12 +3271,12 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
32733271
32743272 // Casting floating point values that are out of bounds of the target
32753273 // 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 ()));
32823280 return ValueObject::CreateValueObjectFromAPInt (target, integer, type,
32833281 " result" );
32843282 }
@@ -3297,10 +3295,11 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
32973295 return ValueObject::CreateValueObjectFromAPFloat (target, f, type,
32983296 " result" );
32993297 } 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 ()));
33043303 }
33053304 } else {
33063305 if (is_integer) {
@@ -3312,10 +3311,11 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
33123311 return ValueObject::CreateValueObjectFromAPFloat (target, f, type,
33133312 " result" );
33143313 } 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 ()));
33193319 }
33203320 }
33213321 if (is_float) {
@@ -3327,34 +3327,37 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
33273327 return ValueObject::CreateValueObjectFromAPFloat (target, f, type,
33283328 " result" );
33293329 } 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 ()));
33343335 }
33353336 }
33363337 }
33373338 }
33383339
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" ));
33413343}
33423344
33433345lldb::ValueObjectSP ValueObject::CastToEnumType (CompilerType type) {
33443346 bool is_enum = GetCompilerType ().IsEnumerationType ();
33453347 bool is_integer = GetCompilerType ().IsInteger ();
33463348 bool is_float = GetCompilerType ().IsFloat ();
3349+ ExecutionContext exe_ctx (GetExecutionContextRef ());
33473350
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 " ));
33533356
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 " ));
33583361
33593362 lldb::TargetSP target = GetTargetSP ();
33603363 uint64_t byte_size = 0 ;
@@ -3371,34 +3374,35 @@ lldb::ValueObjectSP ValueObject::CastToEnumType(CompilerType type) {
33713374
33723375 // Casting floating point values that are out of bounds of the target
33733376 // 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 ()));
33803383 return ValueObject::CreateValueObjectFromAPInt (target, integer, type,
33813384 " 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 " ));
33863389 } else {
33873390 // Get the value as APSInt and extend or truncate it to the requested size.
33883391 auto value_or_err = GetValueAsAPSInt ();
33893392 if (value_or_err) {
33903393 llvm::APSInt ext = value_or_err->extOrTrunc (byte_size * CHAR_BIT);
33913394 return ValueObject::CreateValueObjectFromAPInt (target, ext, type,
33923395 " 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 ()));
33993402 }
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" ));
34023406}
34033407
34043408ValueObject::EvaluationPoint::EvaluationPoint () : m_mod_id(), m_exe_ctx_ref() {}
0 commit comments