[PATCH] D142757: [clang][driver] Emit an error for `/clang:-x`
Mariya Podchishchaeva via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 30 08:47:46 PST 2023
Fznamznon updated this revision to Diff 493326.
Fznamznon added a comment.
Add a release note.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142757/new/
https://reviews.llvm.org/D142757
Files:
clang/docs/ReleaseNotes.rst
clang/lib/Driver/Driver.cpp
clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl_by_mod_name.json
clang/test/Driver/x-args.c
Index: clang/test/Driver/x-args.c
===================================================================
--- clang/test/Driver/x-args.c
+++ clang/test/Driver/x-args.c
@@ -5,3 +5,8 @@
// RUN: %clang -fsyntax-only -xc %s -xc++ -fsyntax-only 2>&1 | FileCheck %s
// RUN: %clang -fsyntax-only %s -xc %s -xc++ -fsyntax-only 2>&1 | FileCheck %s
// CHECK: '-x c++' after last input file has no effect
+
+// RUN: not %clang_cl /WX /clang:-xc /clang:-E /clang:-dM %s 2>&1 | FileCheck -check-prefix=CL %s
+// RUN: not %clang_cl /WX /clang:-E /clang:-dM %s /clang:-xc 2>&1 | FileCheck -check-prefix=CL %s
+// CL-NOT: '-x c' after last input file has no effect
+// CL: error: unsupported option '-x c'; did you mean '/TC' or '/TP'?
Index: clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl_by_mod_name.json
===================================================================
--- clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl_by_mod_name.json
+++ clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl_by_mod_name.json
@@ -1,12 +1,12 @@
[
{
"directory": "DIR",
- "command": "clang-cl /E /IInputs /D INCLUDE_HEADER2 /clang:-MD /clang:-MF /clang:DIR/modules_cdb2_clangcl.d /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps /clang:-x /clang:c++ --",
+ "command": "clang-cl /E /IInputs /D INCLUDE_HEADER2 /clang:-MD /clang:-MF /clang:DIR/modules_cdb2_clangcl.d /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps /TP --",
"file": ""
},
{
"directory": "DIR",
- "command": "clang-cl /E /IInputs /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps /clang:-x /clang:c++ --",
+ "command": "clang-cl /E /IInputs /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps /TP --",
"file": ""
},
]
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2572,11 +2572,18 @@
}
// Warn -x after last input file has no effect
- {
+ if (!IsCLMode()) {
Arg *LastXArg = Args.getLastArgNoClaim(options::OPT_x);
Arg *LastInputArg = Args.getLastArgNoClaim(options::OPT_INPUT);
- if (LastXArg && LastInputArg && LastInputArg->getIndex() < LastXArg->getIndex())
+ if (LastXArg && LastInputArg &&
+ LastInputArg->getIndex() < LastXArg->getIndex())
Diag(clang::diag::warn_drv_unused_x) << LastXArg->getValue();
+ } else {
+ // In CL mode suggest /TC or /TP since -x doesn't make sense if passed via
+ // /clang:.
+ if (auto *A = Args.getLastArg(options::OPT_x))
+ Diag(diag::err_drv_unsupported_opt_with_suggestion)
+ << A->getAsString(Args) << "/TC' or '/TP";
}
for (Arg *A : Args) {
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -57,6 +57,10 @@
- Fix crash on invalid code when looking up a destructor in a templated class
inside a namespace. This fixes
`Issue 59446 <https://github.com/llvm/llvm-project/issues/59446>`_.
+- Fix confusing warning message when `/clang:-x` is passed in clang-cl driver
+ mode and emit an error which suggests using `/TC` or `/TP` clang-cl options
+ instead. This fixes
+ `Issue 59307 <https://github.com/llvm/llvm-project/issues/59307>`_.
Improvements to Clang's diagnostics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142757.493326.patch
Type: text/x-patch
Size: 3732 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230130/f38c53eb/attachment-0001.bin>
More information about the cfe-commits
mailing list