diff options
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-downstream-compiler.cpp | 50 | ||||
| -rw-r--r-- | source/core/slang-downstream-compiler.h | 34 | ||||
| -rw-r--r-- | source/core/slang-gcc-compiler-util.cpp | 28 | ||||
| -rw-r--r-- | source/core/slang-nvrtc-compiler.cpp | 8 | ||||
| -rw-r--r-- | source/core/slang-visual-studio-compiler-util.cpp | 16 |
5 files changed, 68 insertions, 68 deletions
diff --git a/source/core/slang-downstream-compiler.cpp b/source/core/slang-downstream-compiler.cpp index 8a795363d..b9b5a059d 100644 --- a/source/core/slang-downstream-compiler.cpp +++ b/source/core/slang-downstream-compiler.cpp @@ -63,14 +63,14 @@ void DownstreamCompiler::Desc::appendAsText(StringBuilder& out) const /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DownstreamDiagnostic !!!!!!!!!!!!!!!!!!!!!!!!*/ -/* static */UnownedStringSlice DownstreamDiagnostic::getTypeText(Type type) +/* static */UnownedStringSlice DownstreamDiagnostic::getSeverityText(Severity severity) { - switch (type) + switch (severity) { - default: return UnownedStringSlice::fromLiteral("Unknown"); - case Type::Info: return UnownedStringSlice::fromLiteral("Info"); - case Type::Warning: return UnownedStringSlice::fromLiteral("Warning"); - case Type::Error: return UnownedStringSlice::fromLiteral("Error"); + default: return UnownedStringSlice::fromLiteral("Unknown"); + case Severity::Info: return UnownedStringSlice::fromLiteral("Info"); + case Severity::Warning: return UnownedStringSlice::fromLiteral("Warning"); + case Severity::Error: return UnownedStringSlice::fromLiteral("Error"); } } @@ -98,59 +98,59 @@ void DownstreamCompiler::Desc::appendAsText(StringBuilder& out) const /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DownstreamDiagnostics !!!!!!!!!!!!!!!!!!!!!!*/ -Index DownstreamDiagnostics::getCountByType(Diagnostic::Type type) const +Index DownstreamDiagnostics::getCountBySeverity(Diagnostic::Severity severity) const { Index count = 0; for (const auto& msg : diagnostics) { - count += Index(msg.type == type); + count += Index(msg.severity == severity); } return count; } -Int DownstreamDiagnostics::countByStage(Diagnostic::Stage stage, Index counts[Int(Diagnostic::Type::CountOf)]) const +Int DownstreamDiagnostics::countByStage(Diagnostic::Stage stage, Index counts[Int(Diagnostic::Severity::CountOf)]) const { Int count = 0; - ::memset(counts, 0, sizeof(Index) * Int(Diagnostic::Type::CountOf)); + ::memset(counts, 0, sizeof(Index) * Int(Diagnostic::Severity::CountOf)); for (const auto& diagnostic : diagnostics) { if (diagnostic.stage == stage) { count++; - counts[Index(diagnostic.type)]++; + counts[Index(diagnostic.severity)]++; } } return count++; } -static void _appendCounts(const Index counts[Int(DownstreamDiagnostic::Type::CountOf)], StringBuilder& out) +static void _appendCounts(const Index counts[Int(DownstreamDiagnostic::Severity::CountOf)], StringBuilder& out) { - typedef DownstreamDiagnostic::Type Type; + typedef DownstreamDiagnostic::Severity Severity; - for (Index i = 0; i < Int(Type::CountOf); i++) + for (Index i = 0; i < Int(Severity::CountOf); i++) { if (counts[i] > 0) { - out << DownstreamDiagnostic::getTypeText(Type(i)) << "(" << counts[i] << ") "; + out << DownstreamDiagnostic::getSeverityText(Severity(i)) << "(" << counts[i] << ") "; } } } -static void _appendSimplified(const Index counts[Int(DownstreamDiagnostic::Type::CountOf)], StringBuilder& out) +static void _appendSimplified(const Index counts[Int(DownstreamDiagnostic::Severity::CountOf)], StringBuilder& out) { - typedef DownstreamDiagnostic::Type Type; - for (Index i = 0; i < Int(Type::CountOf); i++) + typedef DownstreamDiagnostic::Severity Severity; + for (Index i = 0; i < Int(Severity::CountOf); i++) { if (counts[i] > 0) { - out << DownstreamDiagnostic::getTypeText(Type(i)) << " "; + out << DownstreamDiagnostic::getSeverityText(Severity(i)) << " "; } } } void DownstreamDiagnostics::appendSummary(StringBuilder& out) const { - Index counts[Int(Diagnostic::Type::CountOf)]; + Index counts[Int(Diagnostic::Severity::CountOf)]; if (countByStage(Diagnostic::Stage::Compile, counts) > 0) { out << "Compile: "; @@ -167,7 +167,7 @@ void DownstreamDiagnostics::appendSummary(StringBuilder& out) const void DownstreamDiagnostics::appendSimplifiedSummary(StringBuilder& out) const { - Index counts[Int(Diagnostic::Type::CountOf)]; + Index counts[Int(Diagnostic::Severity::CountOf)]; if (countByStage(Diagnostic::Stage::Compile, counts) > 0) { out << "Compile: "; @@ -182,12 +182,12 @@ void DownstreamDiagnostics::appendSimplifiedSummary(StringBuilder& out) const } } -void DownstreamDiagnostics::removeByType(Diagnostic::Type type) +void DownstreamDiagnostics::removeBySeverity(Diagnostic::Severity severity) { Index count = diagnostics.getCount(); for (Index i = 0; i < count; ++i) { - if (diagnostics[i].type == type) + if (diagnostics[i].severity == severity) { diagnostics.removeAt(i); i--; @@ -435,7 +435,7 @@ const DownstreamCompiler::Desc& DownstreamCompilerUtil::getCompiledWithDesc() Int bestIndex = -1; - const SlangPassThrough type = desc.type; + const SlangPassThrough compilerType = desc.type; Int maxVersionValue = 0; Int minVersionDiff = 0x7fffffff; @@ -454,7 +454,7 @@ const DownstreamCompiler::Desc& DownstreamCompilerUtil::getCompiledWithDesc() DownstreamCompiler* compiler = compilers[i]; auto compilerDesc = compiler->getDesc(); - if (type == compilerDesc.type) + if (compilerType == compilerDesc.type) { const Int versionValue = compilerDesc.getVersionValue(); switch (matchType) diff --git a/source/core/slang-downstream-compiler.h b/source/core/slang-downstream-compiler.h index 7c9831dac..9c3b9055f 100644 --- a/source/core/slang-downstream-compiler.h +++ b/source/core/slang-downstream-compiler.h @@ -20,7 +20,7 @@ struct DownstreamDiagnostic { typedef DownstreamDiagnostic ThisType; - enum class Type + enum class Severity { Unknown, Info, @@ -36,14 +36,14 @@ struct DownstreamDiagnostic void reset() { - type = Type::Unknown; + severity = Severity::Unknown; stage = Stage::Compile; fileLine = 0; } bool operator==(const ThisType& rhs) const { - return type == rhs.type && + return severity == rhs.severity && stage == rhs.stage && text == rhs.text && code == rhs.code && @@ -52,9 +52,9 @@ struct DownstreamDiagnostic } bool operator!=(const ThisType& rhs) const { return !(*this == rhs); } - static UnownedStringSlice getTypeText(Type type); + static UnownedStringSlice getSeverityText(Severity severity); - Type type; ///< The type of error + Severity severity; ///< The severity of error Stage stage; ///< The stage the error came from String text; ///< The text of the error String code; ///< The compiler specific error code @@ -66,24 +66,24 @@ struct DownstreamDiagnostics { typedef DownstreamDiagnostic Diagnostic; - /// Reset to an initial empty state + /// Reset to an initial empty state void reset() { diagnostics.clear(); rawDiagnostics = String(); result = SLANG_OK; } - /// Get the number of diagnostics by type - Index getCountByType(Diagnostic::Type type) const; - /// True if there are any diagnostics of the type - bool has(Diagnostic::Type type) const { return getCountByType(type) > 0; } + /// Get the number of diagnostics by severity + Index getCountBySeverity(Diagnostic::Severity severity) const; + /// True if there are any diagnostics of severity + bool has(Diagnostic::Severity severity) const { return getCountBySeverity(severity) > 0; } - /// Stores in outCounts, the amount of diagnostics for the stage of each type - Int countByStage(Diagnostic::Stage stage, Index outCounts[Int(Diagnostic::Type::CountOf)]) const; + /// Stores in outCounts, the amount of diagnostics for the stage of each severity + Int countByStage(Diagnostic::Stage stage, Index outCounts[Int(Diagnostic::Severity::CountOf)]) const; - /// Append a summary to out + /// Append a summary to out void appendSummary(StringBuilder& out) const; - /// Appends a summary that just identifies if there is an error of a type (not a count) + /// Appends a summary that just identifies if there is an error of a type (not a count) void appendSimplifiedSummary(StringBuilder& out) const; - /// Remove all diagnostics of the type - void removeByType(Diagnostic::Type type); + /// Remove all diagnostics of the type + void removeBySeverity(Diagnostic::Severity severity); String rawDiagnostics; @@ -182,7 +182,7 @@ public: /// Ctor explicit Desc(SlangPassThrough inType = SLANG_PASS_THROUGH_NONE, Int inMajorVersion = 0, Int inMinorVersion = 0):type(inType), majorVersion(inMajorVersion), minorVersion(inMinorVersion) {} - SlangPassThrough type; ///< The type of the compiler + SlangPassThrough type; ///< The type of the compiler Int majorVersion; ///< Major version (interpretation is type specific) Int minorVersion; ///< Minor version }; diff --git a/source/core/slang-gcc-compiler-util.cpp b/source/core/slang-gcc-compiler-util.cpp index cea9930b5..56955f1da 100644 --- a/source/core/slang-gcc-compiler-util.cpp +++ b/source/core/slang-gcc-compiler-util.cpp @@ -92,21 +92,21 @@ SlangResult GCCDownstreamCompilerUtil::calcVersion(const String& exeName, Downst return SLANG_FAIL; } -static SlangResult _parseErrorType(const UnownedStringSlice& in, DownstreamDiagnostic::Type& outType) +static SlangResult _parseSeverity(const UnownedStringSlice& in, DownstreamDiagnostic::Severity& outSeverity) { - typedef DownstreamDiagnostic::Type Type; + typedef DownstreamDiagnostic::Severity Severity; if (in == "error" || in == "fatal error") { - outType = Type::Error; + outSeverity = Severity::Error; } else if (in == "warning") { - outType = Type::Warning; + outSeverity = Severity::Warning; } else if (in == "info" || in == "note") { - outType = Type::Info; + outSeverity = Severity::Info; } else { @@ -130,7 +130,7 @@ enum class LineParseResult static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParseResult& outLineParseResult, DownstreamDiagnostic& outDiagnostic) { typedef DownstreamDiagnostic Diagnostic; - typedef Diagnostic::Type Type; + typedef Diagnostic::Severity Severity; // Set to default case outLineParseResult = LineParseResult::Ignore; @@ -197,13 +197,13 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse { // We'll ignore for now outDiagnostic.stage = Diagnostic::Stage::Link; - outDiagnostic.type = Type::Info; + outDiagnostic.severity = Severity::Info; outDiagnostic.text = split[1].trim(); outLineParseResult = LineParseResult::Start; return SLANG_OK; } - if (SLANG_SUCCEEDED(_parseErrorType(split0, outDiagnostic.type))) + if (SLANG_SUCCEEDED(_parseSeverity(split0, outDiagnostic.severity))) { // Command line errors can be just contain 'error:' etc. Can be seen on apple/clang outDiagnostic.stage = Diagnostic::Stage::Compile; @@ -226,7 +226,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse split0.startsWith(UnownedStringSlice::fromLiteral("Clang")) ) { // Extract the type - SLANG_RETURN_ON_FAIL(_parseErrorType(split[1].trim(), outDiagnostic.type)); + SLANG_RETURN_ON_FAIL(_parseSeverity(split[1].trim(), outDiagnostic.severity)); if (text.startsWith("linker command failed")) { @@ -241,7 +241,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse { // This is a little weak... but looks like it's a link error outDiagnostic.filePath = split[0]; - outDiagnostic.type = Type::Error; + outDiagnostic.severity = Severity::Error; outDiagnostic.stage = Diagnostic::Stage::Link; outDiagnostic.text = text; outLineParseResult = LineParseResult::Single; @@ -250,7 +250,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse else if (text.startsWith("ld returned")) { outDiagnostic.stage = DownstreamDiagnostic::Stage::Link; - SLANG_RETURN_ON_FAIL(_parseErrorType(split[1].trim(), outDiagnostic.type)); + SLANG_RETURN_ON_FAIL(_parseSeverity(split[1].trim(), outDiagnostic.severity)); outDiagnostic.text = line; outLineParseResult = LineParseResult::Single; return SLANG_OK; @@ -277,7 +277,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse { outDiagnostic.filePath = split[1]; outDiagnostic.fileLine = 0; - outDiagnostic.type = Diagnostic::Type::Error; + outDiagnostic.severity = Diagnostic::Severity::Error; outDiagnostic.stage = Diagnostic::Stage::Link; outDiagnostic.text = split[3]; @@ -288,7 +288,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse else if (split.getCount() >= 5) { // Probably a regular error line - SLANG_RETURN_ON_FAIL(_parseErrorType(split[3].trim(), outDiagnostic.type)); + SLANG_RETURN_ON_FAIL(_parseSeverity(split[3].trim(), outDiagnostic.severity)); outDiagnostic.filePath = split[0]; SLANG_RETURN_ON_FAIL(StringUtil::parseInt(split[1], outDiagnostic.fileLine)); @@ -361,7 +361,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse } } - if (outOutput.has(Diagnostic::Type::Error) || exeRes.resultCode != 0) + if (outOutput.has(Diagnostic::Severity::Error) || exeRes.resultCode != 0) { outOutput.result = SLANG_FAIL; } diff --git a/source/core/slang-nvrtc-compiler.cpp b/source/core/slang-nvrtc-compiler.cpp index 78afc618f..eb117379f 100644 --- a/source/core/slang-nvrtc-compiler.cpp +++ b/source/core/slang-nvrtc-compiler.cpp @@ -190,7 +190,7 @@ static bool _hasDriveLetter(const UnownedStringSlice& line) static SlangResult _parseNVRTCLine(const UnownedStringSlice& line, DownstreamDiagnostic& outDiagnostic) { typedef DownstreamDiagnostic Diagnostic; - typedef Diagnostic::Type Type; + typedef Diagnostic::Severity Severity; outDiagnostic.stage = Diagnostic::Stage::Compile; @@ -215,11 +215,11 @@ static SlangResult _parseNVRTCLine(const UnownedStringSlice& line, DownstreamDia if (split1 == "error") { - outDiagnostic.type = Type::Error; + outDiagnostic.severity = Severity::Error; } else if (split1 == "warning") { - outDiagnostic.type = Type::Warning; + outDiagnostic.severity = Severity::Warning; } outDiagnostic.text = split[2].trim(); @@ -461,7 +461,7 @@ SlangResult NVRTCDownstreamCompiler::compile(const CompileOptions& options, RefP } // if it has a compilation error.. set on output - if (diagnostics.has(DownstreamDiagnostic::Type::Error)) + if (diagnostics.has(DownstreamDiagnostic::Severity::Error)) { diagnostics.result = SLANG_FAIL; } diff --git a/source/core/slang-visual-studio-compiler-util.cpp b/source/core/slang-visual-studio-compiler-util.cpp index af05c9c95..a3578483f 100644 --- a/source/core/slang-visual-studio-compiler-util.cpp +++ b/source/core/slang-visual-studio-compiler-util.cpp @@ -258,21 +258,21 @@ namespace Slang return SLANG_OK; } -static SlangResult _parseErrorType(const UnownedStringSlice& in, DownstreamDiagnostics::Diagnostic::Type& outType) +static SlangResult _parseSeverity(const UnownedStringSlice& in, DownstreamDiagnostics::Diagnostic::Severity& outSeverity) { - typedef DownstreamDiagnostics::Diagnostic::Type Type; + typedef DownstreamDiagnostics::Diagnostic::Severity Type; if (in == "error" || in == "fatal error") { - outType = Type::Error; + outSeverity = Type::Error; } else if (in == "warning") { - outType = Type::Warning; + outSeverity = Type::Warning; } else if (in == "info") { - outType = Type::Info; + outSeverity = Type::Info; } else { @@ -289,7 +289,7 @@ static SlangResult _parseVisualStudioLine(const UnownedStringSlice& line, Downst if (line.startsWith(linkPrefix)) { outDiagnostic.stage = Diagnostic::Stage::Link; - outDiagnostic.type = Diagnostic::Type::Info; + outDiagnostic.severity = Diagnostic::Severity::Info; outDiagnostic.text = UnownedStringSlice(line.begin() + linkPrefix.getLength(), line.end()); @@ -394,7 +394,7 @@ static SlangResult _parseVisualStudioLine(const UnownedStringSlice& line, Downst } // Extract the bit before the code - SLANG_RETURN_ON_FAIL(_parseErrorType(UnownedStringSlice(errorSection.begin(), errorSection.begin() + errorCodeIndex).trim(), outDiagnostic.type)); + SLANG_RETURN_ON_FAIL(_parseSeverity(UnownedStringSlice(errorSection.begin(), errorSection.begin() + errorCodeIndex).trim(), outDiagnostic.severity)); // Link codes start with LNK prefix postError = UnownedStringSlice(postPath.begin() + errorColonIndex + 1, end); @@ -426,7 +426,7 @@ static SlangResult _parseVisualStudioLine(const UnownedStringSlice& line, Downst } // if it has a compilation error.. set on output - if (outDiagnostics.has(Diagnostic::Type::Error)) + if (outDiagnostics.has(Diagnostic::Severity::Error)) { outDiagnostics.result = SLANG_FAIL; } |
