[clang] 6461e53 - [Driver] Don't claim -c/-S

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 23 21:57:26 PDT 2024


Author: Fangrui Song
Date: 2024-07-23T21:57:21-07:00
New Revision: 6461e537815f7fa68cef06842505353cf5600e9c

URL: https://github.com/llvm/llvm-project/commit/6461e537815f7fa68cef06842505353cf5600e9c
DIFF: https://github.com/llvm/llvm-project/commit/6461e537815f7fa68cef06842505353cf5600e9c.diff

LOG: [Driver] Don't claim -c/-S

Remove the TODO I left in commit
a07b135ce0c0111bd83450b5dc29ef0381cdbc39.

We will now warn about `-c/-S` with `-fsyntax-only`. This relands #98607
with a specific target triple.

Added: 
    clang/test/Driver/warn-fsyntax-only.c

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 7cc9771b1b9e5..9a374c03caee5 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -794,10 +794,6 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
       Args.hasArg(options::OPT_coverage))
     FProfileDir = Args.getLastArg(options::OPT_fprofile_dir);
 
-  // TODO: Don't claim -c/-S to warn about -fsyntax-only -c/-S, -E -c/-S,
-  // like we warn about -fsyntax-only -E.
-  (void)(Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S));
-
   // Put the .gcno and .gcda files (if needed) next to the primary output file,
   // or fall back to a file in the current directory for `clang -c --coverage
   // d/a.c` in the absence of -o.

diff  --git a/clang/test/Driver/warn-fsyntax-only.c b/clang/test/Driver/warn-fsyntax-only.c
new file mode 100644
index 0000000000000..d13bab41c047a
--- /dev/null
+++ b/clang/test/Driver/warn-fsyntax-only.c
@@ -0,0 +1,7 @@
+// RUN: %clang --target=x86_64 -fsyntax-only -E %s 2>&1 | FileCheck %s --check-prefix=CHECK-PP
+// RUN: %clang --target=x86_64 -fsyntax-only -S %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASM
+// RUN: %clang --target=x86_64 -fsyntax-only -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-OBJ
+
+// CHECK-PP:  warning: argument unused during compilation: '-fsyntax-only' [-Wunused-command-line-argument]
+// CHECK-ASM: warning: argument unused during compilation: '-S' [-Wunused-command-line-argument]
+// CHECK-OBJ: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument]


        


More information about the cfe-commits mailing list