[PATCH] D116395: [Clang] Emit warning for -x option without effects

Hans Wennborg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 27 07:52:13 PST 2022


hans added inline comments.


================
Comment at: clang/lib/Driver/Driver.cpp:2416
   }
+  if (Inputs.size() == InputsBeforeOptX && InputTypeArg != nullptr)
+    Diag(diag::warn_drv_ignored_option_x) << InputTypeArg->getValue(0);
----------------
Could we end up here in clang-cl mode with InputTypeArg pointing to a '/TC' or '/TP' option? (Set near the top of the function.) In that case, emitting a diagnostic that talks about -x would be misleading.

What if you initialized InputsBeforeOptX to a sentinel value instead (e.g. SIZE_MAX)? Could the if statement then be simplified to just

```
if (Inputs.size() == InputsBeforeX)
```

?


================
Comment at: clang/test/Driver/redundant-args.c:2
+// RUN: %clang -target x86_64-apple-darwin10 -Werror -x c -x c -fsyntax-only %s
+// RUN: %clang -target x86_64-apple-darwin10 %s -### -x c 2>&1 | FileCheck %s
+
----------------
These two lines seem to test pretty different things (and I find the first test a bit confusing). Maybe there's a better test to add the new warning to, or it could go in its own file?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116395/new/

https://reviews.llvm.org/D116395



More information about the cfe-commits mailing list