[clang] [fixit] Properly apply warning options during fixit-recompile (#190280)

Fixes https://github.com/llvm/llvm-project/issues/18707

During fixit recompile, the frontend was not reapplying command-line
diagnostic options, so the second pass could lose -Wno-* suppressions
and other warning configuration.

Added regression test to make sure that diagnostic options are properly
applied in the fixit-recompile path.
This commit is contained in:
Benjamin Luke 2026-04-28 10:38:16 -07:00 committed by GitHub
parent b40c1d511b
commit 9e0057bdc4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View file

@ -149,6 +149,8 @@ bool FixItRecompile::BeginInvocation(CompilerInstance &CI) {
return false;
CI.getDiagnosticClient().clear();
CI.getDiagnostics().Reset();
ProcessWarningOptions(CI.getDiagnostics(), CI.getDiagnosticOpts(),
CI.getVirtualFileSystem());
PreprocessorOptions &PPOpts = CI.getPreprocessorOpts();
PPOpts.RemappedFiles.insert(PPOpts.RemappedFiles.end(),

View file

@ -0,0 +1,15 @@
// RUN: %clang_cc1 -std=c++14 %s -fixit-recompile -fixit-to-temporary -Werror \
// RUN: -Wno-deprecated-register 2>&1 | FileCheck %s
//In c++14 this produces a fixit, which we fix with -fixit-recompile
static_assert(true);
// During the recompile we ensure that the -Wno-deprecated-register option
// is properly applied
void f() {
register int data;
}
// CHECK: error: 'static_assert' with no message is a C++17 extension
// CHECK: note: FIX-IT applied suggested code changes
// CHECK-NOT: 'register' storage class specifier is deprecated and incompatible with C++17