From 2fd768f3aa10d7051f4ca156c60e7d762cb59c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Wed, 14 Aug 2024 19:40:44 +0200 Subject: [PATCH] Add "has issued errors" method on a compilation (#1091) `Compilation::getSemanticDiagnostics()` caches its result and is meant to be called on a finished compilation for which no more diagnostics will be issued. For use cases where user code using slang as a library wants to issue its own diagnostics, but doesn't want to deal with an AST which failed elaboration, provide a `hasIssuedErrors()` method to find out early if the elaboration failed. --- include/slang/ast/Compilation.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/slang/ast/Compilation.h b/include/slang/ast/Compilation.h index c5d0a2f54..9afb5ed7f 100644 --- a/include/slang/ast/Compilation.h +++ b/include/slang/ast/Compilation.h @@ -708,6 +708,9 @@ class SLANG_EXPORT Compilation : public BumpAllocator { /// Creates an empty ImplicitTypeSyntax object. const syntax::ImplicitTypeSyntax& createEmptyTypeSyntax(SourceLocation loc); + /// Queries if any errors have been issued on any scope within this compilation. + bool hasIssuedErrors() const { return numErrors > 0; }; + /// @{ private: