https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/101103
compile_commands.json entries often have -c. When adding -fsyntax-only, we should remove -c to prevent the following warning: ``` % clang -c -fsyntax-only a.c clang: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument] ``` Previously, -c and -S were inappropriately claimed in `addPGOAndCoverageFlags` (see the workaround added by commit a07b135ce0c0111bd83450b5dc29ef0381cdbc39). Now the workaround have been removed (#98607). (clangDriver reports a -Wunused-command-line-argument diagnostic for each unclaimed option.) Fix #100909 >From 2a0978485260ea2a37d61fe73b8f18cfb4203286 Mon Sep 17 00:00:00 2001 From: Fangrui Song <i...@maskray.me> Date: Mon, 29 Jul 2024 17:01:56 -0700 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5-bogner --- clang/lib/Tooling/ArgumentsAdjusters.cpp | 5 +++-- clang/test/Tooling/clang-check-extra-arg.cpp | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/clang/lib/Tooling/ArgumentsAdjusters.cpp b/clang/lib/Tooling/ArgumentsAdjusters.cpp index df4c74205b087..d01c57ee69c00 100644 --- a/clang/lib/Tooling/ArgumentsAdjusters.cpp +++ b/clang/lib/Tooling/ArgumentsAdjusters.cpp @@ -49,10 +49,11 @@ ArgumentsAdjuster getClangSyntaxOnlyAdjuster() { })) continue; - if (!Arg.starts_with("-fcolor-diagnostics") && + if (Arg != "-c" && Arg != "-S" && + !Arg.starts_with("-fcolor-diagnostics") && !Arg.starts_with("-fdiagnostics-color")) AdjustedArgs.push_back(Args[i]); - // If we strip a color option, make sure we strip any preceeding `-Xclang` + // If we strip an option, make sure we strip any preceeding `-Xclang` // option as well. // FIXME: This should be added to most argument adjusters! else if (!AdjustedArgs.empty() && AdjustedArgs.back() == "-Xclang") diff --git a/clang/test/Tooling/clang-check-extra-arg.cpp b/clang/test/Tooling/clang-check-extra-arg.cpp index df5fb930eedcd..488497edd4e81 100644 --- a/clang/test/Tooling/clang-check-extra-arg.cpp +++ b/clang/test/Tooling/clang-check-extra-arg.cpp @@ -1,4 +1,6 @@ -// RUN: clang-check "%s" -extra-arg=-Wunimplemented-warning -extra-arg-before=-Wunimplemented-warning-before -- -c 2>&1 | FileCheck %s +/// Check we do not report "argument unused during compilation: '-c'" +// RUN: clang-check "%s" -extra-arg=-Wunimplemented-warning -extra-arg-before=-Wunimplemented-warning-before -- -c 2>&1 | FileCheck %s --implicit-check-not='argument unused' +// RUN: clang-check "%s" -extra-arg=-Wunimplemented-warning -extra-arg-before=-Wunimplemented-warning-before -- -S -Xclang -S 2>&1 | FileCheck %s --implicit-check-not='argument unused' // CHECK: unknown warning option '-Wunimplemented-warning-before' // CHECK: unknown warning option '-Wunimplemented-warning' _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits