File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -503,6 +503,16 @@ Interpreter::Visit(const ScalarLiteralNode *node) {
503
503
auto type = PickLiteralType (type_system, m_exe_ctx_scope, node);
504
504
if (type) {
505
505
Scalar scalar = node->GetValue ();
506
+ // APInt from StringRef::getAsInteger comes with just enough bitwidth to
507
+ // hold the value. This adjusts APInt bitwidth to match the compiler type.
508
+ if (scalar.GetType () == scalar.e_int ) {
509
+ auto apsint = scalar.GetAPSInt ();
510
+ auto type_bitsize = type->GetBitSize (m_exe_ctx_scope.get ());
511
+ if (type_bitsize) {
512
+ llvm::APInt adjusted = apsint.zextOrTrunc (*type_bitsize);
513
+ scalar = Scalar (adjusted);
514
+ }
515
+ }
506
516
return ValueObject::CreateValueObjectFromScalar (m_target, scalar, *type,
507
517
" result" );
508
518
} else
You can’t perform that action at this time.
0 commit comments