@@ -3196,18 +3196,15 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
31963196 bool is_integer = GetCompilerType ().IsInteger ();
31973197 ExecutionContext exe_ctx (GetExecutionContextRef ());
31983198
3199- if (!type.IsScalarType ()) {
3200- Status error = Status::FromErrorString (" target type must be a scalar" );
3199+ if (!type.IsScalarType ())
32013200 return ValueObjectConstResult::Create (
3202- exe_ctx.GetBestExecutionContextScope (), error. Clone ());
3203- }
3201+ exe_ctx.GetBestExecutionContextScope (),
3202+ Status::FromErrorString ( " target type must be a scalar " ));
32043203
3205- if (!is_scalar && !is_enum && !is_pointer) {
3206- Status error =
3207- Status::FromErrorString (" argument must be a scalar, enum, or pointer" );
3204+ if (!is_scalar && !is_enum && !is_pointer)
32083205 return ValueObjectConstResult::Create (
3209- exe_ctx.GetBestExecutionContextScope (), error. Clone ());
3210- }
3206+ exe_ctx.GetBestExecutionContextScope (),
3207+ Status::FromErrorString ( " argument must be a scalar, enum, or pointer " ));
32113208
32123209 lldb::TargetSP target = GetTargetSP ();
32133210 uint64_t type_byte_size = 0 ;
@@ -3218,18 +3215,15 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
32183215 val_byte_size = temp.value ();
32193216
32203217 if (is_pointer) {
3221- if (!type.IsInteger () && !type.IsBoolean ()) {
3222- Status error =
3223- Status::FromErrorString (" target type must be an integer or boolean" );
3218+ if (!type.IsInteger () && !type.IsBoolean ())
32243219 return ValueObjectConstResult::Create (
3225- exe_ctx.GetBestExecutionContextScope (), error.Clone ());
3226- }
3227- if (!type.IsBoolean () && type_byte_size < val_byte_size) {
3228- Status error = Status::FromErrorString (
3229- " target type cannot be smaller than the pointer type" );
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)
32303223 return ValueObjectConstResult::Create (
3231- exe_ctx.GetBestExecutionContextScope (), error.Clone ());
3232- }
3224+ exe_ctx.GetBestExecutionContextScope (),
3225+ Status::FromErrorString (
3226+ " target type cannot be smaller than the pointer type" ));
32333227 }
32343228
32353229 if (type.IsBoolean ()) {
@@ -3241,13 +3235,12 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
32413235 if (float_value_or_err)
32423236 return ValueObject::CreateValueObjectFromBool (
32433237 target, !float_value_or_err->isZero (), " result" );
3244- else {
3245- Status error = Status::FromErrorStringWithFormat (
3246- " cannot get value as APFloat: %s" ,
3247- llvm::toString (float_value_or_err.takeError ()).c_str ());
3238+ else
32483239 return ValueObjectConstResult::Create (
3249- exe_ctx.GetBestExecutionContextScope (), error.Clone ());
3250- }
3240+ exe_ctx.GetBestExecutionContextScope (),
3241+ Status::FromErrorStringWithFormat (
3242+ " cannot get value as APFloat: %s" ,
3243+ llvm::toString (float_value_or_err.takeError ()).c_str ()));
32513244 }
32523245 }
32533246
@@ -3261,14 +3254,12 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
32613254 int_value_or_err->extOrTrunc (type_byte_size * CHAR_BIT);
32623255 return ValueObject::CreateValueObjectFromAPInt (target, ext, type,
32633256 " result" );
3264- } else {
3265- Status error = Status::FromErrorStringWithFormat (
3266- " cannot get value as APSInt: %s" ,
3267- llvm::toString (int_value_or_err.takeError ()).c_str ());
3268- ;
3257+ } else
32693258 return ValueObjectConstResult::Create (
3270- exe_ctx.GetBestExecutionContextScope (), error.Clone ());
3271- }
3259+ exe_ctx.GetBestExecutionContextScope (),
3260+ Status::FromErrorStringWithFormat (
3261+ " cannot get value as APSInt: %s" ,
3262+ llvm::toString (int_value_or_err.takeError ()).c_str ()));
32723263 } else if (is_scalar && is_float) {
32733264 llvm::APSInt integer (type_byte_size * CHAR_BIT, !type.IsSigned ());
32743265 bool is_exact;
@@ -3280,13 +3271,12 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
32803271
32813272 // Casting floating point values that are out of bounds of the target
32823273 // type is undefined behaviour.
3283- if (status & llvm::APFloatBase::opInvalidOp) {
3284- Status error = Status::FromErrorStringWithFormat (
3285- " invalid type cast detected: %s" ,
3286- llvm::toString (float_value_or_err.takeError ()).c_str ());
3274+ if (status & llvm::APFloatBase::opInvalidOp)
32873275 return ValueObjectConstResult::Create (
3288- exe_ctx.GetBestExecutionContextScope (), error.Clone ());
3289- }
3276+ exe_ctx.GetBestExecutionContextScope (),
3277+ Status::FromErrorStringWithFormat (
3278+ " invalid type cast detected: %s" ,
3279+ llvm::toString (float_value_or_err.takeError ()).c_str ()));
32903280 return ValueObject::CreateValueObjectFromAPInt (target, integer, type,
32913281 " result" );
32923282 }
@@ -3305,11 +3295,11 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
33053295 return ValueObject::CreateValueObjectFromAPFloat (target, f, type,
33063296 " result" );
33073297 } else {
3308- Status error = Status::FromErrorStringWithFormat (
3309- " cannot get value as APSInt: %s" ,
3310- llvm::toString (int_value_or_err.takeError ()).c_str ());
33113298 return ValueObjectConstResult::Create (
3312- exe_ctx.GetBestExecutionContextScope (), error.Clone ());
3299+ exe_ctx.GetBestExecutionContextScope (),
3300+ Status::FromErrorStringWithFormat (
3301+ " cannot get value as APSInt: %s" ,
3302+ llvm::toString (int_value_or_err.takeError ()).c_str ()));
33133303 }
33143304 } else {
33153305 if (is_integer) {
@@ -3321,11 +3311,11 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
33213311 return ValueObject::CreateValueObjectFromAPFloat (target, f, type,
33223312 " result" );
33233313 } else {
3324- Status error = Status::FromErrorStringWithFormat (
3325- " cannot get value as APSInt: %s" ,
3326- llvm::toString (int_value_or_err.takeError ()).c_str ());
33273314 return ValueObjectConstResult::Create (
3328- exe_ctx.GetBestExecutionContextScope (), error.Clone ());
3315+ exe_ctx.GetBestExecutionContextScope (),
3316+ Status::FromErrorStringWithFormat (
3317+ " cannot get value as APSInt: %s" ,
3318+ llvm::toString (int_value_or_err.takeError ()).c_str ()));
33293319 }
33303320 }
33313321 if (is_float) {
@@ -3337,19 +3327,19 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
33373327 return ValueObject::CreateValueObjectFromAPFloat (target, f, type,
33383328 " result" );
33393329 } else {
3340- Status error = Status::FromErrorStringWithFormat (
3341- " cannot get value as APFloat: %s" ,
3342- llvm::toString (float_value_or_err.takeError ()).c_str ());
33433330 return ValueObjectConstResult::Create (
3344- exe_ctx.GetBestExecutionContextScope (), error.Clone ());
3331+ exe_ctx.GetBestExecutionContextScope (),
3332+ Status::FromErrorStringWithFormat (
3333+ " cannot get value as APFloat: %s" ,
3334+ llvm::toString (float_value_or_err.takeError ()).c_str ()));
33453335 }
33463336 }
33473337 }
33483338 }
33493339
3350- Status error = Status::FromErrorString ( " Unable to perform requested cast " );
3351- return ValueObjectConstResult::Create ( exe_ctx.GetBestExecutionContextScope (),
3352- error. Clone ( ));
3340+ return ValueObjectConstResult::Create (
3341+ exe_ctx.GetBestExecutionContextScope (),
3342+ Status::FromErrorString ( " Unable to perform requested cast " ));
33533343}
33543344
33553345lldb::ValueObjectSP ValueObject::CastToEnumType (CompilerType type) {
@@ -3358,18 +3348,16 @@ lldb::ValueObjectSP ValueObject::CastToEnumType(CompilerType type) {
33583348 bool is_float = GetCompilerType ().IsFloat ();
33593349 ExecutionContext exe_ctx (GetExecutionContextRef ());
33603350
3361- if (!is_enum && !is_integer && !is_float) {
3362- Status error = Status::FromErrorString (
3363- " argument must be an integer, a float, or an enum" );
3351+ if (!is_enum && !is_integer && !is_float)
33643352 return ValueObjectConstResult::Create (
3365- exe_ctx.GetBestExecutionContextScope (), error.Clone ());
3366- }
3353+ exe_ctx.GetBestExecutionContextScope (),
3354+ Status::FromErrorString (
3355+ " argument must be an integer, a float, or an enum" ));
33673356
3368- if (!type.IsEnumerationType ()) {
3369- Status error = Status::FromErrorString (" target type must be an enum" );
3357+ if (!type.IsEnumerationType ())
33703358 return ValueObjectConstResult::Create (
3371- exe_ctx.GetBestExecutionContextScope (), error. Clone ());
3372- }
3359+ exe_ctx.GetBestExecutionContextScope (),
3360+ Status::FromErrorString ( " target type must be an enum " ));
33733361
33743362 lldb::TargetSP target = GetTargetSP ();
33753363 uint64_t byte_size = 0 ;
@@ -3386,38 +3374,35 @@ lldb::ValueObjectSP ValueObject::CastToEnumType(CompilerType type) {
33863374
33873375 // Casting floating point values that are out of bounds of the target
33883376 // type is undefined behaviour.
3389- if (status & llvm::APFloatBase::opInvalidOp) {
3390- Status error = Status::FromErrorStringWithFormat (
3391- " invalid type cast detected: %s" ,
3392- llvm::toString (value_or_err.takeError ()).c_str ());
3377+ if (status & llvm::APFloatBase::opInvalidOp)
33933378 return ValueObjectConstResult::Create (
3394- exe_ctx.GetBestExecutionContextScope (), error.Clone ());
3395- }
3379+ exe_ctx.GetBestExecutionContextScope (),
3380+ Status::FromErrorStringWithFormat (
3381+ " invalid type cast detected: %s" ,
3382+ llvm::toString (value_or_err.takeError ()).c_str ()));
33963383 return ValueObject::CreateValueObjectFromAPInt (target, integer, type,
33973384 " result" );
3398- } else {
3399- Status error = Status::FromErrorString (" cannot get value as APFloat" );
3385+ } else
34003386 return ValueObjectConstResult::Create (
3401- exe_ctx.GetBestExecutionContextScope (), error. Clone ());
3402- }
3387+ exe_ctx.GetBestExecutionContextScope (),
3388+ Status::FromErrorString ( " cannot get value as APFloat " ));
34033389 } else {
34043390 // Get the value as APSInt and extend or truncate it to the requested size.
34053391 auto value_or_err = GetValueAsAPSInt ();
34063392 if (value_or_err) {
34073393 llvm::APSInt ext = value_or_err->extOrTrunc (byte_size * CHAR_BIT);
34083394 return ValueObject::CreateValueObjectFromAPInt (target, ext, type,
34093395 " result" );
3410- } else {
3411- Status error = Status::FromErrorStringWithFormat (
3412- " cannot get value as APSInt: %s" ,
3413- llvm::toString (value_or_err.takeError ()).c_str ());
3396+ } else
34143397 return ValueObjectConstResult::Create (
3415- exe_ctx.GetBestExecutionContextScope (), error.Clone ());
3416- }
3398+ exe_ctx.GetBestExecutionContextScope (),
3399+ Status::FromErrorStringWithFormat (
3400+ " cannot get value as APSInt: %s" ,
3401+ llvm::toString (value_or_err.takeError ()).c_str ()));
34173402 }
3418- Status error = Status::FromErrorString ( " Cannot perform requested cast " );
3419- return ValueObjectConstResult::Create ( exe_ctx.GetBestExecutionContextScope (),
3420- error. Clone ( ));
3403+ return ValueObjectConstResult::Create (
3404+ exe_ctx.GetBestExecutionContextScope (),
3405+ Status::FromErrorString ( " Cannot perform requested cast " ));
34213406}
34223407
34233408ValueObject::EvaluationPoint::EvaluationPoint () : m_mod_id(), m_exe_ctx_ref() {}
0 commit comments