[flang-commits] [PATCH] D106727: [flang] Produce proper "preprocessor output" for -E option

Andrzej Warzynski via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Jul 29 07:02:58 PDT 2021


awarzynski added inline comments.


================
Comment at: clang/include/clang/Driver/Options.td:4540-4541
   HelpText<"Run the InputOuputTest action. Use for development and testing only.">;
+def fdebug_dump_cooked_chars : Flag<["-"], "fdebug-dump-cooked-chars">, Group<Preprocessor_Group>,
+  HelpText<"Dump the cooked character stream in -E mode">;
 def fdebug_unparse_no_sema : Flag<["-"], "fdebug-unparse-no-sema">, Group<Action_Group>,
----------------
In this group, all options have the following flags set: 
```
let Flags = [FC1Option, FlangOnlyOption] in {
```
This means that we only support them in the frontend driver (`FC1Option`). Frontend-only options should be skipped in `clang/lib/Driver/ToolChains/Flang.cpp` (the bridge between the compiler driver and the frontend driver).  This way, `flang-new` will ignore it:
```lang=bash
bin/flang-new  -E -P  -fdebug-dump-cooked-chars  file.f
flang-new: warning: argument unused during compilation: '-fdebug-dump-cooked-chars'
```

Users can still use it with `-Xflang`, e.g. 
```lang=bash
flang-new -E -Xflang -fdebug-dump-cooked-chars file.f
```

This way, we avoid exposing all of the frontend options in the compiler driver mode.


================
Comment at: clang/lib/Driver/ToolChains/Flang.cpp:43
+                   options::OPT_I, options::OPT_cpp, options::OPT_nocpp,
+                   options::OPT_fdebug_dump_cooked_chars});
 }
----------------
You can delete `options::OPT_fdebug_dump_cooked_chars` from here. It won't be supported by the compiler driver, but that's fine. It's mostly for compiler developers,  so it's fine to restrict it to the frontend driver. You can still pass it to `flang-new -fc1` with `-Xflang`. 

As for `-P`, could you add it to https://github.com/llvm/llvm-project/blob/main/flang/test/Driver/frontend-forwarding.f90?


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

https://reviews.llvm.org/D106727



More information about the flang-commits mailing list