llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Michael Kruse (Meinersbur) <details> <summary>Changes</summary> The diagnostic string for warn_drv_preprocessed_input_file_unused and warn_drv_input_file_unused require %1/%2 to be true iff the causing option is *un*available. Swap the option. Also use `getSpelling()` to include the dash in the printed input. warn_drv_input_file_unused was already part of #<!-- -->218802 which was reverted. preprocessed-input-file-unused.c test case generated by AI --- Full diff: https://github.com/llvm/llvm-project/pull/225640.diff 4 Files Affected: - (modified) clang/lib/Driver/Driver.cpp (+4-4) - (added) clang/test/Driver/Inputs/preprocessed-input-file-unused.i (+1) - (modified) clang/test/Driver/aix-ld.c (+1-1) - (added) clang/test/Driver/preprocessed-input-file-unused.c (+15) ``````````diff diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 7649941a68b1cc..65bb9680de4a9d 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3526,13 +3526,13 @@ 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 - << (FinalPhaseArg ? FinalPhaseArg->getOption().getName() : ""); + << InputArg->getAsString(Args) << !FinalPhaseArg + << (FinalPhaseArg ? FinalPhaseArg->getSpelling() : ""); else Diag(clang::diag::warn_drv_input_file_unused) << InputArg->getAsString(Args) << getPhaseName(InitialPhase) - << !!FinalPhaseArg - << (FinalPhaseArg ? FinalPhaseArg->getOption().getName() : ""); + << !FinalPhaseArg + << (FinalPhaseArg ? FinalPhaseArg->getSpelling() : ""); continue; } 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/aix-ld.c b/clang/test/Driver/aix-ld.c index bedd224eeca9ce..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 [-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 new file mode 100644 index 00000000000000..78fd92f1502ae5 --- /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] `````````` </details> https://github.com/llvm/llvm-project/pull/225640 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
