Skip to content

Commit d69d981

Browse files
authored
[Tooling] -fsyntax-only adjuster: remove -c and -S
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 a07b135). Now the workaround have been removed (#98607). (clangDriver reports a -Wunused-command-line-argument diagnostic for each unclaimed option.) Fix #100909 Pull Request: #101103
1 parent c95abe9 commit d69d981

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

clang/lib/Tooling/ArgumentsAdjusters.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ ArgumentsAdjuster getClangSyntaxOnlyAdjuster() {
4949
}))
5050
continue;
5151

52-
if (!Arg.starts_with("-fcolor-diagnostics") &&
52+
if (Arg != "-c" && Arg != "-S" &&
53+
!Arg.starts_with("-fcolor-diagnostics") &&
5354
!Arg.starts_with("-fdiagnostics-color"))
5455
AdjustedArgs.push_back(Args[i]);
55-
// If we strip a color option, make sure we strip any preceeding `-Xclang`
56+
// If we strip an option, make sure we strip any preceeding `-Xclang`
5657
// option as well.
5758
// FIXME: This should be added to most argument adjusters!
5859
else if (!AdjustedArgs.empty() && AdjustedArgs.back() == "-Xclang")

clang/test/Tooling/clang-check-extra-arg.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: clang-check "%s" -extra-arg=-Wunimplemented-warning -extra-arg-before=-Wunimplemented-warning-before -- -c 2>&1 | FileCheck %s
1+
/// Check we do not report "argument unused during compilation: '-c'"
2+
// RUN: clang-check "%s" -extra-arg=-Wunimplemented-warning -extra-arg-before=-Wunimplemented-warning-before -- -c 2>&1 | FileCheck %s --implicit-check-not='argument unused'
3+
// 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'
24

35
// CHECK: unknown warning option '-Wunimplemented-warning-before'
46
// CHECK: unknown warning option '-Wunimplemented-warning'

0 commit comments

Comments
 (0)