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 /tools | |
| 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>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/slang-test/parse-diagnostic-util.cpp | 62 | ||||
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 6 |
2 files changed, 34 insertions, 34 deletions
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; |
