diff options
author | Mariya Podchishchaeva <mariya.podchishchaeva@intel.com> | 2023-02-02 11:41:11 -0500 |
---|---|---|
committer | Mariya Podchishchaeva <mariya.podchishchaeva@intel.com> | 2023-02-02 11:48:33 -0500 |
commit | fe082124faa8455cc9a68be5fdf10fc46a4d066c (patch) | |
tree | 76c7906c0e57e7dd5a02850a3c7a7ddaca2c1748 /clang/lib/Driver/Driver.cpp | |
parent | 9b06f756b2438684e0a3357d3f6fd12b50a2092b (diff) | |
download | llvm-fe082124faa8455cc9a68be5fdf10fc46a4d066c.zip llvm-fe082124faa8455cc9a68be5fdf10fc46a4d066c.tar.gz llvm-fe082124faa8455cc9a68be5fdf10fc46a4d066c.tar.bz2 |
[clang][driver] Emit an error for `/clang:-x`
`/clang:-x` emits an error instead of a warning. And if the error is suppressed,
`/clang:-x` takes no effect.
Considering that `/clang:` is a recent addition in 2018-11 and there are MSVC
style alternatives, therefore `/clang:-x` doesn't seem useful and we just reject
it since properly supporting it would add lots of complexity.
Fixes #59307
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D142757
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 98c0edc..6c0ff3d 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2566,17 +2566,21 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args, } if (ShowNote) Diag(clang::diag::note_drv_t_option_is_global); - - // No driver mode exposes -x and /TC or /TP; we don't support mixing them. - assert(!Args.hasArg(options::OPT_x) && "-x and /TC or /TP is not allowed"); } // 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) { |