diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 14:49:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 14:49:26 +0800 |
| commit | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch) | |
| tree | ea1d61342cd29368e19135000ec2948813096205 /source/slang/slang-compiler-options.cpp | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'source/slang/slang-compiler-options.cpp')
| -rw-r--r-- | source/slang/slang-compiler-options.cpp | 583 |
1 files changed, 301 insertions, 282 deletions
diff --git a/source/slang/slang-compiler-options.cpp b/source/slang/slang-compiler-options.cpp index 3325a313a..c01d3fb9c 100644 --- a/source/slang/slang-compiler-options.cpp +++ b/source/slang/slang-compiler-options.cpp @@ -1,339 +1,358 @@ #include "slang-compiler-options.h" + #include "slang-compiler.h" namespace Slang { - void CompilerOptionSet::load(uint32_t count, slang::CompilerOptionEntry* entries) +void CompilerOptionSet::load(uint32_t count, slang::CompilerOptionEntry* entries) +{ + for (uint32_t i = 0; i < count; i++) { - for (uint32_t i = 0; i < count; i++) + CompilerOptionValue value; + value.kind = entries[i].value.kind; + value.intValue = entries[i].value.intValue0; + value.intValue2 = entries[i].value.intValue1; + if (value.kind == CompilerOptionValueKind::String) { - CompilerOptionValue value; - value.kind = entries[i].value.kind; - value.intValue = entries[i].value.intValue0; - value.intValue2 = entries[i].value.intValue1; - if (value.kind == CompilerOptionValueKind::String) - { - value.stringValue = entries[i].value.stringValue0; - value.stringValue2 = entries[i].value.stringValue1; - } - add(entries[i].name, value); + value.stringValue = entries[i].value.stringValue0; + value.stringValue2 = entries[i].value.stringValue1; } + add(entries[i].name, value); } +} - void CompilerOptionSet::writeCommandLineArgs(Session* globalSession, StringBuilder& sb) +void CompilerOptionSet::writeCommandLineArgs(Session* globalSession, StringBuilder& sb) +{ + for (auto& option : options) { - for (auto& option : options) + auto optionInfoIndex = globalSession->m_commandOptions.findOptionByUserValue( + CommandOptions::UserValue(option.key)); + if (optionInfoIndex == -1) + continue; + auto optionInfo = globalSession->m_commandOptions.getOptionAt(optionInfoIndex); + auto nameCommaIndex = optionInfo.names.indexOf(','); + if (nameCommaIndex == -1) + nameCommaIndex = optionInfo.names.getLength(); + auto name = optionInfo.names.head(nameCommaIndex); + switch (option.key) { - auto optionInfoIndex = globalSession->m_commandOptions.findOptionByUserValue(CommandOptions::UserValue(option.key)); - if (optionInfoIndex == -1) - continue; - auto optionInfo = globalSession->m_commandOptions.getOptionAt(optionInfoIndex); - auto nameCommaIndex = optionInfo.names.indexOf(','); - if (nameCommaIndex == -1) nameCommaIndex = optionInfo.names.getLength(); - auto name = optionInfo.names.head(nameCommaIndex); - switch (option.key) + case CompilerOptionName::Capability: + for (auto v : option.value) { - case CompilerOptionName::Capability: - for (auto v : option.value) - { - sb << " " << optionInfo.names << " " << v.stringValue; - } - break; - case CompilerOptionName::Include: - for (auto v : option.value) - { - sb << " -I \"" << v.stringValue << "\""; - } - break; - case CompilerOptionName::MacroDefine: - for (auto v : option.value) - { - sb << " -D" << v.stringValue; - if (v.stringValue2.getLength()) - sb << "=" << v.stringValue2; - } - break; - case CompilerOptionName::VulkanBindShift: // intValue0 (higher 8 bits): kind; intValue0(higher bits): set; intValue1: shift - for (auto v : option.value) - { - uint8_t kind; - int set, shift; - v.unpackInt3(kind, set, shift); - switch ((HLSLToVulkanLayoutOptions::Kind)(kind)) - { - case HLSLToVulkanLayoutOptions::Kind::UnorderedAccess: - sb << " -fvk-u-shift"; - break; - case HLSLToVulkanLayoutOptions::Kind::Sampler: - sb << " -fvk-s-shift"; - break; - case HLSLToVulkanLayoutOptions::Kind::ShaderResource: - sb << " -fvk-t-shift"; - break; - case HLSLToVulkanLayoutOptions::Kind::ConstantBuffer: - sb << " -fvk-b-shift"; - break; - default: - continue; - } - sb << " " << shift << " " << set; - } - break; - case CompilerOptionName::VulkanBindShiftAll: // intValue0: set; intValue1: shift - for (auto v : option.value) - { - sb << " -fvk-all-shift " << v.intValue2 << " " << v.intValue; - } - break; - case CompilerOptionName::VulkanBindGlobals: // intValue0: index; intValue1: set - for (auto v : option.value) - { - sb << " " << name << v.intValue << " " << v.intValue2; - } - break; - case CompilerOptionName::Optimization: - for (auto v : option.value) - { - sb << " -O" << v.intValue; - } - break; - case CompilerOptionName::DownstreamArgs: - for (auto v : option.value) - { - List<UnownedStringSlice> lines; - StringUtil::split(v.stringValue2.getUnownedSlice(), '\n', lines); - for (auto l : lines) - { - sb << " -x" << v.stringValue << " " << l.trim(); - } - } - break; - case CompilerOptionName::EmitSpirvDirectly: - case CompilerOptionName::GLSLForceScalarLayout: - case CompilerOptionName::ForceDXLayout: - case CompilerOptionName::MatrixLayoutRow: - case CompilerOptionName::MatrixLayoutColumn: - case CompilerOptionName::VulkanInvertY: - case CompilerOptionName::VulkanUseDxPositionW: - case CompilerOptionName::VulkanUseEntryPointName: - case CompilerOptionName::VulkanUseGLLayout: - case CompilerOptionName::VulkanEmitReflection: - case CompilerOptionName::EnableEffectAnnotations: - case CompilerOptionName::DefaultImageFormatUnknown: - case CompilerOptionName::DisableDynamicDispatch: - case CompilerOptionName::DisableSpecialization: - case CompilerOptionName::DumpIntermediates: - if (option.value.getCount() && option.value[0].intValue != 0) - sb << " " << name; - break; + sb << " " << optionInfo.names << " " << v.stringValue; } - } - } - - void CompilerOptionSet::buildHash(DigestBuilder<SHA1>& builder) - { - for (auto& kv : options) - { - builder.append(kv.key); - builder.append(kv.value.getCount()); - for (auto& v : kv.value) + break; + case CompilerOptionName::Include: + for (auto v : option.value) { - if (v.kind == CompilerOptionValueKind::Int) + sb << " -I \"" << v.stringValue << "\""; + } + break; + case CompilerOptionName::MacroDefine: + for (auto v : option.value) + { + sb << " -D" << v.stringValue; + if (v.stringValue2.getLength()) + sb << "=" << v.stringValue2; + } + break; + case CompilerOptionName::VulkanBindShift: // intValue0 (higher 8 bits): kind; + // intValue0(higher bits): set; intValue1: + // shift + for (auto v : option.value) + { + uint8_t kind; + int set, shift; + v.unpackInt3(kind, set, shift); + switch ((HLSLToVulkanLayoutOptions::Kind)(kind)) { - builder.append(v.intValue); + case HLSLToVulkanLayoutOptions::Kind::UnorderedAccess: sb << " -fvk-u-shift"; break; + case HLSLToVulkanLayoutOptions::Kind::Sampler: sb << " -fvk-s-shift"; break; + case HLSLToVulkanLayoutOptions::Kind::ShaderResource: sb << " -fvk-t-shift"; break; + case HLSLToVulkanLayoutOptions::Kind::ConstantBuffer: sb << " -fvk-b-shift"; break; + default: continue; } - else + sb << " " << shift << " " << set; + } + break; + case CompilerOptionName::VulkanBindShiftAll: // intValue0: set; intValue1: shift + for (auto v : option.value) + { + sb << " -fvk-all-shift " << v.intValue2 << " " << v.intValue; + } + break; + case CompilerOptionName::VulkanBindGlobals: // intValue0: index; intValue1: set + for (auto v : option.value) + { + sb << " " << name << v.intValue << " " << v.intValue2; + } + break; + case CompilerOptionName::Optimization: + for (auto v : option.value) + { + sb << " -O" << v.intValue; + } + break; + case CompilerOptionName::DownstreamArgs: + for (auto v : option.value) + { + List<UnownedStringSlice> lines; + StringUtil::split(v.stringValue2.getUnownedSlice(), '\n', lines); + for (auto l : lines) { - builder.append(v.stringValue); - builder.append(v.stringValue2); + sb << " -x" << v.stringValue << " " << l.trim(); } } + break; + case CompilerOptionName::EmitSpirvDirectly: + case CompilerOptionName::GLSLForceScalarLayout: + case CompilerOptionName::ForceDXLayout: + case CompilerOptionName::MatrixLayoutRow: + case CompilerOptionName::MatrixLayoutColumn: + case CompilerOptionName::VulkanInvertY: + case CompilerOptionName::VulkanUseDxPositionW: + case CompilerOptionName::VulkanUseEntryPointName: + case CompilerOptionName::VulkanUseGLLayout: + case CompilerOptionName::VulkanEmitReflection: + case CompilerOptionName::EnableEffectAnnotations: + case CompilerOptionName::DefaultImageFormatUnknown: + case CompilerOptionName::DisableDynamicDispatch: + case CompilerOptionName::DisableSpecialization: + case CompilerOptionName::DumpIntermediates: + if (option.value.getCount() && option.value[0].intValue != 0) + sb << " " << name; + break; } } +} - bool CompilerOptionSet::allowDuplicate(CompilerOptionName name) - { - switch (name) - { - case CompilerOptionName::Include: - case CompilerOptionName::MacroDefine: - case CompilerOptionName::WarningsAsErrors: - case CompilerOptionName::DisableWarning: - case CompilerOptionName::DisableWarnings: - case CompilerOptionName::EnableWarning: - case CompilerOptionName::Capability: - case CompilerOptionName::DownstreamArgs: - case CompilerOptionName::VulkanBindShift: - case CompilerOptionName::VulkanBindShiftAll: - return true; - } - return false; - } - CompilerOptionValue Slang::CompilerOptionSet::getDefault(CompilerOptionName name) +void CompilerOptionSet::buildHash(DigestBuilder<SHA1>& builder) +{ + for (auto& kv : options) { - switch (name) + builder.append(kv.key); + builder.append(kv.value.getCount()); + for (auto& v : kv.value) { - case CompilerOptionName::Optimization: - return CompilerOptionValue::fromEnum(OptimizationLevel::Default); - default: - return CompilerOptionValue(); + if (v.kind == CompilerOptionValueKind::Int) + { + builder.append(v.intValue); + } + else + { + builder.append(v.stringValue); + builder.append(v.stringValue2); + } } } +} - SlangTargetFlags CompilerOptionSet::getTargetFlags() +bool CompilerOptionSet::allowDuplicate(CompilerOptionName name) +{ + switch (name) { - SlangTargetFlags result = 0; - if (getBoolOption(CompilerOptionName::DumpIr)) - result |= SLANG_TARGET_FLAG_DUMP_IR; - if (getBoolOption(CompilerOptionName::GenerateWholeProgram)) - result |= SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM; - if (!getBoolOption(CompilerOptionName::EmitSpirvViaGLSL)) - result |= SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY; - if (getBoolOption(CompilerOptionName::ParameterBlocksUseRegisterSpaces)) - result |= SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES; - return result; + case CompilerOptionName::Include: + case CompilerOptionName::MacroDefine: + case CompilerOptionName::WarningsAsErrors: + case CompilerOptionName::DisableWarning: + case CompilerOptionName::DisableWarnings: + case CompilerOptionName::EnableWarning: + case CompilerOptionName::Capability: + case CompilerOptionName::DownstreamArgs: + case CompilerOptionName::VulkanBindShift: + case CompilerOptionName::VulkanBindShiftAll: return true; } - - void CompilerOptionSet::setTargetFlags(SlangTargetFlags flags) + return false; +} +CompilerOptionValue Slang::CompilerOptionSet::getDefault(CompilerOptionName name) +{ + switch (name) { - set(CompilerOptionName::DumpIr, (flags & SLANG_TARGET_FLAG_DUMP_IR) != 0); - set(CompilerOptionName::GenerateWholeProgram, (flags & SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM) != 0); - if ((flags & SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY) != 0) - set(CompilerOptionName::EmitSpirvViaGLSL, false); - else - set(CompilerOptionName::EmitSpirvViaGLSL, true); - set(CompilerOptionName::ParameterBlocksUseRegisterSpaces, (flags & SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES) != 0); + case CompilerOptionName::Optimization: + return CompilerOptionValue::fromEnum(OptimizationLevel::Default); + default: return CompilerOptionValue(); } +} - void CompilerOptionSet::addTargetFlags(SlangTargetFlags flags) - { - if ((flags & SLANG_TARGET_FLAG_DUMP_IR)) - set(CompilerOptionName::DumpIr, true); +SlangTargetFlags CompilerOptionSet::getTargetFlags() +{ + SlangTargetFlags result = 0; + if (getBoolOption(CompilerOptionName::DumpIr)) + result |= SLANG_TARGET_FLAG_DUMP_IR; + if (getBoolOption(CompilerOptionName::GenerateWholeProgram)) + result |= SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM; + if (!getBoolOption(CompilerOptionName::EmitSpirvViaGLSL)) + result |= SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY; + if (getBoolOption(CompilerOptionName::ParameterBlocksUseRegisterSpaces)) + result |= SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES; + return result; +} + +void CompilerOptionSet::setTargetFlags(SlangTargetFlags flags) +{ + set(CompilerOptionName::DumpIr, (flags & SLANG_TARGET_FLAG_DUMP_IR) != 0); + set(CompilerOptionName::GenerateWholeProgram, + (flags & SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM) != 0); + if ((flags & SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY) != 0) + set(CompilerOptionName::EmitSpirvViaGLSL, false); + else + set(CompilerOptionName::EmitSpirvViaGLSL, true); + set(CompilerOptionName::ParameterBlocksUseRegisterSpaces, + (flags & SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES) != 0); +} - if ((flags & SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM) != 0) - set(CompilerOptionName::GenerateWholeProgram, true); +void CompilerOptionSet::addTargetFlags(SlangTargetFlags flags) +{ + if ((flags & SLANG_TARGET_FLAG_DUMP_IR)) + set(CompilerOptionName::DumpIr, true); - if ((flags & SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY) != 0) - set(CompilerOptionName::EmitSpirvDirectly, true); + if ((flags & SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM) != 0) + set(CompilerOptionName::GenerateWholeProgram, true); - if ((flags & SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES) != 0) - set(CompilerOptionName::ParameterBlocksUseRegisterSpaces, true); - } - MatrixLayoutMode CompilerOptionSet::getMatrixLayoutMode() - { - if (getBoolOption(CompilerOptionName::MatrixLayoutRow)) - return kMatrixLayoutMode_RowMajor; - if (getBoolOption(CompilerOptionName::MatrixLayoutColumn)) - return kMatrixLayoutMode_ColumnMajor; + if ((flags & SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY) != 0) + set(CompilerOptionName::EmitSpirvDirectly, true); - return (MatrixLayoutMode)kMatrixLayoutMode_RowMajor; - } + if ((flags & SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES) != 0) + set(CompilerOptionName::ParameterBlocksUseRegisterSpaces, true); +} +MatrixLayoutMode CompilerOptionSet::getMatrixLayoutMode() +{ + if (getBoolOption(CompilerOptionName::MatrixLayoutRow)) + return kMatrixLayoutMode_RowMajor; + if (getBoolOption(CompilerOptionName::MatrixLayoutColumn)) + return kMatrixLayoutMode_ColumnMajor; - void CompilerOptionSet::setMatrixLayoutMode(MatrixLayoutMode mode) - { - options.remove(CompilerOptionName::MatrixLayoutColumn); - options.remove(CompilerOptionName::MatrixLayoutRow); - if (mode == kMatrixLayoutMode_ColumnMajor) - set(CompilerOptionName::MatrixLayoutColumn, true); - if (mode == kMatrixLayoutMode_RowMajor) - set(CompilerOptionName::MatrixLayoutRow, true); - } + return (MatrixLayoutMode)kMatrixLayoutMode_RowMajor; +} - Profile CompilerOptionSet::getProfile() - { - if (auto profileRaw = getEnumOption<Profile::RawEnum>(CompilerOptionName::Profile)) - return Profile(profileRaw); - return Profile(); - } +void CompilerOptionSet::setMatrixLayoutMode(MatrixLayoutMode mode) +{ + options.remove(CompilerOptionName::MatrixLayoutColumn); + options.remove(CompilerOptionName::MatrixLayoutRow); + if (mode == kMatrixLayoutMode_ColumnMajor) + set(CompilerOptionName::MatrixLayoutColumn, true); + if (mode == kMatrixLayoutMode_RowMajor) + set(CompilerOptionName::MatrixLayoutRow, true); +} - void CompilerOptionSet::setProfile(Profile profile) - { - set(CompilerOptionName::Profile, (int)profile.raw); - } +Profile CompilerOptionSet::getProfile() +{ + if (auto profileRaw = getEnumOption<Profile::RawEnum>(CompilerOptionName::Profile)) + return Profile(profileRaw); + return Profile(); +} - ProfileVersion CompilerOptionSet::getProfileVersion() - { - if (auto profileRaw = getEnumOption<Profile::RawEnum>(CompilerOptionName::Profile)) - return Profile(profileRaw).getVersion(); - return ProfileVersion::Unknown; - } +void CompilerOptionSet::setProfile(Profile profile) +{ + set(CompilerOptionName::Profile, (int)profile.raw); +} - void CompilerOptionSet::setProfileVersion(ProfileVersion version) - { - Profile profile; - if (auto profileRaw = getEnumOption<Profile::RawEnum>(CompilerOptionName::Profile)) - profile = Profile(profileRaw); - profile.setVersion(version); - set(CompilerOptionName::Profile, (int)profile.raw); - } +ProfileVersion CompilerOptionSet::getProfileVersion() +{ + if (auto profileRaw = getEnumOption<Profile::RawEnum>(CompilerOptionName::Profile)) + return Profile(profileRaw).getVersion(); + return ProfileVersion::Unknown; +} - void CompilerOptionSet::addCapabilityAtom(CapabilityName cap) - { - add(CompilerOptionName::Capability, cap); - } +void CompilerOptionSet::setProfileVersion(ProfileVersion version) +{ + Profile profile; + if (auto profileRaw = getEnumOption<Profile::RawEnum>(CompilerOptionName::Profile)) + profile = Profile(profileRaw); + profile.setVersion(version); + set(CompilerOptionName::Profile, (int)profile.raw); +} - List<String> CompilerOptionSet::getDownstreamArgs(String downstreamToolName) +void CompilerOptionSet::addCapabilityAtom(CapabilityName cap) +{ + add(CompilerOptionName::Capability, cap); +} + +List<String> CompilerOptionSet::getDownstreamArgs(String downstreamToolName) +{ + List<String> result; + auto downstreamArgsArray = getArray(CompilerOptionName::DownstreamArgs); + for (auto& argSet : downstreamArgsArray) { - List<String> result; - auto downstreamArgsArray = getArray(CompilerOptionName::DownstreamArgs); - for (auto& argSet : downstreamArgsArray) + if (argSet.stringValue == downstreamToolName) { - if (argSet.stringValue == downstreamToolName) - { - CommandLineArgs args; - args.deserialize(argSet.stringValue2); - for (auto arg : args.m_args) - result.add(arg.value); - break; - } + CommandLineArgs args; + args.deserialize(argSet.stringValue2); + for (auto arg : args.m_args) + result.add(arg.value); + break; } - return result; } + return result; +} - void CompilerOptionSet::serialize(SerializedOptionsData* outData) +void CompilerOptionSet::serialize(SerializedOptionsData* outData) +{ + for (auto& option : options) { - for (auto& option : options) + for (auto val : option.value) { - for (auto val : option.value) - { - slang::CompilerOptionEntry entry = {}; - entry.name = option.key; - entry.value.kind = val.kind; - entry.value.intValue0 = val.intValue; - entry.value.intValue1 = val.intValue2; - outData->stringPool.add(val.stringValue); - entry.value.stringValue0 = val.stringValue.getBuffer(); - outData->stringPool.add(val.stringValue2); - entry.value.stringValue1 = val.stringValue.getBuffer(); - outData->entries.add(entry); - } + slang::CompilerOptionEntry entry = {}; + entry.name = option.key; + entry.value.kind = val.kind; + entry.value.intValue0 = val.intValue; + entry.value.intValue1 = val.intValue2; + outData->stringPool.add(val.stringValue); + entry.value.stringValue0 = val.stringValue.getBuffer(); + outData->stringPool.add(val.stringValue2); + entry.value.stringValue1 = val.stringValue.getBuffer(); + outData->entries.add(entry); } } +} - void applySettingsToDiagnosticSink(DiagnosticSink* targetSink, DiagnosticSink* outputSink, CompilerOptionSet& options) +void applySettingsToDiagnosticSink( + DiagnosticSink* targetSink, + DiagnosticSink* outputSink, + CompilerOptionSet& options) +{ + auto disableArray = options.getArray(CompilerOptionName::DisableWarning); + for (auto& element : disableArray) { - auto disableArray = options.getArray(CompilerOptionName::DisableWarning); - for (auto& element : disableArray) - { - overrideDiagnostic(targetSink, outputSink, element.stringValue.getUnownedSlice(), Severity::Warning, Severity::Disable); - } - disableArray = options.getArray(CompilerOptionName::DisableWarnings); - for (auto& element : disableArray) - { - overrideDiagnostics(targetSink, outputSink, element.stringValue.getUnownedSlice(), Severity::Warning, Severity::Disable); - } - auto enableArray = options.getArray(CompilerOptionName::EnableWarning); - for (auto& element : enableArray) - { - overrideDiagnostics(targetSink, outputSink, element.stringValue.getUnownedSlice(), Severity::Warning, Severity::Warning); - } - auto warningsAsErrorsArray = options.getArray(CompilerOptionName::WarningsAsErrors); - for (auto& element : warningsAsErrorsArray) - { - if (element.stringValue == "all") - targetSink->setFlag(DiagnosticSink::Flag::TreatWarningsAsErrors); - else - overrideDiagnostics(targetSink, outputSink, element.stringValue.getUnownedSlice(), Severity::Warning, Severity::Error); - } + overrideDiagnostic( + targetSink, + outputSink, + element.stringValue.getUnownedSlice(), + Severity::Warning, + Severity::Disable); + } + disableArray = options.getArray(CompilerOptionName::DisableWarnings); + for (auto& element : disableArray) + { + overrideDiagnostics( + targetSink, + outputSink, + element.stringValue.getUnownedSlice(), + Severity::Warning, + Severity::Disable); + } + auto enableArray = options.getArray(CompilerOptionName::EnableWarning); + for (auto& element : enableArray) + { + overrideDiagnostics( + targetSink, + outputSink, + element.stringValue.getUnownedSlice(), + Severity::Warning, + Severity::Warning); + } + auto warningsAsErrorsArray = options.getArray(CompilerOptionName::WarningsAsErrors); + for (auto& element : warningsAsErrorsArray) + { + if (element.stringValue == "all") + targetSink->setFlag(DiagnosticSink::Flag::TreatWarningsAsErrors); + else + overrideDiagnostics( + targetSink, + outputSink, + element.stringValue.getUnownedSlice(), + Severity::Warning, + Severity::Error); } } +} // namespace Slang |
