From d9fd0ff3f0fc7b775de1e05570f01798fbc8baa3 Mon Sep 17 00:00:00 2001 From: Alexey Panteleev Date: Tue, 17 May 2022 15:05:44 -0700 Subject: Configuration for warnings (#2241) * Added support for disabling specific warnings or turning them into errors. * Added API entry points for adding diagnostic severity overrides and manipulating some sink flags. --- slang.h | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) (limited to 'slang.h') diff --git a/slang.h b/slang.h index dd078bd05..a2623bdd3 100644 --- a/slang.h +++ b/slang.h @@ -521,11 +521,19 @@ extern "C" typedef int SlangSeverity; enum { - SLANG_SEVERITY_NOTE = 0, /**< An informative message. */ - SLANG_SEVERITY_WARNING, /**< A warning, which indicates a possible proble. */ - SLANG_SEVERITY_ERROR, /**< An error, indicating that compilation failed. */ - SLANG_SEVERITY_FATAL, /**< An unrecoverable error, which forced compilation to abort. */ - SLANG_SEVERITY_INTERNAL, /**< An internal error, indicating a logic error in the compiler. */ + SLANG_SEVERITY_DISABLED = 0, /**< A message that is disabled, filtered out. */ + SLANG_SEVERITY_NOTE, /**< An informative message. */ + SLANG_SEVERITY_WARNING, /**< A warning, which indicates a possible proble. */ + SLANG_SEVERITY_ERROR, /**< An error, indicating that compilation failed. */ + SLANG_SEVERITY_FATAL, /**< An unrecoverable error, which forced compilation to abort. */ + SLANG_SEVERITY_INTERNAL, /**< An internal error, indicating a logic error in the compiler. */ + }; + + typedef int SlangDiagnosticFlags; + enum + { + SLANG_DIAGNOSTIC_FLAG_VERBOSE_PATHS = 0x01, + SLANG_DIAGNOSTIC_FLAG_TREAT_WARNINGS_AS_ERRORS = 0x02 }; typedef int SlangBindableResourceType; @@ -1709,7 +1717,19 @@ extern "C" size_t reproDataSize, ISlangFileSystem* replaceFileSystem, ISlangFileSystemExt** outFileSystem); - + + /*! @see slang::ICompileRequest::overrideDiagnosticSeverity */ + SLANG_API void spOverrideDiagnosticSeverity( + SlangCompileRequest* request, + SlangInt messageID, + SlangSeverity overrideSeverity); + + /*! @see slang::ICompileRequest::getDiagnosticFlags */ + SLANG_API SlangDiagnosticFlags spGetDiagnosticFlags(SlangCompileRequest* request); + + /*! @see slang::ICompileRequest::setDiagnosticFlags */ + SLANG_API void spSetDiagnosticFlags(SlangCompileRequest* request, SlangDiagnosticFlags flags); + /* Forward declarations of types used in the reflection interface; */ @@ -3883,6 +3903,24 @@ namespace slang If false, the resulting code will std430 for storage buffers. */ virtual SLANG_NO_THROW void SLANG_MCALL setTargetForceGLSLScalarBufferLayout(int targetIndex, bool forceScalarLayout) = 0; + + /** Overrides the severity of a specific diagnostic message. + + @param messageID Numeric identifier of the message to override, + as defined in the 1st parameter of the DIAGNOSTIC macro. + @param overrideSeverity New severity of the message. If the message is originally Error or Fatal, + the new severity cannot be lower than that. + */ + virtual SLANG_NO_THROW void SLANG_MCALL overrideDiagnosticSeverity( + SlangInt messageID, + SlangSeverity overrideSeverity) = 0; + + /** Returns the currently active flags of the request's diagnostic sink. */ + virtual SLANG_NO_THROW SlangDiagnosticFlags SLANG_MCALL getDiagnosticFlags() = 0; + + /** Sets the flags of the request's diagnostic sink. + The previously specified flags are discarded. */ + virtual SLANG_NO_THROW void SLANG_MCALL setDiagnosticFlags(SlangDiagnosticFlags flags) = 0; }; #define SLANG_UUID_ICompileRequest ICompileRequest::getTypeGuid() -- cgit v1.2.3