diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-11-06 01:47:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-05 09:47:26 -0800 |
| commit | b118451e301d734e3e783b3acdf871f3f6ea851c (patch) | |
| tree | 277f160d31e2c442f724bc6a2d3c09fabff403ca /source/slang-record-replay | |
| parent | 53dd5928c35d5a5cb1f7d2a563348fd1fa87d672 (diff) | |
Move switch statement bodies to their own lines (#5493)
* Move switch statement bodies to their own lines
* format
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang-record-replay')
| -rw-r--r-- | source/slang-record-replay/replay/json-consumer.h | 16 | ||||
| -rw-r--r-- | source/slang-record-replay/replay/slang-decoder.cpp | 76 | ||||
| -rw-r--r-- | source/slang-record-replay/util/emum-to-string.h | 98 |
3 files changed, 134 insertions, 56 deletions
diff --git a/source/slang-record-replay/replay/json-consumer.h b/source/slang-record-replay/replay/json-consumer.h index 8a367cc20..4eb03ba0a 100644 --- a/source/slang-record-replay/replay/json-consumer.h +++ b/source/slang-record-replay/replay/json-consumer.h @@ -16,13 +16,21 @@ public: { switch (classId) { - case ApiClassId::Class_IModule: m_className = "IModule"; break; - case ApiClassId::Class_IEntryPoint: m_className = "IEntryPoint"; break; + case ApiClassId::Class_IModule: + m_className = "IModule"; + break; + case ApiClassId::Class_IEntryPoint: + m_className = "IEntryPoint"; + break; case ApiClassId::Class_ICompositeComponentType: m_className = "ICompositeComponentType"; break; - case ApiClassId::Class_ITypeConformance: m_className = "ITypeConformance"; break; - default: slangRecordLog(LogLevel::Error, "Invalid classNo %u\n", classId); break; + case ApiClassId::Class_ITypeConformance: + m_className = "ITypeConformance"; + break; + default: + slangRecordLog(LogLevel::Error, "Invalid classNo %u\n", classId); + break; } } CommonInterfaceWriter() = delete; diff --git a/source/slang-record-replay/replay/slang-decoder.cpp b/source/slang-record-replay/replay/slang-decoder.cpp index a0ae842ea..7d9648a2a 100644 --- a/source/slang-record-replay/replay/slang-decoder.cpp +++ b/source/slang-record-replay/replay/slang-decoder.cpp @@ -46,7 +46,9 @@ bool SlangDecoder::processIGlobalSessionMethods( { switch (callId) { - default: slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); break; + default: + slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); + break; case ApiCallId::IGlobalSession_createSession: IGlobalSession_createSession(objectId, parameterBlock); break; @@ -143,7 +145,9 @@ bool SlangDecoder::processISessionMethods( case ApiCallId::ISession_getGlobalSession: ISession_getGlobalSession(objectId, parameterBlock); break; - case ApiCallId::ISession_loadModule: ISession_loadModule(objectId, parameterBlock); break; + case ApiCallId::ISession_loadModule: + ISession_loadModule(objectId, parameterBlock); + break; case ApiCallId::ISession_loadModuleFromIRBlob: ISession_loadModuleFromIRBlob(objectId, parameterBlock); break; @@ -159,7 +163,9 @@ bool SlangDecoder::processISessionMethods( case ApiCallId::ISession_specializeType: ISession_specializeType(objectId, parameterBlock); break; - case ApiCallId::ISession_getTypeLayout: ISession_getTypeLayout(objectId, parameterBlock); break; + case ApiCallId::ISession_getTypeLayout: + ISession_getTypeLayout(objectId, parameterBlock); + break; case ApiCallId::ISession_getContainerType: ISession_getContainerType(objectId, parameterBlock); break; @@ -213,33 +219,51 @@ bool SlangDecoder::processIModuleMethods( case ApiCallId::IModule_getDefinedEntryPoint: IModule_getDefinedEntryPoint(objectId, parameterBlock); break; - case ApiCallId::IModule_serialize: IModule_serialize(objectId, parameterBlock); break; - case ApiCallId::IModule_writeToFile: IModule_writeToFile(objectId, parameterBlock); break; - case ApiCallId::IModule_getName: IModule_getName(objectId, parameterBlock); break; - case ApiCallId::IModule_getFilePath: IModule_getFilePath(objectId, parameterBlock); break; + case ApiCallId::IModule_serialize: + IModule_serialize(objectId, parameterBlock); + break; + case ApiCallId::IModule_writeToFile: + IModule_writeToFile(objectId, parameterBlock); + break; + case ApiCallId::IModule_getName: + IModule_getName(objectId, parameterBlock); + break; + case ApiCallId::IModule_getFilePath: + IModule_getFilePath(objectId, parameterBlock); + break; case ApiCallId::IModule_getUniqueIdentity: IModule_getUniqueIdentity(objectId, parameterBlock); break; case ApiCallId::IModule_findAndCheckEntryPoint: IModule_findAndCheckEntryPoint(objectId, parameterBlock); break; - case ApiCallId::IModule_getSession: IModule_getSession(objectId, parameterBlock); break; - case ApiCallId::IModule_getLayout: IModule_getLayout(objectId, parameterBlock); break; + case ApiCallId::IModule_getSession: + IModule_getSession(objectId, parameterBlock); + break; + case ApiCallId::IModule_getLayout: + IModule_getLayout(objectId, parameterBlock); + break; case ApiCallId::IModule_getSpecializationParamCount: IModule_getSpecializationParamCount(objectId, parameterBlock); break; case ApiCallId::IModule_getEntryPointCode: IModule_getEntryPointCode(objectId, parameterBlock); break; - case ApiCallId::IModule_getTargetCode: IModule_getTargetCode(objectId, parameterBlock); break; + case ApiCallId::IModule_getTargetCode: + IModule_getTargetCode(objectId, parameterBlock); + break; case ApiCallId::IModule_getResultAsFileSystem: IModule_getResultAsFileSystem(objectId, parameterBlock); break; case ApiCallId::IModule_getEntryPointHash: IModule_getEntryPointHash(objectId, parameterBlock); break; - case ApiCallId::IModule_specialize: IModule_specialize(objectId, parameterBlock); break; - case ApiCallId::IModule_link: IModule_link(objectId, parameterBlock); break; + case ApiCallId::IModule_specialize: + IModule_specialize(objectId, parameterBlock); + break; + case ApiCallId::IModule_link: + IModule_link(objectId, parameterBlock); + break; case ApiCallId::IModule_getEntryPointHostCallable: IModule_getEntryPointHostCallable(objectId, parameterBlock); break; @@ -263,8 +287,12 @@ bool SlangDecoder::processIEntryPointMethods( default: slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); return false; - case ApiCallId::IEntryPoint_getSession: IEntryPoint_getSession(objectId, parameterBlock); break; - case ApiCallId::IEntryPoint_getLayout: IEntryPoint_getLayout(objectId, parameterBlock); break; + case ApiCallId::IEntryPoint_getSession: + IEntryPoint_getSession(objectId, parameterBlock); + break; + case ApiCallId::IEntryPoint_getLayout: + IEntryPoint_getLayout(objectId, parameterBlock); + break; case ApiCallId::IEntryPoint_getSpecializationParamCount: IEntryPoint_getSpecializationParamCount(objectId, parameterBlock); break; @@ -280,8 +308,12 @@ bool SlangDecoder::processIEntryPointMethods( case ApiCallId::IEntryPoint_getEntryPointHash: IEntryPoint_getEntryPointHash(objectId, parameterBlock); break; - case ApiCallId::IEntryPoint_specialize: IEntryPoint_specialize(objectId, parameterBlock); break; - case ApiCallId::IEntryPoint_link: IEntryPoint_link(objectId, parameterBlock); break; + case ApiCallId::IEntryPoint_specialize: + IEntryPoint_specialize(objectId, parameterBlock); + break; + case ApiCallId::IEntryPoint_link: + IEntryPoint_link(objectId, parameterBlock); + break; case ApiCallId::IEntryPoint_getEntryPointHostCallable: IEntryPoint_getEntryPointHostCallable(objectId, parameterBlock); break; @@ -302,7 +334,9 @@ bool SlangDecoder::processICompositeComponentTypeMethods( { switch (callId) { - default: slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); break; + default: + slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); + break; case ApiCallId::ICompositeComponentType_getSession: ICompositeComponentType_getSession(objectId, parameterBlock); break; @@ -377,7 +411,9 @@ bool SlangDecoder::processITypeConformanceMethods( case ApiCallId::ITypeConformance_specialize: ITypeConformance_specialize(objectId, parameterBlock); break; - case ApiCallId::ITypeConformance_link: ITypeConformance_link(objectId, parameterBlock); break; + case ApiCallId::ITypeConformance_link: + ITypeConformance_link(objectId, parameterBlock); + break; case ApiCallId::ITypeConformance_getEntryPointHostCallable: ITypeConformance_getEntryPointHostCallable(objectId, parameterBlock); break; @@ -400,7 +436,9 @@ bool SlangDecoder::processFunctionCall( default: slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", header.callId); return false; - case ApiCallId::CreateGlobalSession: CreateGlobalSession(parameterBlock); break; + case ApiCallId::CreateGlobalSession: + CreateGlobalSession(parameterBlock); + break; } return true; } diff --git a/source/slang-record-replay/util/emum-to-string.h b/source/slang-record-replay/util/emum-to-string.h index 60e5e2416..b19782126 100644 --- a/source/slang-record-replay/util/emum-to-string.h +++ b/source/slang-record-replay/util/emum-to-string.h @@ -5,7 +5,8 @@ namespace SlangRecord static Slang::String SlangCompileTargetToString(const SlangCompileTarget target) { #define CASE(x) \ - case x: return #x + case x: \ + return #x switch (target) { @@ -49,7 +50,8 @@ static Slang::String SlangProfileIDToString(const SlangProfileID profile) { switch (profile) { - case SLANG_PROFILE_UNKNOWN: return "SLANG_PROFILE_UNKNOWN"; + case SLANG_PROFILE_UNKNOWN: + return "SLANG_PROFILE_UNKNOWN"; default: Slang::StringBuilder str; str << "Unknown SlangProfileID: " << static_cast<uint32_t>(profile); @@ -65,7 +67,8 @@ static Slang::String SlangTargetFlagsToString(const SlangTargetFlags flags) return "SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES"; case SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM: return "SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM"; - case SLANG_TARGET_FLAG_DUMP_IR: return "SLANG_TARGET_FLAG_DUMP_IR"; + case SLANG_TARGET_FLAG_DUMP_IR: + return "SLANG_TARGET_FLAG_DUMP_IR"; case SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY: return "SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY"; default: @@ -79,9 +82,12 @@ static Slang::String SlangFloatingPointModeToString(const SlangFloatingPointMode { switch (mode) { - case SLANG_FLOATING_POINT_MODE_DEFAULT: return "SLANG_FLOATING_POINT_MODE_DEFAULT"; - case SLANG_FLOATING_POINT_MODE_FAST: return "SLANG_FLOATING_POINT_MODE_FAST"; - case SLANG_FLOATING_POINT_MODE_PRECISE: return "SLANG_FLOATING_POINT_MODE_PRECISE"; + case SLANG_FLOATING_POINT_MODE_DEFAULT: + return "SLANG_FLOATING_POINT_MODE_DEFAULT"; + case SLANG_FLOATING_POINT_MODE_FAST: + return "SLANG_FLOATING_POINT_MODE_FAST"; + case SLANG_FLOATING_POINT_MODE_PRECISE: + return "SLANG_FLOATING_POINT_MODE_PRECISE"; default: Slang::StringBuilder str; str << "Unknown SlangFloatingPointMode: " << static_cast<uint32_t>(mode); @@ -93,11 +99,16 @@ static Slang::String SlangLineDirectiveModeToString(const SlangLineDirectiveMode { switch (mode) { - case SLANG_LINE_DIRECTIVE_MODE_DEFAULT: return "SLANG_LINE_DIRECTIVE_MODE_DEFAULT"; - case SLANG_LINE_DIRECTIVE_MODE_NONE: return "SLANG_LINE_DIRECTIVE_MODE_NONE"; - case SLANG_LINE_DIRECTIVE_MODE_STANDARD: return "SLANG_LINE_DIRECTIVE_MODE_STANDARD"; - case SLANG_LINE_DIRECTIVE_MODE_GLSL: return "SLANG_LINE_DIRECTIVE_MODE_GLSL"; - case SLANG_LINE_DIRECTIVE_MODE_SOURCE_MAP: return "SLANG_LINE_DIRECTIVE_MODE_SOURCE_MAP"; + case SLANG_LINE_DIRECTIVE_MODE_DEFAULT: + return "SLANG_LINE_DIRECTIVE_MODE_DEFAULT"; + case SLANG_LINE_DIRECTIVE_MODE_NONE: + return "SLANG_LINE_DIRECTIVE_MODE_NONE"; + case SLANG_LINE_DIRECTIVE_MODE_STANDARD: + return "SLANG_LINE_DIRECTIVE_MODE_STANDARD"; + case SLANG_LINE_DIRECTIVE_MODE_GLSL: + return "SLANG_LINE_DIRECTIVE_MODE_GLSL"; + case SLANG_LINE_DIRECTIVE_MODE_SOURCE_MAP: + return "SLANG_LINE_DIRECTIVE_MODE_SOURCE_MAP"; default: Slang::StringBuilder str; str << "Unknown SlangLineDirectiveMode: " << static_cast<uint32_t>(mode); @@ -107,8 +118,9 @@ static Slang::String SlangLineDirectiveModeToString(const SlangLineDirectiveMode static Slang::String CompilerOptionNameToString(const slang::CompilerOptionName name) { -#define CASE(x) \ - case CompilerOptionName::x: return #x +#define CASE(x) \ + case CompilerOptionName::x: \ + return #x using namespace slang; switch (name) @@ -235,8 +247,10 @@ static Slang::String CompilerOptionValueKindToString(const slang::CompilerOption using namespace slang; switch (kind) { - case CompilerOptionValueKind::Int: return "Int"; - case CompilerOptionValueKind::String: return "String"; + case CompilerOptionValueKind::Int: + return "Int"; + case CompilerOptionValueKind::String: + return "String"; default: Slang::StringBuilder str; str << "Unknown CompilerOptionValueKind: " << static_cast<uint32_t>(kind); @@ -249,7 +263,8 @@ static Slang::String SessionFlagsToString(const slang::SessionFlags flags) using namespace slang; switch (flags) { - case kSessionFlags_None: return "kSessionFlags_None"; + case kSessionFlags_None: + return "kSessionFlags_None"; default: Slang::StringBuilder str; str << "Unknown SessionFlags: " << static_cast<uint32_t>(flags); @@ -261,9 +276,12 @@ static Slang::String SlangMatrixLayoutModeToString(const SlangMatrixLayoutMode m { switch (mode) { - case SLANG_MATRIX_LAYOUT_MODE_UNKNOWN: return "SLANG_MATRIX_LAYOUT_MODE_UNKNOWN"; - case SLANG_MATRIX_LAYOUT_ROW_MAJOR: return "SLANG_MATRIX_LAYOUT_ROW_MAJOR"; - case SLANG_MATRIX_LAYOUT_COLUMN_MAJOR: return "SLANG_MATRIX_LAYOUT_COLUMN_MAJOR"; + case SLANG_MATRIX_LAYOUT_MODE_UNKNOWN: + return "SLANG_MATRIX_LAYOUT_MODE_UNKNOWN"; + case SLANG_MATRIX_LAYOUT_ROW_MAJOR: + return "SLANG_MATRIX_LAYOUT_ROW_MAJOR"; + case SLANG_MATRIX_LAYOUT_COLUMN_MAJOR: + return "SLANG_MATRIX_LAYOUT_COLUMN_MAJOR"; default: Slang::StringBuilder str; str << "Unknown SlangMatrixLayoutMode: " << static_cast<uint32_t>(mode); @@ -274,7 +292,8 @@ static Slang::String SlangMatrixLayoutModeToString(const SlangMatrixLayoutMode m static Slang::String SlangPassThroughToString(const SlangPassThrough passThrough) { #define CASE(x) \ - case x: return #x + case x: \ + return #x switch (passThrough) { @@ -303,7 +322,8 @@ static Slang::String SlangPassThroughToString(const SlangPassThrough passThrough static Slang::String SlangSourceLanguageToString(const SlangSourceLanguage language) { #define CASE(x) \ - case x: return #x + case x: \ + return #x switch (language) { @@ -329,7 +349,8 @@ static Slang::String CompileCoreModuleFlagsToString(const slang::CompileCoreModu using namespace slang; switch (flags) { - case CompileCoreModuleFlag::WriteDocumentation: return "WriteDocumentation"; + case CompileCoreModuleFlag::WriteDocumentation: + return "WriteDocumentation"; default: Slang::StringBuilder str; str << "Unknown CompileCoreModuleFlags: " << static_cast<uint32_t>(flags); @@ -340,7 +361,8 @@ static Slang::String CompileCoreModuleFlagsToString(const slang::CompileCoreModu static Slang::String SlangArchiveTypeToString(const SlangArchiveType type) { #define CASE(x) \ - case x: return #x + case x: \ + return #x switch (type) { CASE(SLANG_ARCHIVE_TYPE_UNDEFINED); @@ -361,8 +383,10 @@ static Slang::String SpecializationArgKindToString(const slang::SpecializationAr using namespace slang; switch (kind) { - case SpecializationArg::Kind::Unknown: return "Unknown"; - case SpecializationArg::Kind::Type: return "Type"; + case SpecializationArg::Kind::Unknown: + return "Unknown"; + case SpecializationArg::Kind::Type: + return "Type"; default: Slang::StringBuilder str; str << "Unknown SpecializationArg::Kind: " << static_cast<uint32_t>(kind); @@ -375,8 +399,10 @@ static Slang::String LayoutRulesToString(const slang::LayoutRules rules) using namespace slang; switch (rules) { - case LayoutRules::Default: return "Default"; - case LayoutRules::MetalArgumentBufferTier2: return "MetalArgumentBufferTier2"; + case LayoutRules::Default: + return "Default"; + case LayoutRules::MetalArgumentBufferTier2: + return "MetalArgumentBufferTier2"; default: Slang::StringBuilder str; str << "Unknown LayoutRules: " << static_cast<uint32_t>(rules); @@ -387,7 +413,8 @@ static Slang::String LayoutRulesToString(const slang::LayoutRules rules) static Slang::String SlangStageToString(const SlangStage stage) { #define CASE(x) \ - case x: return #x + case x: \ + return #x switch (stage) { @@ -419,11 +446,16 @@ static Slang::String ContainerTypeToString(const slang::ContainerType type) using namespace slang; switch (type) { - case ContainerType::None: return "None"; - case ContainerType::UnsizedArray: return "UnsizedArray"; - case ContainerType::StructuredBuffer: return "StructuredBuffer"; - case ContainerType::ConstantBuffer: return "ConstantBuffer"; - case ContainerType::ParameterBlock: return "ParameterBlock"; + case ContainerType::None: + return "None"; + case ContainerType::UnsizedArray: + return "UnsizedArray"; + case ContainerType::StructuredBuffer: + return "StructuredBuffer"; + case ContainerType::ConstantBuffer: + return "ConstantBuffer"; + case ContainerType::ParameterBlock: + return "ParameterBlock"; default: Slang::StringBuilder str; str << "Unknown ContainerType: " << static_cast<uint32_t>(type); |
