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