[PATCH] D156436: [llvm/OptTable] Print options without documentation

Jan Ole Hüser via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 28 08:54:28 PDT 2023


j0le added inline comments.


================
Comment at: flang/test/Driver/driver-help-hidden.f90:51
+! CHECK-NEXT: -fno-automatic          Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
+! CHECK-NEXT: -fno-backslash
 ! CHECK-NEXT: -fno-color-diagnostics  Disable colors in diagnostics
----------------
awarzynski wrote:
> IMHO, printing (no help text for the `-fno-<option>` variant):
> ```
> -fno-backslash 
> ```
> on top of:
> ```
>  -fbackslash   Specify that backslash in string introduces an escape character
> ```
> is of little value. To me this is noise that we should avoid. If both `-fbackslash ` and `-fno-backslash ` are printed, then both should contain "help" text.
I agree, it is of little value. But the value is, that the user now knows, that she/he/they/... can toggle of the `-fbackslash` option explicitly. Maybe some wrapper around flang (like a build system), that the user has little control of, sets the option `-fbackslash`, then the user can turn it of with `-fno-backslash`.

But if we realy want to hide `-fno-backslash` and other `-fno-<option>` options, but still show options that have no help text (but don't have a related negated option), we can come up with some ideas.

But first let's analyze the implementation: 
If I understand this correctly, the flang options also come from the clang source tree, i.e. from the file "clang/include/clang/Driver/Options.td".

Both `-fbackslash` and `-fno-backslash` are defined with this line:
```
defm backslash : OptInFC1FFlag<"backslash", "Specify that backslash in string introduces an escape character">;
```

That corresponds to the following lines in the generated "Options.inc" file:
```
OPTION(prefix_1, llvm::StringLiteral("fbackslash"), fbackslash, Flag, f_Group, INVALID, nullptr, FC1Option | FlangOption | FlangOnlyOption, 0, "Specify that backslash in string introduces an escape character", nullptr, nullptr)
OPTION(prefix_1, llvm::StringLiteral("fno-backslash"), fno_backslash, Flag, f_Group, INVALID, nullptr, FC1Option | FlangOption | FlangOnlyOption, 0, "", nullptr, nullptr)
```

I don't totally understand how this table generation works. And I don't know how we can tell (programmatically) from this table that `fbackslash` and `fno_backslash` are related. But maybe there is a way, or we have to change the table generation.

Possible solutions:
1. For `OptInFC1FFlag` the "-fno-..." options are marked as hidden.
2. We detect in `OptTable::printHelp` that those options are related and group them together
3. A help text for the "-fno-..." option is generated from help text of "-f..." option. Either in table generation or in C++ code.


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

https://reviews.llvm.org/D156436



More information about the llvm-commits mailing list