slang::WaiverRule struct

Represents a single waiver rule that can suppress diagnostics based on file paths, hierarchy paths, diagnostic names, and source content patterns.

Public functions

bool matchesFile(const std::filesystem::path& filePath) const
Check if a file path matches this rule's file pattern (file-scoped rules only).
bool matchesLineContent(std::string_view lineContent) const
Check if source line content matches this rule's line pattern.
bool matchesHier(std::string_view hierPath) const
Check if a hierarchical path matches this rule's hier glob (hier-scoped rules only).

Public variables

bool hierScope
True if this is a hierarchy-scoped rule; false for file-scoped.
std::filesystem::path scopeGlob
The scope glob as written by the user (for display / diagnostics).
std::filesystem::path normalizedPattern
The scope glob normalized once at load time for matching.
std::optional<std::regex> linePattern
Optional source line content pattern (regex).
std::vector<std::string> diagnosticCodes
Optional diagnostic code names (e.g., "unused-variable").
size_t appliedCount
Number of times this rule has suppressed a diagnostic.
bool scopeMatched
Whether the scope glob (file or hier) matched at least once.
bool diagnosticMatched
Whether scope + diagnostic name both matched at least once.
std::filesystem::path sourceFile
The path of the waiver file this rule was loaded from.
uint32_t sourceLine
1-based line in sourceFile where the [[waivers]] entry begins, or 0 if the load source didn't carry position info.
bool diagnosticSeenWithoutSymbol
For hier-scoped rules with a diagnostic filter: set when the named diagnostic was issued but had no symbol attached, so the rule could not match.

Function documentation

bool slang::WaiverRule::matchesLineContent(std::string_view lineContent) const

Check if source line content matches this rule's line pattern.

Caller must ensure linePattern is set before calling.

Variable documentation

std::filesystem::path slang::WaiverRule::normalizedPattern

The scope glob normalized once at load time for matching.

For file rules: '' converted to slang's '...' then lexically_normal'd. For hier rules: '.' replaced with '/' then '' converted to '...'.

std::optional<std::regex> slang::WaiverRule::linePattern

Optional source line content pattern (regex).

Matched with regex_search (substring), not regex_match — anchor with ^ / $ if you need full-line.

std::vector<std::string> slang::WaiverRule::diagnosticCodes

Optional diagnostic code names (e.g., "unused-variable").

Empty means match all diagnostics; one or more entries means match any in the list. Names are validated against DiagnosticEngine::findFromOptionName at load time, so any value present here is guaranteed to correspond to a real diagnostic option.

bool slang::WaiverRule::diagnosticSeenWithoutSymbol

For hier-scoped rules with a diagnostic filter: set when the named diagnostic was issued but had no symbol attached, so the rule could not match.

This typically happens for parse/preprocess/lex diagnostics (no AST symbol exists yet) and for some elaboration-time diagnostics that are reported against a SourceLocation rather than attached to a Symbol. Used to suggest switching to a 'file' scope in the unused- waivers report rather than emitting the generic "no hierarchy paths matched glob" message.