summaryrefslogtreecommitdiffstats
path: root/source/compiler-core
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-08-15 20:30:01 -0700
committerGitHub <noreply@github.com>2023-08-16 11:30:01 +0800
commit0c366bc0a4332ee14d08f2555396a18cb64229fa (patch)
tree72885dc8154a9aeed857708a2be2587eabc0c985 /source/compiler-core
parent45d9961a6a86d184248ef84f6a07125b0c224f97 (diff)
Fix a bug that warning 39001 can't be fully disabled. (#3112)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/compiler-core')
-rw-r--r--source/compiler-core/slang-diagnostic-sink.cpp9
-rw-r--r--source/compiler-core/slang-diagnostic-sink.h18
2 files changed, 15 insertions, 12 deletions
diff --git a/source/compiler-core/slang-diagnostic-sink.cpp b/source/compiler-core/slang-diagnostic-sink.cpp
index a8d981545..2d3f34c5c 100644
--- a/source/compiler-core/slang-diagnostic-sink.cpp
+++ b/source/compiler-core/slang-diagnostic-sink.cpp
@@ -550,7 +550,7 @@ SlangResult DiagnosticSink::getBlobIfNeeded(ISlangBlob** outBlob)
return SLANG_OK;
}
-void DiagnosticSink::diagnoseImpl(DiagnosticInfo const& info, const UnownedStringSlice& formattedMessage)
+bool DiagnosticSink::diagnoseImpl(DiagnosticInfo const& info, const UnownedStringSlice& formattedMessage)
{
if (info.severity >= Severity::Error)
{
@@ -576,6 +576,7 @@ void DiagnosticSink::diagnoseImpl(DiagnosticInfo const& info, const UnownedStrin
// TODO: figure out a better policy for aborting compilation
SLANG_ABORT_COMPILATION("");
}
+ return true;
}
Severity DiagnosticSink::getEffectiveMessageSeverity(DiagnosticInfo const& info)
@@ -598,13 +599,13 @@ Severity DiagnosticSink::getEffectiveMessageSeverity(DiagnosticInfo const& info)
return effectiveSeverity;
}
-void DiagnosticSink::diagnoseImpl(SourceLoc const& pos, DiagnosticInfo info, int argCount, DiagnosticArg const* args)
+bool DiagnosticSink::diagnoseImpl(SourceLoc const& pos, DiagnosticInfo info, int argCount, DiagnosticArg const* args)
{
// Override the severity in the 'info' structure to pass it further into formatDiagnostics
info.severity = getEffectiveMessageSeverity(info);
if (info.severity == Severity::Disable)
- return;
+ return false;
StringBuilder messageBuilder;
{
@@ -621,7 +622,7 @@ void DiagnosticSink::diagnoseImpl(SourceLoc const& pos, DiagnosticInfo info, int
formatDiagnostic(this, diagnostic, messageBuilder);
}
- diagnoseImpl(info, messageBuilder.getUnownedSlice());
+ return diagnoseImpl(info, messageBuilder.getUnownedSlice());
}
void DiagnosticSink::diagnoseRaw(
diff --git a/source/compiler-core/slang-diagnostic-sink.h b/source/compiler-core/slang-diagnostic-sink.h
index fc5e31b47..1969e66b6 100644
--- a/source/compiler-core/slang-diagnostic-sink.h
+++ b/source/compiler-core/slang-diagnostic-sink.h
@@ -163,30 +163,31 @@ public:
SLANG_FORCE_INLINE int getErrorCount() { return m_errorCount; }
template<typename P, typename... Args>
- void diagnose(P const& pos, DiagnosticInfo const& info, Args const&... args )
+ bool diagnose(P const& pos, DiagnosticInfo const& info, Args const&... args )
{
DiagnosticArg as[] = { DiagnosticArg(args)... };
- diagnoseImpl(getDiagnosticPos(pos), info, sizeof...(args), as);
+ return diagnoseImpl(getDiagnosticPos(pos), info, sizeof...(args), as);
}
template<typename P>
- void diagnose(P const& pos, DiagnosticInfo const& info)
+ bool diagnose(P const& pos, DiagnosticInfo const& info)
{
// MSVC gets upset with the zero sized array above, so overload that case here
- diagnoseImpl(getDiagnosticPos(pos), info, 0, nullptr);
+ return diagnoseImpl(getDiagnosticPos(pos), info, 0, nullptr);
}
// Useful for notes on existing diagnostics, where it would be redundant to display the same line again.
// (Ideally we would print the error/warning and notes in one call...)
template<typename P, typename... Args>
- void diagnoseWithoutSourceView(P const& pos, DiagnosticInfo const& info, Args const&... args )
+ bool diagnoseWithoutSourceView(P const& pos, DiagnosticInfo const& info, Args const&... args )
{
const auto fs = this->getFlags();
this->resetFlag(Flag::SourceLocationLine);
- diagnose(pos, info, args...);
+ auto result = diagnose(pos, info, args...);
this->setFlags(fs);
+ return result;
}
// Add a diagnostic with raw text
@@ -259,8 +260,9 @@ public:
ISlangWriter* writer = nullptr;
protected:
- void diagnoseImpl(SourceLoc const& pos, DiagnosticInfo info, int argCount, DiagnosticArg const* args);
- void diagnoseImpl(DiagnosticInfo const& info, const UnownedStringSlice& formattedMessage);
+ // Returns true if a diagnostic is actually written.
+ bool diagnoseImpl(SourceLoc const& pos, DiagnosticInfo info, int argCount, DiagnosticArg const* args);
+ bool diagnoseImpl(DiagnosticInfo const& info, const UnownedStringSlice& formattedMessage);
Severity getEffectiveMessageSeverity(DiagnosticInfo const& info);