[all-commits] [llvm/llvm-project] 1e31cd: [llvm] Add include guards to LLVMOption TableGen
Brian Gesiak via All-commits
all-commits at lists.llvm.org
Tue Jun 27 17:21:47 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1e31cdfbb152f00c30b5eacc8a50104c00753f2d
https://github.com/llvm/llvm-project/commit/1e31cdfbb152f00c30b5eacc8a50104c00753f2d
Author: Brian Gesiak <brian at modocache.io>
Date: 2023-06-27 (Tue, 27 Jun 2023)
Changed paths:
M llvm/include/llvm/Option/OptParser.td
Log Message:
-----------
[llvm] Add include guards to LLVMOption TableGen
Add include guards that allow multiple includes of `OptParser.td`. This
is helpful when defining multiple sets of options in multiple files.
For example, a user could define a `HelpOptions.td` file that defines
only `-h` and `--help`:
```
// HelpOptions.td
include "llvm/Option/OptParser.td"
def HelpOptionGroup : OptionGroup<"Help Options">;
def help : Flag<["--", "-"], "help">, Group<HelpOptionGroup>,
Flags<[]>;
def : Flag<["-"], "h">, Group<HelpOptionGroup>, Flags<[]>, Alias<help>;
```
This file could then be included into any TableGen file that wishes to
define these options:
```
// MyOptions.td
include "llvm/Option/OptParser.td"
def MyOptionGroup : OptionGroup<"My Options">;
// ...define my options.
// And also define `-h` and `--help`:
include "HelpOptions.td"
```
This currently isn't possible, because this would result in
`OptParser.td` being included twice. Alternatively, the include of
`OptParser.td` in the `HelpOptions.td` example above could be removed,
but then `llvm-tblgen --gen-opt-parser-defs HelpOptions.td` would fail
(because the `OptionGroup` and `Option` records are defined in
`OptParser.td`).
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D153915
More information about the All-commits
mailing list