-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang] Parse warning-suppression-mapping after setting up diagengine #125714
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
Merged
Conversation
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
@llvm/pr-subscribers-clang Author: kadir çetinkaya (kadircet) ChangesWe can emit diagnostics while parsing warning-suppression-mapping, make Full diff: https://github.com/llvm/llvm-project/pull/125714.diff 2 Files Affected:
diff --git a/clang/lib/Basic/Warnings.cpp b/clang/lib/Basic/Warnings.cpp
index da0304463007b65..5f48e0ec8155434 100644
--- a/clang/lib/Basic/Warnings.cpp
+++ b/clang/lib/Basic/Warnings.cpp
@@ -73,16 +73,6 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
else
Diags.setExtensionHandlingBehavior(diag::Severity::Ignored);
- if (!Opts.DiagnosticSuppressionMappingsFile.empty()) {
- if (auto FileContents =
- VFS.getBufferForFile(Opts.DiagnosticSuppressionMappingsFile)) {
- Diags.setDiagSuppressionMapping(**FileContents);
- } else if (ReportDiags) {
- Diags.Report(diag::err_drv_no_such_file)
- << Opts.DiagnosticSuppressionMappingsFile;
- }
- }
-
SmallVector<diag::kind, 10> _Diags;
const IntrusiveRefCntPtr< DiagnosticIDs > DiagIDs =
Diags.getDiagnosticIDs();
@@ -237,4 +227,17 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
}
}
}
+
+ // Process suppression mappings file after processing other warning flags
+ // (like -Wno-unknown-warning-option) as we can emit extra warnings during
+ // processing.
+ if (!Opts.DiagnosticSuppressionMappingsFile.empty()) {
+ if (auto FileContents =
+ VFS.getBufferForFile(Opts.DiagnosticSuppressionMappingsFile)) {
+ Diags.setDiagSuppressionMapping(**FileContents);
+ } else if (ReportDiags) {
+ Diags.Report(diag::err_drv_no_such_file)
+ << Opts.DiagnosticSuppressionMappingsFile;
+ }
+ }
}
diff --git a/clang/unittests/Basic/DiagnosticTest.cpp b/clang/unittests/Basic/DiagnosticTest.cpp
index b26f72a2fb0ee5a..88fa1800f0ff2a4 100644
--- a/clang/unittests/Basic/DiagnosticTest.cpp
+++ b/clang/unittests/Basic/DiagnosticTest.cpp
@@ -346,4 +346,13 @@ TEST_F(SuppressionMappingTest, IsIgnored) {
EXPECT_FALSE(Diags.isIgnored(diag::warn_unused_function,
SM.getLocForStartOfFile(ClangID)));
}
+
+TEST_F(SuppressionMappingTest, ParsingRespectsOtherWarningOpts) {
+ Diags.getDiagnosticOptions().DiagnosticSuppressionMappingsFile = "foo.txt";
+ FS->addFile("foo.txt", /*ModificationTime=*/{},
+ llvm::MemoryBuffer::getMemBuffer("[non-existing-warning]"));
+ Diags.getDiagnosticOptions().Warnings.push_back("no-unknown-warning-option");
+ clang::ProcessWarningOptions(Diags, Diags.getDiagnosticOptions(), *FS);
+ EXPECT_THAT(diags(), IsEmpty());
+}
} // namespace
|
jyknight
approved these changes
Feb 5, 2025
(Oh, all these suppression mappings fixes will need to be backported to the 20.x branch too.) |
We can emit diagnostics while parsing warning-suppression-mapping, make sure command line flags take affect when emitting those.
84b5e22
to
b210fc4
Compare
/cherry-pick ecb016a |
/pull-request #126030 |
swift-ci
pushed a commit
to swiftlang/llvm-project
that referenced
this pull request
Feb 8, 2025
…llvm#125714) We can emit diagnostics while parsing warning-suppression-mapping, make sure command line flags take affect when emitting those. (cherry picked from commit ecb016a)
Icohedron
pushed a commit
to Icohedron/llvm-project
that referenced
this pull request
Feb 11, 2025
…llvm#125714) We can emit diagnostics while parsing warning-suppression-mapping, make sure command line flags take affect when emitting those.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
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.
We can emit diagnostics while parsing warning-suppression-mapping, make
sure command line flags take affect when emitting those.