================
@@ -2841,6 +2841,30 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, 
ArgList &Args,
     }
 
     Opts.ProgramAction = *ProgramAction;
+
+    // Catch common mistakes when multiple actions are specified for cc1 (e.g.
+    // -S -emit-llvm means -emit-llvm while -emit-llvm -S means -S). However, 
to
+    // support driver `-c -Xclang ACTION` (-cc1 -emit-llvm file -main-file-name
+    // X ACTION), we suppress the error when the two actions are separated by
+    // -main-file-name.
+    //
+    // As an exception, accept composable -ast-dump*.
+    if (!A->getSpelling().starts_with("-ast-dump")) {
----------------
MaskRay wrote:

`-ast-dump -ast-dump-lookups` and `-ast-dump-lookups -ast-dump`  are 
composable. `llvm/utils/update_cc_test_checks.py` appends `-ast-dump=json` when 
the cc1 command line may contain another action option.

Since there are 3+ `-ast-dump*` options that need an exception, I feel that 
`starts_with("-ast-dump"))` is simpler than listing all `OPT_ast_dump*`..

https://github.com/llvm/llvm-project/pull/91140
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to