https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/225640
>From c8faa26aeb1bf04edc0244d70c4f1246bb9a285b Mon Sep 17 00:00:00 2001 From: Michael Kruse <[email protected]> Date: Wed, 23 Sep 2026 10:07:12 +0200 Subject: [PATCH 1/3] Fix condition inversion --- clang/lib/Driver/Driver.cpp | 4 ++-- clang/test/Driver/aix-ld.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 7649941a68b1cc..f523967a422acc 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3526,12 +3526,12 @@ void Driver::handleArguments(Compilation &C, DerivedArgList &Args, Args.getLastArg(options::OPT_M, options::OPT_MM)) && getPreprocessedType(InputType) == types::TY_INVALID) Diag(clang::diag::warn_drv_preprocessed_input_file_unused) - << InputArg->getAsString(Args) << !!FinalPhaseArg + << InputArg->getAsString(Args) << !FinalPhaseArg << (FinalPhaseArg ? FinalPhaseArg->getOption().getName() : ""); else Diag(clang::diag::warn_drv_input_file_unused) << InputArg->getAsString(Args) << getPhaseName(InitialPhase) - << !!FinalPhaseArg + << !FinalPhaseArg << (FinalPhaseArg ? FinalPhaseArg->getOption().getName() : ""); continue; } diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c index bedd224eeca9ce..8b3caeb81224ca 100644 --- a/clang/test/Driver/aix-ld.c +++ b/clang/test/Driver/aix-ld.c @@ -1171,4 +1171,4 @@ // RUN: -K \ // RUN: -c \ // RUN: | FileCheck --check-prefixes=CHECK-K-UNUSED %s -// CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused [-Wunused-command-line-argument] +// CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused when 'c' is present [-Wunused-command-line-argument] >From 82715b345b470ff9674e1210375bbbdbefa61314 Mon Sep 17 00:00:00 2001 From: Michael Kruse <[email protected]> Date: Wed, 23 Sep 2026 10:27:07 +0200 Subject: [PATCH 2/3] AI-generated test case --- .../Inputs/preprocessed-input-file-unused.i | 1 + .../test/Driver/preprocessed-input-file-unused.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 clang/test/Driver/Inputs/preprocessed-input-file-unused.i create mode 100644 clang/test/Driver/preprocessed-input-file-unused.c diff --git a/clang/test/Driver/Inputs/preprocessed-input-file-unused.i b/clang/test/Driver/Inputs/preprocessed-input-file-unused.i new file mode 100644 index 00000000000000..c2102144fb141f --- /dev/null +++ b/clang/test/Driver/Inputs/preprocessed-input-file-unused.i @@ -0,0 +1 @@ +int unused; diff --git a/clang/test/Driver/preprocessed-input-file-unused.c b/clang/test/Driver/preprocessed-input-file-unused.c new file mode 100644 index 00000000000000..5e09edc536fb21 --- /dev/null +++ b/clang/test/Driver/preprocessed-input-file-unused.c @@ -0,0 +1,15 @@ +// Regression test for a condition inversion bug that caused +// warn_drv_preprocessed_input_file_unused to never mention which option +// determined the final compilation phase. + +// RUN: %clang -E %S/Inputs/preprocessed-input-file-unused.i -o /dev/null 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-E %s +// CHECK-E: warning: {{.*}}preprocessed-input-file-unused.i: previously preprocessed input unused when 'E' is present [-Wunused-command-line-argument] + +// RUN: %clang -M %S/Inputs/preprocessed-input-file-unused.i -o /dev/null 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-M %s +// CHECK-M: warning: {{.*}}preprocessed-input-file-unused.i: previously preprocessed input unused when 'M' is present [-Wunused-command-line-argument] + +// RUN: %clang -MM %S/Inputs/preprocessed-input-file-unused.i -o /dev/null 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MM %s +// CHECK-MM: warning: {{.*}}preprocessed-input-file-unused.i: previously preprocessed input unused when 'MM' is present [-Wunused-command-line-argument] >From 79d45a50b75ff20d5dbebbcce52c77638435dd1c Mon Sep 17 00:00:00 2001 From: Michael Kruse <[email protected]> Date: Wed, 23 Sep 2026 12:06:08 +0200 Subject: [PATCH 3/3] Print spelling (including dash) --- clang/lib/Driver/Driver.cpp | 4 ++-- clang/test/Driver/aix-ld.c | 2 +- clang/test/Driver/preprocessed-input-file-unused.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index f523967a422acc..65bb9680de4a9d 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3527,12 +3527,12 @@ void Driver::handleArguments(Compilation &C, DerivedArgList &Args, getPreprocessedType(InputType) == types::TY_INVALID) Diag(clang::diag::warn_drv_preprocessed_input_file_unused) << InputArg->getAsString(Args) << !FinalPhaseArg - << (FinalPhaseArg ? FinalPhaseArg->getOption().getName() : ""); + << (FinalPhaseArg ? FinalPhaseArg->getSpelling() : ""); else Diag(clang::diag::warn_drv_input_file_unused) << InputArg->getAsString(Args) << getPhaseName(InitialPhase) << !FinalPhaseArg - << (FinalPhaseArg ? FinalPhaseArg->getOption().getName() : ""); + << (FinalPhaseArg ? FinalPhaseArg->getSpelling() : ""); continue; } diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c index 8b3caeb81224ca..641908afc8d986 100644 --- a/clang/test/Driver/aix-ld.c +++ b/clang/test/Driver/aix-ld.c @@ -1171,4 +1171,4 @@ // RUN: -K \ // RUN: -c \ // RUN: | FileCheck --check-prefixes=CHECK-K-UNUSED %s -// CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused when 'c' is present [-Wunused-command-line-argument] +// CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused when '-c' is present [-Wunused-command-line-argument] diff --git a/clang/test/Driver/preprocessed-input-file-unused.c b/clang/test/Driver/preprocessed-input-file-unused.c index 5e09edc536fb21..78fd92f1502ae5 100644 --- a/clang/test/Driver/preprocessed-input-file-unused.c +++ b/clang/test/Driver/preprocessed-input-file-unused.c @@ -4,12 +4,12 @@ // RUN: %clang -E %S/Inputs/preprocessed-input-file-unused.i -o /dev/null 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-E %s -// CHECK-E: warning: {{.*}}preprocessed-input-file-unused.i: previously preprocessed input unused when 'E' is present [-Wunused-command-line-argument] +// CHECK-E: warning: {{.*}}preprocessed-input-file-unused.i: previously preprocessed input unused when '-E' is present [-Wunused-command-line-argument] // RUN: %clang -M %S/Inputs/preprocessed-input-file-unused.i -o /dev/null 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-M %s -// CHECK-M: warning: {{.*}}preprocessed-input-file-unused.i: previously preprocessed input unused when 'M' is present [-Wunused-command-line-argument] +// CHECK-M: warning: {{.*}}preprocessed-input-file-unused.i: previously preprocessed input unused when '-M' is present [-Wunused-command-line-argument] // RUN: %clang -MM %S/Inputs/preprocessed-input-file-unused.i -o /dev/null 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-MM %s -// CHECK-MM: warning: {{.*}}preprocessed-input-file-unused.i: previously preprocessed input unused when 'MM' is present [-Wunused-command-line-argument] +// CHECK-MM: warning: {{.*}}preprocessed-input-file-unused.i: previously preprocessed input unused when '-MM' is present [-Wunused-command-line-argument] _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
