Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/swift/Basic/DiagnosticOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ class DiagnosticOptions {
/// allow diagnostics at <unknown>, that is controlled by VerifyIgnoreUnknown.
bool VerifyIgnoreUnrelated = false;

/// Indicates whether to ignore \c diag::in_macro_expansion. This is useful
/// for when they occur in unnamed buffers (such as clang attribute buffers),
/// but VerifyIgnoreUnrelated is too blunt of a tool. Note that notes of this
/// kind are not printed by \c PrintingDiagnosticConsumer.
bool VerifyIgnoreMacroLocationNote = false;

/// Indicates whether diagnostic passes should be skipped.
bool SkipDiagnosticPasses = false;

Expand Down
7 changes: 5 additions & 2 deletions include/swift/Frontend/DiagnosticVerifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,21 @@ class DiagnosticVerifier : public DiagnosticConsumer {
bool AutoApplyFixes;
bool IgnoreUnknown;
bool IgnoreUnrelated;
bool IgnoreMacroLocationNote;
bool UseColor;
ArrayRef<std::string> AdditionalExpectedPrefixes;

public:
explicit DiagnosticVerifier(SourceManager &SM, ArrayRef<unsigned> BufferIDs,
ArrayRef<std::string> AdditionalFilePaths,
bool AutoApplyFixes, bool IgnoreUnknown,
bool IgnoreUnrelated, bool UseColor,
bool IgnoreUnrelated,
bool IgnoreMacroLocationNote, bool UseColor,
ArrayRef<std::string> AdditionalExpectedPrefixes)
: SM(SM), BufferIDs(BufferIDs), AdditionalFilePaths(AdditionalFilePaths),
AutoApplyFixes(AutoApplyFixes), IgnoreUnknown(IgnoreUnknown),
IgnoreUnrelated(IgnoreUnrelated), UseColor(UseColor),
IgnoreUnrelated(IgnoreUnrelated),
IgnoreMacroLocationNote(IgnoreMacroLocationNote), UseColor(UseColor),
AdditionalExpectedPrefixes(AdditionalExpectedPrefixes) {}

virtual void handleDiagnostic(SourceManager &SM,
Expand Down
2 changes: 2 additions & 0 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ def verify_ignore_unknown: Flag<["-"], "verify-ignore-unknown">,
HelpText<"Allow diagnostics for '<unknown>' location in verify mode">;
def verify_ignore_unrelated: Flag<["-"], "verify-ignore-unrelated">,
HelpText<"Allow diagnostics in files outside those with expected diagnostics in verify mode">;
def verify_ignore_macro_note: Flag<["-"], "verify-ignore-macro-note">,
HelpText<"Skip verifying notes about macro location">;
def verify_generic_signatures : Separate<["-"], "verify-generic-signatures">,
MetaVarName<"<module-name>">,
HelpText<"Verify the generic signatures in the given module">;
Expand Down
1 change: 1 addition & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2598,6 +2598,7 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
Opts.VerifyMode = DiagnosticOptions::VerifyAndApplyFixes;
Opts.VerifyIgnoreUnknown |= Args.hasArg(OPT_verify_ignore_unknown);
Opts.VerifyIgnoreUnrelated |= Args.hasArg(OPT_verify_ignore_unrelated);
Opts.VerifyIgnoreMacroLocationNote |= Args.hasArg(OPT_verify_ignore_macro_note);
Opts.SkipDiagnosticPasses |= Args.hasArg(OPT_disable_diagnostic_passes);
Opts.ShowDiagnosticsAfterFatalError |=
Args.hasArg(OPT_show_diagnostics_after_fatal);
Expand Down
2 changes: 2 additions & 0 deletions lib/Frontend/DiagnosticVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,8 @@ void DiagnosticVerifier::handleDiagnostic(SourceManager &SM,
// because there's no reason to verify them.
if (Info.ID == diag::verify_encountered_fatal.ID)
return;
if (IgnoreMacroLocationNote && Info.ID == diag::in_macro_expansion.ID)
return;
SmallVector<CapturedFixItInfo, 2> fixIts;
for (const auto &fixIt : Info.FixIts) {
fixIts.emplace_back(SM, fixIt);
Expand Down
3 changes: 2 additions & 1 deletion lib/Frontend/Frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ bool CompilerInstance::setupDiagnosticVerifierIfNeeded() {
SourceMgr, InputSourceCodeBufferIDs, diagOpts.AdditionalVerifierFiles,
diagOpts.VerifyMode == DiagnosticOptions::VerifyAndApplyFixes,
diagOpts.VerifyIgnoreUnknown, diagOpts.VerifyIgnoreUnrelated,
diagOpts.UseColor, diagOpts.AdditionalDiagnosticVerifierPrefixes);
diagOpts.VerifyIgnoreMacroLocationNote, diagOpts.UseColor,
diagOpts.AdditionalDiagnosticVerifierPrefixes);

addDiagnosticConsumer(DiagVerifier.get());
}
Expand Down