]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/llvm/tools/clang/include/clang/Driver/OptParser.td
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / llvm / tools / clang / include / clang / Driver / OptParser.td
1 //===--- OptParser.td - Common Option Parsing Interfaces ------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  This file defines the common interfaces used by the option parsing TableGen
11 //  backend.
12 //
13 //===----------------------------------------------------------------------===//
14
15 // Define the kinds of options.
16
17 class OptionKind<string name, int predecence = 0, bit sentinel = 0> {
18   string Name = name;
19   // The kind precedence, kinds with lower precedence are matched first.
20   int Precedence = predecence;
21   // Indicate a sentinel option.
22   bit Sentinel = sentinel;
23 }
24
25 // An option group.
26 def KIND_GROUP : OptionKind<"Group">;
27 // The input option kind.
28 def KIND_INPUT : OptionKind<"Input", 1, 1>;
29 // The unknown option kind.
30 def KIND_UNKNOWN : OptionKind<"Unknown", 2, 1>;
31 // A flag with no values.
32 def KIND_FLAG : OptionKind<"Flag">;
33 // An option which prefixes its (single) value.
34 def KIND_JOINED : OptionKind<"Joined", 1>;
35 // An option which is followed by its value.
36 def KIND_SEPARATE : OptionKind<"Separate">;
37 // An option followed by its values, which are separated by commas.
38 def KIND_COMMAJOINED : OptionKind<"CommaJoined">;
39 // An option which is which takes multiple (separate) arguments.
40 def KIND_MULTIARG : OptionKind<"MultiArg">;
41 // An option which is either joined to its (non-empty) value, or followed by its
42 // value.
43 def KIND_JOINED_OR_SEPARATE : OptionKind<"JoinedOrSeparate">;
44 // An option which is both joined to its (first) value, and followed by its
45 // (second) value.
46 def KIND_JOINED_AND_SEPARATE : OptionKind<"JoinedAndSeparate">;
47
48 // Define the option flags.
49
50 class OptionFlag {}
51
52 // DriverOption - The option is a "driver" option, and should not be forwarded
53 // to gcc.
54 def DriverOption : OptionFlag;
55
56 // LinkerInput - The option is a linker input.
57 def LinkerInput : OptionFlag;
58
59 // NoArgumentUnused - Don't report argument unused warnings for this option; this
60 // is useful for options like -static or -dynamic which a user may always end up
61 // passing, even if the platform defaults to (or only supports) that option.
62 def NoArgumentUnused : OptionFlag;
63
64 // RenderAsInput - The option should not render the name when rendered as an
65 // input (i.e., the option is rendered as values).
66 def RenderAsInput : OptionFlag;
67
68 // RenderJoined - The option should be rendered joined, even if separate (only
69 // sensible on single value separate options).
70 def RenderJoined : OptionFlag;
71
72 // RenderSeparate - The option should be rendered separately, even if joined
73 // (only sensible on joined options).
74 def RenderSeparate : OptionFlag;
75
76 // Unsupported - The option is unsupported, and the driver will reject command
77 // lines that use it.
78 def Unsupported : OptionFlag;
79
80 // HelpHidden - The option should not be displayed in --help, even if it has
81 // help text. Clients *can* use this in conjunction with the OptTable::PrintHelp
82 // arguments to implement hidden help groups.
83 def HelpHidden : OptionFlag;
84
85 // NoForward - The option should not be implicitly forwarded to other tools.
86 def NoForward : OptionFlag;
87
88 // CC1Option - This option should be accepted by clang -cc1.
89 def CC1Option : OptionFlag;
90
91 // NoDriverOption - This option should not be accepted by the driver.
92 def NoDriverOption : OptionFlag;
93
94 // Define the option group class.
95
96 class OptionGroup<string name> {
97   string EnumName = ?; // Uses the def name if undefined.
98   string Name = name;
99   string HelpText = ?;
100   OptionGroup Group = ?;
101 }
102
103 // Define the option class.
104
105 class Option<list<string> prefixes, string name, OptionKind kind> {
106   string EnumName = ?; // Uses the def name if undefined.
107   list<string> Prefixes = prefixes;
108   string Name = name;
109   OptionKind Kind = kind;
110   // Used by MultiArg option kind.
111   int NumArgs = 0;
112   string HelpText = ?;
113   string MetaVarName = ?;
114   list<OptionFlag> Flags = [];
115   OptionGroup Group = ?;
116   Option Alias = ?;
117 }
118
119 // Helpers for defining options.
120
121 class Flag<list<string> prefixes, string name>
122   : Option<prefixes, name, KIND_FLAG>;
123 class Joined<list<string> prefixes, string name>
124   : Option<prefixes, name, KIND_JOINED>;
125 class Separate<list<string> prefixes, string name>
126   : Option<prefixes, name, KIND_SEPARATE>;
127 class CommaJoined<list<string> prefixes, string name>
128   : Option<prefixes, name, KIND_COMMAJOINED>;
129 class MultiArg<list<string> prefixes, string name, int numargs>
130   : Option<prefixes, name, KIND_MULTIARG> {
131   int NumArgs = numargs;
132 }
133 class JoinedOrSeparate<list<string> prefixes, string name>
134   : Option<prefixes, name, KIND_JOINED_OR_SEPARATE>;
135 class JoinedAndSeparate<list<string> prefixes, string name>
136   : Option<prefixes, name, KIND_JOINED_AND_SEPARATE>;
137
138 // Mix-ins for adding optional attributes.
139
140 class Alias<Option alias> { Option Alias = alias; }
141 class EnumName<string name> { string EnumName = name; }
142 class Flags<list<OptionFlag> flags> { list<OptionFlag> Flags = flags; }
143 class Group<OptionGroup group> { OptionGroup Group = group; }
144 class HelpText<string text> { string HelpText = text; }
145 class MetaVarName<string name> { string MetaVarName = name; }
146
147 // Predefined options.
148
149 // FIXME: Have generator validate that these appear in correct position (and
150 // aren't duplicated).
151 def INPUT : Option<[], "<input>", KIND_INPUT>, Flags<[DriverOption,CC1Option]>;
152 def UNKNOWN : Option<[], "<unknown>", KIND_UNKNOWN>;