[PATCH] D133161: [Clang] Fix the new driver crashing when using '-fsyntax-only'

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 1 16:03:34 PDT 2022


tra added a comment.

OK. I'm going to land it then.



================
Comment at: clang/lib/Driver/Driver.cpp:4396-4398
+  bool SingleDeviceOutput = !llvm::any_of(OffloadActions, [](Action *A) {
+    return A->getType() == types::TY_Nothing;
+  }) && isa<CompileJobAction>(HostAction);
----------------
`any_of(A->getType() == types::TY_Nothing)` looks like a rather indirect way to infer that we have `-fsyntax-only`. Would there be any other legitimate case when we'd have `Ty_Nothing` actions?





================
Comment at: clang/lib/Driver/Driver.cpp:4402
       /*BoundArch=*/nullptr, isa<CompileJobAction>(HostAction) ? DDep : DDeps);
-  return C.MakeAction<OffloadAction>(
-      HDep, isa<CompileJobAction>(HostAction) ? DDep : DDeps);
+  return C.MakeAction<OffloadAction>(HDep, SingleDeviceOutput ? DDep : DDeps);
 }
----------------
Assuming that we're guaranteed that all actions produce no outputs, can we just pass an empty array if `-fsyntax-only` is specified?




================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4503
   for (const InputInfo &I : Inputs) {
-    if (&I == &Input) {
-      // This is the primary input.
+    if (&I == &Input || I.getType() == types::TY_Nothing) {
+      // This is the primary input or contains nothing.
----------------
.. and if we don't propagate no-output actions, there would be no need to filter them here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133161



More information about the cfe-commits mailing list