llvm.org GIT mirror llvm / 6c7e787
Option parsing: allow aliases in groups Option aliases in option groups were previously disallowed by an assert. As far as I can tell, there was no technical reason for this, and I would like to be able to put cl.exe compatible options in their own group for Clang, so let's change the assert. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186838 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 6 years ago
3 changed file(s) with 16 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
2121 Option::Option(const OptTable::Info *info, const OptTable *owner)
2222 : Info(info), Owner(owner) {
2323
24 // Multi-level aliases are not supported, and alias options cannot
25 // have groups. This just simplifies option tracking, it is not an
26 // inherent limitation.
27 assert((!Info || !getAlias().isValid() || (!getAlias().getAlias().isValid() &&
28 !getGroup().isValid())) &&
29 "Multi-level aliases and aliases with groups are unsupported.");
24 // Multi-level aliases are not supported. This just simplifies option
25 // tracking, it is not an inherent limitation.
26 assert(!Info || !getAlias().isValid() || !getAlias().getAlias().isValid() &&
27 "Multi-level aliases are not supported.");
3028 }
3129
3230 Option::~Option() {
135135 EXPECT_EQ(AL->getLastArgValue(OPT_SLASH_C), "foo");
136136 EXPECT_EQ(AL->getLastArgValue(OPT_C), "bar");
137137 }
138
139 TEST(Option, ParseAliasInGroup) {
140 TestOptTable T;
141 unsigned MAI, MAC;
142
143 const char *MyArgs[] = { "-I" };
144 OwningPtr AL(T.ParseArgs(MyArgs, array_endof(MyArgs), MAI, MAC));
145 EXPECT_TRUE(AL->hasArg(OPT_H));
146 }
1515 def Ceq : Joined<["-", "--"], "C=">, Alias, Flags<[OptFlag1]>;
1616
1717 def H : Flag<["-"], "H">, Flags<[HelpHidden]>;
18
19 def my_group : OptionGroup<"my group">;
20 def I : Flag<["-"], "I">, Alias, Group;