[spirv] Support CXXDefaultArgExpr translation. (#825)

This commit is contained in:
Ehsan 2017-11-20 08:46:07 -05:00 коммит произвёл GitHub
Родитель 06aadc4789
Коммит 3809395c08
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -509,6 +509,10 @@ SpirvEvalInfo SPIRVEmitter::doExpr(const Expr *expr) {
return doConditionalOperator(condExpr);
}
if (const auto *defaultArgExpr = dyn_cast<CXXDefaultArgExpr>(expr)) {
return doExpr(defaultArgExpr->getParam()->getDefaultArg());
}
if (isa<CXXThisExpr>(expr)) {
assert(curThis);
return curThis;

Просмотреть файл

@ -0,0 +1,28 @@
// Run: %dxc -T vs_6_0 -E main
int foo(int x = 5)
{
return x + 1;
}
void main()
{
// CHECK: %param_var_x = OpVariable %_ptr_Function_int Function
// CHECK-NEXT: %param_var_x_0 = OpVariable %_ptr_Function_int Function
// CHECK-NEXT: %param_var_x_1 = OpVariable %_ptr_Function_int Function
// CHECK-NEXT: OpStore %param_var_x %int_5
// CHECK-NEXT: {{%\d+}} = OpFunctionCall %int %foo %param_var_x
// Call without passing arg.
foo();
// CHECK-NEXT: OpStore %param_var_x_0 %int_2
// CHECK-NEXT: {{%\d+}} = OpFunctionCall %int %foo %param_var_x_0
// Call with passing arg.
foo(2);
// CHECK-NEXT: OpStore %param_var_x_1 %int_5
// CHECK-NEXT: {{%\d+}} = OpFunctionCall %int %foo %param_var_x_1
// Call without passing arg again.
foo();
}

Просмотреть файл

@ -354,6 +354,7 @@ TEST_F(FileTest, ControlFlowConditionalOp) { runFileTest("cf.cond-op.hlsl"); }
// For functions
TEST_F(FileTest, FunctionCall) { runFileTest("fn.call.hlsl"); }
TEST_F(FileTest, FunctionDefaultArg) { runFileTest("fn.default-arg.hlsl"); }
TEST_F(FileTest, FunctionInOutParam) { runFileTest("fn.param.inout.hlsl"); }
// For OO features