summaryrefslogtreecommitdiff
path: root/source/core/slang-downstream-compiler.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-02-04 14:23:32 -0500
committerGitHub <noreply@github.com>2021-02-04 14:23:32 -0500
commit7f266f1ea7a51213069282296a905650fd405c3f (patch)
treef275da33fc05101c5f9c08076cb038968ab556de /source/core/slang-downstream-compiler.cpp
parentef283b80b886c7a0fb34c20e07a43ccca3237ed8 (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 'source/core/slang-downstream-compiler.cpp')
-rw-r--r--source/core/slang-downstream-compiler.cpp50
1 files changed, 25 insertions, 25 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)