Skip to content

Conversation

@llvmbot
Copy link
Member

@llvmbot llvmbot commented Feb 6, 2025

Backport df22bbe

Requested by: @kadircet

@llvmbot llvmbot added this to the LLVM 20.X Release milestone Feb 6, 2025
@llvmbot
Copy link
Member Author

llvmbot commented Feb 6, 2025

@jyknight What do you think about merging this PR to the release branch?

@llvmbot llvmbot requested a review from jyknight February 6, 2025 09:09
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Feb 6, 2025
@llvmbot
Copy link
Member Author

llvmbot commented Feb 6, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: None (llvmbot)

Changes

Backport df22bbe

Requested by: @kadircet


Full diff: https://github.com/llvm/llvm-project/pull/126027.diff

2 Files Affected:

  • (added) clang/test/Driver/warning-suppression-mappings-not-parsed.cpp (+5)
  • (modified) clang/tools/driver/driver.cpp (+4)
diff --git a/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp b/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp
new file mode 100644
index 000000000000000..8f52fb1c6cc7d6c
--- /dev/null
+++ b/clang/test/Driver/warning-suppression-mappings-not-parsed.cpp
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: echo '[unknown-warning]' > %t/foo.txt
+// RUN: %clang -fdriver-only --warning-suppression-mappings=%t/foo.txt %s | FileCheck -allow-empty %s
+// CHECK-NOT: unknown warning option 'unknown-warning'
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 74923247b7ee169..00c00cea16f470f 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -318,6 +318,10 @@ int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) {
 
   IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts =
       CreateAndPopulateDiagOpts(Args);
+  // Driver's diagnostics don't use suppression mappings, so don't bother
+  // parsing them. CC1 still receives full args, so this doesn't impact other
+  // actions.
+  DiagOpts->DiagnosticSuppressionMappingsFile.clear();
 
   TextDiagnosticPrinter *DiagClient
     = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);

)

This gets rid of some extra IO from driver startup, and possiblity of
emitting warnings twice.

(cherry picked from commit df22bbe)
@tstellar tstellar merged commit 4cde428 into llvm:release/20.x Feb 7, 2025
8 of 11 checks passed
@github-actions
Copy link

github-actions bot commented Feb 7, 2025

@kadircet (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category

Projects

Development

Successfully merging this pull request may close these issues.

4 participants