]>
git.proxmox.com Git - rustc.git/blob - src/llvm/tools/clang/include/clang/Driver/Option.h
1 //===--- Option.h - Abstract Driver Options ---------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef CLANG_DRIVER_OPTION_H_
11 #define CLANG_DRIVER_OPTION_H_
13 #include "clang/Driver/OptTable.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/Support/ErrorHandling.h"
16 #include "clang/Basic/LLVM.h"
25 DriverOption
= (1 << 0),
26 HelpHidden
= (1 << 1),
27 LinkerInput
= (1 << 2),
28 NoArgumentUnused
= (1 << 3),
30 RenderAsInput
= (1 << 5),
31 RenderJoined
= (1 << 6),
32 RenderSeparate
= (1 << 7),
33 Unsupported
= (1 << 8),
38 /// Option - Abstract representation for a single form of driver
41 /// An Option class represents a form of option that the driver
42 /// takes, for example how many arguments the option has and how
43 /// they can be provided. Individual option instances store
44 /// additional information about what group the option is a member
45 /// of (if any), if the option is an alias, and a number of
46 /// flags. At runtime the driver parses the command line into
47 /// concrete Arg instances, each of which corresponds to a
48 /// particular Option instance.
60 JoinedOrSeparateClass
,
61 JoinedAndSeparateClass
64 enum RenderStyleKind
{
65 RenderCommaJoinedStyle
,
72 const OptTable::Info
*Info
;
74 /// Group this option is a member of, if any.
77 /// Option that this is an alias for, if any.
81 Option(const OptTable::Info
*Info
,
82 const Option
*Group
, const Option
*Alias
);
85 unsigned getID() const { return Info
->ID
; }
86 OptionClass
getKind() const { return OptionClass(Info
->Kind
); }
87 StringRef
getName() const { return Info
->Name
; }
88 const Option
*getGroup() const { return Group
; }
89 const Option
*getAlias() const { return Alias
; }
91 unsigned getNumArgs() const { return Info
->Param
; }
93 bool isUnsupported() const { return Info
->Flags
& options::Unsupported
; }
95 bool isLinkerInput() const { return Info
->Flags
& options::LinkerInput
; }
97 bool hasNoOptAsInput() const { return Info
->Flags
& options::RenderAsInput
;}
99 RenderStyleKind
getRenderStyle() const {
100 if (Info
->Flags
& options::RenderJoined
)
101 return RenderJoinedStyle
;
102 if (Info
->Flags
& options::RenderSeparate
)
103 return RenderSeparateStyle
;
108 return RenderValuesStyle
;
110 case JoinedAndSeparateClass
:
111 return RenderJoinedStyle
;
112 case CommaJoinedClass
:
113 return RenderCommaJoinedStyle
;
117 case JoinedOrSeparateClass
:
118 return RenderSeparateStyle
;
120 llvm_unreachable("Unexpected kind!");
123 bool isDriverOption() const { return Info
->Flags
& options::DriverOption
; }
125 bool hasNoArgumentUnused() const {
126 return Info
->Flags
& options::NoArgumentUnused
;
129 bool hasNoForward() const { return Info
->Flags
& options::NoForward
; }
131 bool isCC1Option() const { return Info
->Flags
& options::CC1Option
; }
133 bool hasForwardToGCC() const {
134 return !hasNoForward() && !isDriverOption() && !isLinkerInput();
137 /// getUnaliasedOption - Return the final option this option
138 /// aliases (itself, if the option has no alias).
139 const Option
*getUnaliasedOption() const {
140 if (Alias
) return Alias
->getUnaliasedOption();
144 /// getRenderName - Return the name to use when rendering this
146 StringRef
getRenderName() const {
147 return getUnaliasedOption()->getName();
150 /// matches - Predicate for whether this option is part of the
151 /// given option (which may be a group).
153 /// Note that matches against options which are an alias should never be
154 /// done -- aliases do not participate in matching and so such a query will
156 bool matches(OptSpecifier ID
) const;
158 /// accept - Potentially accept the current argument, returning a
159 /// new Arg instance, or 0 if the option does not accept this
160 /// argument (or the argument is missing values).
162 /// If the option accepts the current argument, accept() sets
163 /// Index to the position where argument parsing should resume
164 /// (even if the argument is missing values).
165 Arg
*accept(const ArgList
&Args
, unsigned &Index
) const;
170 } // end namespace driver
171 } // end namespace clang