diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2021-02-04 14:23:32 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-04 14:23:32 -0500 |
| commit | 7f266f1ea7a51213069282296a905650fd405c3f (patch) | |
| tree | f275da33fc05101c5f9c08076cb038968ab556de | |
| parent | ef283b80b886c7a0fb34c20e07a43ccca3237ed8 (diff) | |
DownstreamDiagnostic::Type -> Severity (#1687)
* #include an absolute path didn't work - because paths were taken to always be relative.
* WIP diagnostics for line number output.
* Small param naming change
* Use x macro for pass through compile human name lookup/getting.
* WIP on parsing downstream compiler output.
* Split out parsing into ParseDiagnosticUtil.
Added test result of single line.
* Dump out the std output on fail to parse diagnostics.
* Change test type for syntax-error-intrinsic.slang be TEST not TEST_DIAGNOSTIC
* Use Index for StringUtil.
* WIP: First pass support for parsing Slang diagnostics.
* WIP Testing comparing with ParseDiagnosticUtil with previous ad-hoc mechanism.
* Use the new parsing mechanism for diagnostic comparisons.
* Improvements to diagnostics parsing.
Better error handling, and fallback handling.
Added ability to parse downstream compilers without a prefix.
Added ability to parse Slang with a prefix.
* DownstreamDiagnostic::Type -> Severity and related fixes.
* Small fixes around moving from DownstreamDiagnostic::Type -> Severity
* Small comment fixes.
Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
| -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 | ||||
| -rwxr-xr-x | source/slang/slang-compiler.cpp | 12 | ||||
| -rw-r--r-- | tools/slang-test/parse-diagnostic-util.cpp | 62 | ||||
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 6 |
8 files changed, 108 insertions, 108 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; } diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 1e9357f4f..993a4966e 100755 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -1541,22 +1541,22 @@ SlangResult dissassembleDXILUsingDXC( // Severity severity = Severity::Error; - switch (diagnostic.type) + switch (diagnostic.severity) { - case Diagnostic::Type::Unknown: - case Diagnostic::Type::Error: + case Diagnostic::Severity::Unknown: + case Diagnostic::Severity::Error: { severity = Severity::Error; builder << "error"; break; } - case Diagnostic::Type::Warning: + case Diagnostic::Severity::Warning: { severity = Severity::Warning; builder << "warning"; break; } - case Diagnostic::Type::Info: + case Diagnostic::Severity::Info: { severity = Severity::Note; builder << "info"; @@ -1572,7 +1572,7 @@ SlangResult dissassembleDXILUsingDXC( } // If any errors are emitted, then we are done - if (diagnostics.has(DownstreamDiagnostic::Type::Error)) + if (diagnostics.has(DownstreamDiagnostic::Severity::Error)) { return SLANG_FAIL; } diff --git a/tools/slang-test/parse-diagnostic-util.cpp b/tools/slang-test/parse-diagnostic-util.cpp index 6d5a64cce..41dae07f7 100644 --- a/tools/slang-test/parse-diagnostic-util.cpp +++ b/tools/slang-test/parse-diagnostic-util.cpp @@ -61,15 +61,15 @@ using namespace Slang; SLANG_RETURN_ON_FAIL(splitPathLocation(lineSlices[0], outDiagnostic)); { - const UnownedStringSlice errorSlice = lineSlices[1].trim(); + const UnownedStringSlice severityAndCodeSlice = lineSlices[1].trim(); + const UnownedStringSlice severitySlice = StringUtil::getAtInSplit(severityAndCodeSlice, ' ', 0); - const UnownedStringSlice errorTypeName = StringUtil::getAtInSplit(errorSlice, ' ', 0); - outDiagnostic.code = StringUtil::getAtInSplit(errorSlice, ' ', 1); + outDiagnostic.code = StringUtil::getAtInSplit(severityAndCodeSlice, ' ', 1); - outDiagnostic.type = DownstreamDiagnostic::Type::Error; - if (errorTypeName == "warning") + outDiagnostic.severity = DownstreamDiagnostic::Severity::Error; + if (severitySlice == "warning") { - outDiagnostic.type = DownstreamDiagnostic::Type::Warning; + outDiagnostic.severity = DownstreamDiagnostic::Severity::Warning; } } @@ -92,12 +92,12 @@ using namespace Slang; Int lineCol; SLANG_RETURN_ON_FAIL(StringUtil::parseInt(lineSlices[2], lineCol)); - UnownedStringSlice typeSlice = lineSlices[3].trim(); + UnownedStringSlice severitySlice = lineSlices[3].trim(); - outDiagnostic.type = DownstreamDiagnostic::Type::Error; - if (typeSlice == UnownedStringSlice::fromLiteral("warning")) + outDiagnostic.severity = DownstreamDiagnostic::Severity::Error; + if (severitySlice == UnownedStringSlice::fromLiteral("warning")) { - outDiagnostic.type = DownstreamDiagnostic::Type::Warning; + outDiagnostic.severity = DownstreamDiagnostic::Severity::Warning; } // The rest of the line @@ -114,12 +114,12 @@ using namespace Slang; return SLANG_FAIL; } { - const UnownedStringSlice typeSlice = lineSlices[0].trim(); + const UnownedStringSlice severitySlice = lineSlices[0].trim(); - outDiagnostic.type = DownstreamDiagnostic::Type::Error; - if (typeSlice.caseInsensitiveEquals(UnownedStringSlice::fromLiteral("warning"))) + outDiagnostic.severity = DownstreamDiagnostic::Severity::Error; + if (severitySlice.caseInsensitiveEquals(UnownedStringSlice::fromLiteral("warning"))) { - outDiagnostic.type = DownstreamDiagnostic::Type::Warning; + outDiagnostic.severity = DownstreamDiagnostic::Severity::Warning; } } @@ -139,20 +139,20 @@ using namespace Slang; } { - const UnownedStringSlice errorSlice = lineSlices[1].trim(); + const UnownedStringSlice severityAndCodeSlice = lineSlices[1].trim(); // Get the code - outDiagnostic.code = StringUtil::getAtInSplit(errorSlice, ' ', 1).trim(); + outDiagnostic.code = StringUtil::getAtInSplit(severityAndCodeSlice, ' ', 1).trim(); - const UnownedStringSlice typeSlice = StringUtil::getAtInSplit(errorSlice, ' ', 0); + const UnownedStringSlice severitySlice = StringUtil::getAtInSplit(severityAndCodeSlice, ' ', 0); - outDiagnostic.type = DownstreamDiagnostic::Type::Error; - if (typeSlice == UnownedStringSlice::fromLiteral("warning")) + outDiagnostic.severity = DownstreamDiagnostic::Severity::Error; + if (severitySlice == UnownedStringSlice::fromLiteral("warning")) { - outDiagnostic.type = DownstreamDiagnostic::Type::Warning; + outDiagnostic.severity = DownstreamDiagnostic::Severity::Warning; } - else if (typeSlice == UnownedStringSlice::fromLiteral("info")) + else if (severitySlice == UnownedStringSlice::fromLiteral("info")) { - outDiagnostic.type = DownstreamDiagnostic::Type::Info; + outDiagnostic.severity = DownstreamDiagnostic::Severity::Info; } } @@ -163,7 +163,7 @@ using namespace Slang; return SLANG_OK; } -static SlangResult _getSlangDiagnosticType(const UnownedStringSlice& inText, DownstreamDiagnostic::Type& outType, Int& outCode) +static SlangResult _getSlangDiagnosticSeverity(const UnownedStringSlice& inText, DownstreamDiagnostic::Severity& outSeverity, Int& outCode) { UnownedStringSlice text(inText.trim()); @@ -192,9 +192,9 @@ static SlangResult _getSlangDiagnosticType(const UnownedStringSlice& inText, Dow switch (index) { case -1: return SLANG_FAIL; - case 0: outType = DownstreamDiagnostic::Type::Info; break; - case 1: outType = DownstreamDiagnostic::Type::Warning; break; - default: outType = DownstreamDiagnostic::Type::Error; break; + case 0: outSeverity = DownstreamDiagnostic::Severity::Info; break; + case 1: outSeverity = DownstreamDiagnostic::Severity::Warning; break; + default: outSeverity = DownstreamDiagnostic::Severity::Error; break; } outCode = 0; @@ -221,9 +221,9 @@ static bool _isSlangDiagnostic(const UnownedStringSlice& line) // Extract the type/code slice UnownedStringSlice typeSlice = StringUtil::getAtInSplit(line, ':', typeIndex); - DownstreamDiagnostic::Type type; + DownstreamDiagnostic::Severity type; Int code; - return SLANG_SUCCEEDED(_getSlangDiagnosticType(typeSlice, type, code)); + return SLANG_SUCCEEDED(_getSlangDiagnosticSeverity(typeSlice, type, code)); } /* static */SlangResult ParseDiagnosticUtil::parseSlangLine(const UnownedStringSlice& line, List<UnownedStringSlice>& lineSlices, DownstreamDiagnostic& outDiagnostic) @@ -240,7 +240,7 @@ static bool _isSlangDiagnostic(const UnownedStringSlice& line) SLANG_RETURN_ON_FAIL(splitPathLocation(lineSlices[0], outDiagnostic)); Int code; - SLANG_RETURN_ON_FAIL(_getSlangDiagnosticType(lineSlices[1], outDiagnostic.type, code)); + SLANG_RETURN_ON_FAIL(_getSlangDiagnosticSeverity(lineSlices[1], outDiagnostic.severity, code)); if (code != 0) { @@ -310,7 +310,7 @@ static void _addDiagnosticNote(const UnownedStringSlice& in, List<DownstreamDiag // Make it a note on the output DownstreamDiagnostic diagnostic; diagnostic.reset(); - diagnostic.type = DownstreamDiagnostic::Type::Info; + diagnostic.severity = DownstreamDiagnostic::Severity::Info; diagnostic.text = in; outDiagnostics.add(diagnostic); } @@ -444,7 +444,7 @@ static SlangResult _findDownstreamCompiler(const UnownedStringSlice& slice, Slan } DownstreamDiagnostic diagnostic; - diagnostic.type = DownstreamDiagnostic::Type::Error; + diagnostic.severity = DownstreamDiagnostic::Severity::Error; diagnostic.stage = DownstreamDiagnostic::Stage::Compile; diagnostic.fileLine = 0; diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index e7e882ad4..861e42971 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -1409,9 +1409,9 @@ static String _calcSummary(const DownstreamDiagnostics& inOutput) { DownstreamDiagnostics output(inOutput); - // We only want to analyse errors for now - output.removeByType(DownstreamDiagnostics::Diagnostic::Type::Info); - output.removeByType(DownstreamDiagnostics::Diagnostic::Type::Warning); + // We only want to analyze errors for now + output.removeBySeverity(DownstreamDiagnostic::Severity::Info); + output.removeBySeverity(DownstreamDiagnostic::Severity::Warning); StringBuilder builder; |
