Skip to content

Commit 6167217

Browse files
committed
LLVMCodeBuilder: Fix raw value to unknown type conversion
1 parent 289dd14 commit 6167217

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/engine/internal/llvm/llvmcodebuilder.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -2320,6 +2320,9 @@ llvm::Value *LLVMCodeBuilder::castRawValue(LLVMRegister *reg, Compiler::StaticTy
23202320
return nullptr;
23212321
}
23222322

2323+
case Compiler::StaticType::Unknown:
2324+
return createValue(reg);
2325+
23232326
default:
23242327
assert(false);
23252328
return nullptr;

test/llvm/llvmcodebuilder_test.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,18 @@ TEST_F(LLVMCodeBuilderTest, FunctionCalls)
488488

489489
v = m_builder->addConstValue(321.5);
490490
m_builder->addFunctionCall("test_print_unknown", Compiler::StaticType::Void, { Compiler::StaticType::Unknown }, { v });
491+
v = m_builder->addFunctionCall("test_const_number", Compiler::StaticType::Number, { Compiler::StaticType::Number }, { v });
492+
m_builder->addFunctionCall("test_print_unknown", Compiler::StaticType::Void, { Compiler::StaticType::Unknown }, { v });
491493

492494
v = m_builder->addConstValue("test");
493495
m_builder->addFunctionCall("test_print_unknown", Compiler::StaticType::Void, { Compiler::StaticType::Unknown }, { v });
496+
v = m_builder->addFunctionCall("test_const_string", Compiler::StaticType::String, { Compiler::StaticType::String }, { v });
497+
m_builder->addFunctionCall("test_print_unknown", Compiler::StaticType::Void, { Compiler::StaticType::Unknown }, { v });
494498

495499
v = m_builder->addConstValue(true);
496500
m_builder->addFunctionCall("test_print_unknown", Compiler::StaticType::Void, { Compiler::StaticType::Unknown }, { v });
501+
v = m_builder->addFunctionCall("test_const_bool", Compiler::StaticType::Bool, { Compiler::StaticType::Bool }, { v });
502+
m_builder->addFunctionCall("test_print_unknown", Compiler::StaticType::Void, { Compiler::StaticType::Unknown }, { v });
497503

498504
auto code = m_builder->finalize();
499505
Script script(&m_target, nullptr, nullptr);
@@ -519,7 +525,10 @@ TEST_F(LLVMCodeBuilderTest, FunctionCalls)
519525
"123\n"
520526
"1\n"
521527
"321.5\n"
528+
"321.5\n"
529+
"test\n"
522530
"test\n"
531+
"true\n"
523532
"true\n";
524533

525534
EXPECT_CALL(m_target, isStage()).Times(7);

0 commit comments

Comments
 (0)