]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/llvm/tools/clang/include/clang/Driver/OptParser.td
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.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 // Define the option group class.
89
90 class OptionGroup<string name> {
91   string EnumName = ?; // Uses the def name if undefined.
92   string Name = name;
93   string HelpText = ?;
94   OptionGroup Group = ?;
95 }
96
97 // Define the option class.
98
99 class Option<string name, OptionKind kind> {
100   string EnumName = ?; // Uses the def name if undefined.
101   string Name = name;
102   OptionKind Kind = kind;
103   // Used by MultiArg option kind.
104   int NumArgs = 0;
105   string HelpText = ?;
106   string MetaVarName = ?;
107   list<OptionFlag> Flags = [];
108   OptionGroup Group = ?;
109   Option Alias = ?;
110 }
111
112 // Helpers for defining options.
113
114 class Flag<string name> : Option<name, KIND_FLAG>;
115 class Joined<string name> : Option<name, KIND_JOINED>;
116 class Separate<string name> : Option<name, KIND_SEPARATE>;
117 class CommaJoined<string name> : Option<name, KIND_COMMAJOINED>;
118 class MultiArg<string name, int numargs> : Option<name, KIND_MULTIARG> {
119   int NumArgs = numargs;
120 }
121 class JoinedOrSeparate<string name> : Option<name, KIND_JOINED_OR_SEPARATE>;
122 class JoinedAndSeparate<string name> : Option<name, KIND_JOINED_AND_SEPARATE>;
123
124 // Mix-ins for adding optional attributes.
125
126 class Alias<Option alias> { Option Alias = alias; }
127 class EnumName<string name> { string EnumName = name; }
128 class Flags<list<OptionFlag> flags> { list<OptionFlag> Flags = flags; }
129 class Group<OptionGroup group> { OptionGroup Group = group; }
130 class HelpText<string text> { string HelpText = text; }
131 class MetaVarName<string name> { string MetaVarName = name; }
132
133 // Predefined options.
134
135 // FIXME: Have generator validate that these appear in correct position (and
136 // aren't duplicated).
137 def INPUT : Option<"<input>", KIND_INPUT>, Flags<[DriverOption]>;
138 def UNKNOWN : Option<"<unknown>", KIND_UNKNOWN>;