[frontend] Add an option called -verify-additional-prefix to add additional check prefixes to the DiagnosticVerifier.

This enables one to use varying prefixes when checking diagnostics with the
DiagnosticVerifier. So for instance, I can make a test work both with and
without send-non-sendable enabled by adding additional prefixes. As an example:

```swift
// RUN: %target-swift-frontend ... -verify-additional-prefix no-sns-
// RUN: %target-swift-frontend ... -verify-additional-prefix sns-

let x = ... // expected-error {{This is always checked no matter what prefixes I added}}
let y = ... // expected-no-sns-error {{This is only checked if send non sendable is disabled}}
let z = ... // expected-sns-error {{This is only checked if send non sendable is enabled}}
let w = ... // expected-no-sns-error {{This is checked for a specific error when sns is disabled...}}
// expected-sns-error @-1 {{and for a different error when sns is enabled}}
```

rdar://114643840
This commit is contained in:
Michael Gottesman
2023-08-29 11:59:22 -07:00
parent 52c732fa92
commit fa1558a175
9 changed files with 199 additions and 20 deletions

View File

@@ -1795,6 +1795,8 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
for (Arg *A : Args.filtered(OPT_verify_additional_file))
Opts.AdditionalVerifierFiles.push_back(A->getValue());
for (Arg *A : Args.filtered(OPT_verify_additional_prefix))
Opts.AdditionalDiagnosticVerifierPrefixes.push_back(A->getValue());
Opts.UseColor |=
Args.hasFlag(OPT_color_diagnostics,