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 --- source/slang/slang-ir-specialize-dispatch.cpp | 44 ++++++++++++++------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'source/slang/slang-ir-specialize-dispatch.cpp') diff --git a/source/slang/slang-ir-specialize-dispatch.cpp b/source/slang/slang-ir-specialize-dispatch.cpp index 9eba0aa4f..ae7b2dc67 100644 --- a/source/slang/slang-ir-specialize-dispatch.cpp +++ b/source/slang/slang-ir-specialize-dispatch.cpp @@ -2,17 +2,20 @@ #include "slang-ir-generics-lowering-context.h" #include "slang-ir-insts.h" -#include "slang-ir.h" #include "slang-ir-util.h" +#include "slang-ir.h" namespace Slang { -IRFunc* specializeDispatchFunction(SharedGenericsLoweringContext* sharedContext, IRFunc* dispatchFunc) +IRFunc* specializeDispatchFunction( + SharedGenericsLoweringContext* sharedContext, + IRFunc* dispatchFunc) { auto witnessTableType = cast(dispatchFunc->getDataType())->getParamType(0); auto conformanceType = cast(witnessTableType)->getConformanceType(); // Collect all witness tables of `witnessTableType` in current module. - List witnessTables = sharedContext->getWitnessTablesFromInterfaceType(conformanceType); + List witnessTables = + sharedContext->getWitnessTablesFromInterfaceType(conformanceType); SLANG_ASSERT(dispatchFunc->getFirstBlock() == dispatchFunc->getLastBlock()); auto block = dispatchFunc->getFirstBlock(); @@ -28,17 +31,10 @@ IRFunc* specializeDispatchFunction(SharedGenericsLoweringContext* sharedContext, { switch (inst->getOp()) { - case kIROp_Call: - callInst = cast(inst); - break; - case kIROp_LookupWitness: - lookupInst = cast(inst); - break; - case kIROp_Return: - returnInst = cast(inst); - break; - default: - break; + case kIROp_Call: callInst = cast(inst); break; + case kIROp_LookupWitness: lookupInst = cast(inst); break; + case kIROp_Return: returnInst = cast(inst); break; + default: break; } } SLANG_ASSERT(callInst && lookupInst && returnInst); @@ -56,7 +52,8 @@ IRFunc* specializeDispatchFunction(SharedGenericsLoweringContext* sharedContext, paramTypes.add(paramInst->getFullType()); } - // Modify the first paramter from IRWitnessTable to IRWitnessTableID representing the sequential ID. + // Modify the first paramter from IRWitnessTable to IRWitnessTableID representing the sequential + // ID. paramTypes[0] = builder->getWitnessTableIDType((IRType*)conformanceType); auto newDipsatchFuncType = builder->getFuncType(paramTypes, dispatchFunc->getResultType()); @@ -95,7 +92,10 @@ IRFunc* specializeDispatchFunction(SharedGenericsLoweringContext* sharedContext, auto seqIdDecoration = witnessTable->findDecoration(); if (!seqIdDecoration) { - sharedContext->sink->diagnose(witnessTable->getConcreteType(), Diagnostics::typeCannotBeUsedInDynamicDispatch, witnessTable->getConcreteType()); + sharedContext->sink->diagnose( + witnessTable->getConcreteType(), + Diagnostics::typeCannotBeUsedInDynamicDispatch, + witnessTable->getConcreteType()); } if (i != witnessTables.getCount() - 1) @@ -226,11 +226,12 @@ void ensureWitnessTableSequentialIDs(SharedGenericsLoweringContext* sharedContex else { auto witnessTableType = as(inst->getDataType()); - if (witnessTableType && witnessTableType->getConformanceType()->findDecoration()) + if (witnessTableType && witnessTableType->getConformanceType() + ->findDecoration()) { - // The interface is for specialization only, it would be an error if dynamic dispatch is used - // through the interface. - // Skip assigning ID for the witness table. + // The interface is for specialization only, it would be an error if dynamic + // dispatch is used through the interface. Skip assigning ID for the witness + // table. continue; } @@ -264,7 +265,8 @@ void ensureWitnessTableSequentialIDs(SharedGenericsLoweringContext* sharedContex // Get a sequential ID for the witness table using the map from the Linkage. uint32_t seqID = 0; if (!linkage->mapMangledNameToRTTIObjectIndex.tryGetValue( - witnessTableMangledName, seqID)) + witnessTableMangledName, + seqID)) { auto interfaceType = cast(inst->getDataType())->getConformanceType(); -- cgit v1.2.3