From f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 29 Oct 2024 14:49:26 +0800 Subject: format * format * Minor test fixes * enable checking cpp format in ci --- .../slang/slang-ir-check-shader-parameter-type.cpp | 93 ++++++++++++---------- 1 file changed, 50 insertions(+), 43 deletions(-) (limited to 'source/slang/slang-ir-check-shader-parameter-type.cpp') diff --git a/source/slang/slang-ir-check-shader-parameter-type.cpp b/source/slang/slang-ir-check-shader-parameter-type.cpp index 71833c838..6f3161110 100644 --- a/source/slang/slang-ir-check-shader-parameter-type.cpp +++ b/source/slang/slang-ir-check-shader-parameter-type.cpp @@ -1,65 +1,72 @@ #include "slang-ir-check-shader-parameter-type.h" + #include "slang-ir-util.h" namespace Slang { - void checkForInvalidShaderParameterTypeForMetal(IRModule* module, DiagnosticSink* sink) +void checkForInvalidShaderParameterTypeForMetal(IRModule* module, DiagnosticSink* sink) +{ + HashSet workListSet; + List workList; + for (auto inst : module->getGlobalInsts()) { - HashSet workListSet; - List workList; - for (auto inst : module->getGlobalInsts()) + if (inst->getOp() == kIROp_ParameterBlockType) { - if (inst->getOp() == kIROp_ParameterBlockType) + auto type = inst->getOperand(0); + if (workListSet.add(type)) + workList.add(type); + // Diagnose an error on `ParameterBlock>`. + if (type->getOp() == kIROp_ConstantBufferType) { - auto type = inst->getOperand(0); - if (workListSet.add(type)) - workList.add(type); - // Diagnose an error on `ParameterBlock>`. - if (type->getOp() == kIROp_ConstantBufferType) + bool foundUseSite = false; + for (auto use = inst->firstUse; use; use = use->nextUse) { - bool foundUseSite = false; - for (auto use = inst->firstUse; use; use = use->nextUse) + auto user = use->getUser(); + if (user->sourceLoc.isValid()) { - auto user = use->getUser(); - if (user->sourceLoc.isValid()) - { - sink->diagnose(user, Diagnostics::constantBufferInParameterBlockNotAllowedOnMetal); - foundUseSite = true; - break; - } + sink->diagnose( + user, + Diagnostics::constantBufferInParameterBlockNotAllowedOnMetal); + foundUseSite = true; + break; } - if (!foundUseSite) - sink->diagnose(inst, Diagnostics::constantBufferInParameterBlockNotAllowedOnMetal); } + if (!foundUseSite) + sink->diagnose( + inst, + Diagnostics::constantBufferInParameterBlockNotAllowedOnMetal); } } - // Diagnose an error any any struct fields whose type is `ConstantBuffer` if the - // struct is used inside a `ParameterBlock`. - for (Index i = 0; i < workList.getCount(); i++) + } + // Diagnose an error any any struct fields whose type is `ConstantBuffer` if the + // struct is used inside a `ParameterBlock`. + for (Index i = 0; i < workList.getCount(); i++) + { + auto type = workList[i]; + if (auto structType = as(type)) { - auto type = workList[i]; - if (auto structType = as(type)) + for (auto field : structType->getFields()) { - for (auto field : structType->getFields()) + auto fieldType = field->getFieldType(); + if (fieldType->getOp() == kIROp_ConstantBufferType) { - auto fieldType = field->getFieldType(); - if (fieldType->getOp() == kIROp_ConstantBufferType) - { - sink->diagnose(field->getKey(), Diagnostics::constantBufferInParameterBlockNotAllowedOnMetal); - } - if (workListSet.add(fieldType)) - workList.add(fieldType); + sink->diagnose( + field->getKey(), + Diagnostics::constantBufferInParameterBlockNotAllowedOnMetal); } + if (workListSet.add(fieldType)) + workList.add(fieldType); } } } +} - void checkForInvalidShaderParameterType( - TargetRequest* target, - IRModule* module, - DiagnosticSink* sink) - { - if (isMetalTarget(target)) - checkForInvalidShaderParameterTypeForMetal(module, sink); - } -} \ No newline at end of file +void checkForInvalidShaderParameterType( + TargetRequest* target, + IRModule* module, + DiagnosticSink* sink) +{ + if (isMetalTarget(target)) + checkForInvalidShaderParameterTypeForMetal(module, sink); +} +} // namespace Slang \ No newline at end of file -- cgit v1.2.3