Skip to content

Commit

Permalink
Add "has issued errors" method on a compilation (#1091)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
povik committed Aug 14, 2024
1 parent fd44678 commit 2fd768f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/slang/ast/Compilation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 2fd768f

Please sign in to comment.