-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Clang] Silently ignore unknown warnings in --warning-suppression-mappings
#124141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's intentional to emit these warnings so can we keep that but rather make sure we do respect rest of the warning options?
we can do that by moving https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/Warnings.cpp#L76-L84 past processing of other warning flags.
in addition to that, we should propagate
ReportDiags
intoDiagnosticsEngine::setDiagSuppressionMapping
and not emit warnings when it's set to false (to prevent double emitting in driver & cc1).this is more of a FR, but we should also use source-manager and attach source-location to these warnings.
--
I am happy to do these changes myself, as they're more involved then what's in this PR currently. PLMK if you'd prefer that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize it was intentional to emit unknown-warning diagnostics, but I really think we should not. Yes, that could catch a typo in the suppressions file, but you could also typo the filenames in the same way without notice, so I don't find that terribly persuasive as a use-case. Because this is a suppression file, the primary notice that you've made a mistake is that the diagnostic you expected to suppress did not get suppressed.
On the other hand, not emitting unknown-warning diagnostic is particularly useful here, as it allows the suppressions file for a given codebase to be easily used across multiple compilers. It allows users to easily write a file which suppresses some instance of a newly-introduced diagnostic, yet doesn't complain when the compiler doesn't yet support the suppressed-diagnostic. Notably, on the version which doesn't recognize the flag, generally the suppression is not necessary, since it doesn't know how to emit the diagnostic anyways.
And there's not the ability to guard with
#if __has_warning
like you can if adding a suppression via editing the source file.But, yes, if we do continue to emit an unknown-warning diagnostic, it needs to honor -Werror and -Wno-unknown-warning-option.
Why parse the suppression file in the driver? Even if we do check ReportDiags, isn't it just wasted work to read it at all?
I'd be happy to have you do so! (Even if a bit less happy than going with the simpler proposal, here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i still feel a little bit uneasy about leaving the user in the dark, when they're trying to use the suppression mapping and it silently doesn't work (even if it's due to a configuration error). so i'd rather punt on silently ignoring, until concerns like version skew is really biting us in practice.
Most of the projects that maintain their own toolchain already needs to put effort into fiddling with warning flags as they update their toolchain hence I don't think we're creating any new maintenance surface here.
sorry my comment was a little misleading. i agree that we shouldn't try parsing this in driver, there's simply no need. but we should still respect
ReportDiags
in the implementation.thanks! i'll put together a patch soon