<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">This breaks the phase 1 llvmlab bot.<div><br></div><div>Can you fix or revert?</div><div><br></div><div><a href="http://lab.llvm.org:8013/builders/phase1%20-%20sanity/builds/9735">http://lab.llvm.org:8013/builders/phase1%20-%20sanity/builds/9735</a></div><div><br></div><div>Michael</div><div><br><div><div>On Jul 31, 2013, at 3:44 PM, Hans Wennborg <<a href="mailto:hans@hanshq.net">hans@hanshq.net</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Author: hans<br>Date: Wed Jul 31 17:44:41 2013<br>New Revision: 187537<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=187537&view=rev">http://llvm.org/viewvc/llvm-project?rev=187537&view=rev</a><br>Log:<br>Option parsing: add support for alias arguments.<br><br>This makes option aliases more powerful by enabling them to<br>pass along arguments to the option they're aliasing.<br><br>For example, if we have a joined option "-foo=", we can now<br>specify a flag option "-bar" to be an alias of that, with the<br>argument "baz".<br><br>This is especially useful for the cl.exe compatible clang driver,<br>where many options are aliases. For example, this patch enables<br>us to alias "/Ox" to "-O3" (-O is a joined option), and "/WX" to<br>"-Werror" (again, -W is a joined option).<br><br>Differential Revision:<span class="Apple-converted-space"> </span><a href="http://llvm-reviews.chandlerc.com/D1245">http://llvm-reviews.chandlerc.com/D1245</a><br><br>Modified:<br> llvm/trunk/include/llvm/Option/OptParser.td<br> llvm/trunk/include/llvm/Option/OptTable.h<br> llvm/trunk/include/llvm/Option/Option.h<br> llvm/trunk/lib/Option/Option.cpp<br> llvm/trunk/unittests/Option/OptionParsingTest.cpp<br> llvm/trunk/unittests/Option/Opts.td<br> llvm/trunk/utils/TableGen/OptParserEmitter.cpp<br><br>Modified: llvm/trunk/include/llvm/Option/OptParser.td<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Option/OptParser.td?rev=187537&r1=187536&r2=187537&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Option/OptParser.td?rev=187537&r1=187536&r2=187537&view=diff</a><br>==============================================================================<br>--- llvm/trunk/include/llvm/Option/OptParser.td (original)<br>+++ llvm/trunk/include/llvm/Option/OptParser.td Wed Jul 31 17:44:41 2013<br>@@ -89,6 +89,7 @@ class Option<list<string> prefixes, stri<br> list<OptionFlag> Flags = [];<br> OptionGroup Group = ?;<br> Option Alias = ?;<br>+ list<string> AliasArgs = [];<br>}<br><br>// Helpers for defining options.<br>@@ -113,6 +114,7 @@ class JoinedAndSeparate<list<string> pre<br>// Mix-ins for adding optional attributes.<br><br>class Alias<Option alias> { Option Alias = alias; }<br>+class AliasArgs<list<string> aliasargs> { list<string> AliasArgs = aliasargs; }<br>class EnumName<string name> { string EnumName = name; }<br>class Flags<list<OptionFlag> flags> { list<OptionFlag> Flags = flags; }<br>class Group<OptionGroup group> { OptionGroup Group = group; }<br><br>Modified: llvm/trunk/include/llvm/Option/OptTable.h<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Option/OptTable.h?rev=187537&r1=187536&r2=187537&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Option/OptTable.h?rev=187537&r1=187536&r2=187537&view=diff</a><br>==============================================================================<br>--- llvm/trunk/include/llvm/Option/OptTable.h (original)<br>+++ llvm/trunk/include/llvm/Option/OptTable.h Wed Jul 31 17:44:41 2013<br>@@ -44,6 +44,7 @@ public:<br> unsigned short Flags;<br> unsigned short GroupID;<br> unsigned short AliasID;<br>+ const char *AliasArgs;<br> };<br><br>private:<br><br>Modified: llvm/trunk/include/llvm/Option/Option.h<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Option/Option.h?rev=187537&r1=187536&r2=187537&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Option/Option.h?rev=187537&r1=187536&r2=187537&view=diff</a><br>==============================================================================<br>--- llvm/trunk/include/llvm/Option/Option.h (original)<br>+++ llvm/trunk/include/llvm/Option/Option.h Wed Jul 31 17:44:41 2013<br>@@ -103,6 +103,16 @@ public:<br> return Owner->getOption(Info->AliasID);<br> }<br><br>+ /// \brief Get the alias arguments as a \0 separated list.<br>+ /// E.g. ["foo", "bar"] would be returned as "foo\0bar\0".<br>+ const char *getAliasArgs() const {<br>+ assert(Info && "Must have a valid info!");<br>+ assert((!Info->AliasArgs || Info->AliasArgs[0] != 0) &&<br>+ "AliasArgs should be either 0 or non-empty.");<br>+<br>+ return Info->AliasArgs;<br>+ }<br>+<br> /// \brief Get the default prefix for this option.<br> StringRef getPrefix() const {<br> const char *Prefix = *Info->Prefixes;<br><br>Modified: llvm/trunk/lib/Option/Option.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Option/Option.cpp?rev=187537&r1=187536&r2=187537&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Option/Option.cpp?rev=187537&r1=187536&r2=187537&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Option/Option.cpp (original)<br>+++ llvm/trunk/lib/Option/Option.cpp Wed Jul 31 17:44:41 2013<br>@@ -26,6 +26,13 @@ Option::Option(const OptTable::Info *inf<br> // tracking, it is not an inherent limitation.<br> assert((!Info || !getAlias().isValid() || !getAlias().getAlias().isValid()) &&<br> "Multi-level aliases are not supported.");<br>+<br>+ if (Info && getAliasArgs()) {<br>+ assert(getAlias().isValid() && "Only alias options can have alias args.");<br>+ assert(getKind() == FlagClass && "Only Flag aliases can have alias args.");<br>+ assert(getAlias().getKind() != FlagClass &&<br>+ "Cannot provide alias args to a flag option.");<br>+ }<br>}<br><br>Option::~Option() {<br>@@ -106,11 +113,22 @@ Arg *Option::accept(const ArgList &Args,<br> }<br><br> switch (getKind()) {<br>- case FlagClass:<br>+ case FlagClass: {<br> if (ArgSize != strlen(Args.getArgString(Index)))<br> return 0;<br><br>- return new Arg(UnaliasedOption, Spelling, Index++);<br>+ Arg *A = new Arg(UnaliasedOption, Spelling, Index++);<br>+ if (getAliasArgs()) {<br>+ const char *Val = getAliasArgs();<br>+ while (*Val != '\0') {<br>+ A->getValues().push_back(Val);<br>+<br>+ // Move past the '\0' to the next argument.<br>+ Val += strlen(Val) + 1;<br>+ }<br>+ }<br>+ return A;<br>+ }<br> case JoinedClass: {<br> const char *Value = Args.getArgString(Index) + ArgSize;<br> return new Arg(UnaliasedOption, Spelling, Index++, Value);<br><br>Modified: llvm/trunk/unittests/Option/OptionParsingTest.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Option/OptionParsingTest.cpp?rev=187537&r1=187536&r2=187537&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Option/OptionParsingTest.cpp?rev=187537&r1=187536&r2=187537&view=diff</a><br>==============================================================================<br>--- llvm/trunk/unittests/Option/OptionParsingTest.cpp (original)<br>+++ llvm/trunk/unittests/Option/OptionParsingTest.cpp Wed Jul 31 17:44:41 2013<br>@@ -17,9 +17,11 @@<br>using namespace llvm;<br>using namespace llvm::opt;<br><br>+#define SUPPORT_ALIASARGS // FIXME: Remove when no longer necessary.<br>+<br>enum ID {<br> OPT_INVALID = 0, // This is not an option ID.<br>-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM, \<br>+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \<br> HELPTEXT, METAVAR) OPT_##ID,<br>#include "Opts.inc"<br> LastOption<br>@@ -37,10 +39,10 @@ enum OptionFlags {<br>};<br><br>static const OptTable::Info InfoTable[] = {<br>-#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM, \<br>+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \<br> HELPTEXT, METAVAR) \<br> { PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, PARAM, \<br>- FLAGS, OPT_##GROUP, OPT_##ALIAS },<br>+ FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS },<br>#include "Opts.inc"<br>#undef OPTION<br>};<br>@@ -145,3 +147,14 @@ TEST(Option, ParseAliasInGroup) {<br> OwningPtr<InputArgList> AL(T.ParseArgs(MyArgs, array_endof(MyArgs), MAI, MAC));<br> EXPECT_TRUE(AL->hasArg(OPT_H));<br>}<br>+<br>+TEST(Option, AliasArgs) {<br>+ TestOptTable T;<br>+ unsigned MAI, MAC;<br>+<br>+ const char *MyArgs[] = { "-J", "-Joo" };<br>+ OwningPtr<InputArgList> AL(T.ParseArgs(MyArgs, array_endof(MyArgs), MAI, MAC));<br>+ EXPECT_TRUE(AL->hasArg(OPT_B));<br>+ EXPECT_EQ(AL->getAllArgValues(OPT_B)[0], "foo");<br>+ EXPECT_EQ(AL->getAllArgValues(OPT_B)[1], "bar");<br>+}<br><br>Modified: llvm/trunk/unittests/Option/Opts.td<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Option/Opts.td?rev=187537&r1=187536&r2=187537&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Option/Opts.td?rev=187537&r1=187536&r2=187537&view=diff</a><br>==============================================================================<br>--- llvm/trunk/unittests/Option/Opts.td (original)<br>+++ llvm/trunk/unittests/Option/Opts.td Wed Jul 31 17:44:41 2013<br>@@ -19,3 +19,6 @@ def H : Flag<["-"], "H">, Flags<[HelpHid<br><br>def my_group : OptionGroup<"my group">;<br>def I : Flag<["-"], "I">, Alias<H>, Group<my_group>;<br>+<br>+def J : Flag<["-"], "J">, Alias<B>, AliasArgs<["foo"]>;<br>+def Joo : Flag<["-"], "Joo">, Alias<B>, AliasArgs<["bar"]>;<br><br>Modified: llvm/trunk/utils/TableGen/OptParserEmitter.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/OptParserEmitter.cpp?rev=187537&r1=187536&r2=187537&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/OptParserEmitter.cpp?rev=187537&r1=187536&r2=187537&view=diff</a><br>==============================================================================<br>--- llvm/trunk/utils/TableGen/OptParserEmitter.cpp (original)<br>+++ llvm/trunk/utils/TableGen/OptParserEmitter.cpp Wed Jul 31 17:44:41 2013<br>@@ -152,11 +152,22 @@ void EmitOptParser(RecordKeeper &Records<br> OS << "/////////\n";<br> OS << "// Groups\n\n";<br> OS << "#ifdef OPTION\n";<br>+<br>+ // FIXME: Remove when option parsing clients are updated.<br>+ OS << "#ifdef SUPPORT_ALIASARGS\n";<br>+ OS << "#define OPTIONX OPTION\n";<br>+ OS << "#else\n";<br>+ OS << "#define OPTIONX(prefix, name, id, kind, group, alias, aliasargs, "<br>+ << "flags, param, helptext, metavar) "<br>+ << "OPTION(prefix, name, id, kind, "<br>+ << "group, alias, flags, param, helptext, metavar)\n";<br>+ OS << "#endif\n";<br>+<br> for (unsigned i = 0, e = Groups.size(); i != e; ++i) {<br> const Record &R = *Groups[i];<br><br> // Start a single option entry.<br>- OS << "OPTION(";<br>+ OS << "OPTIONX(";<br><br> // The option prefix;<br> OS << "0";<br>@@ -178,7 +189,7 @@ void EmitOptParser(RecordKeeper &Records<br> OS << "INVALID";<br><br> // The other option arguments (unused for groups).<br>- OS << ", INVALID, 0, 0";<br>+ OS << ", INVALID, 0, 0, 0";<br><br> // The option help text.<br> if (!isa<UnsetInit>(R.getValueInit("HelpText"))) {<br>@@ -199,7 +210,7 @@ void EmitOptParser(RecordKeeper &Records<br> const Record &R = *Opts[i];<br><br> // Start a single option entry.<br>- OS << "OPTION(";<br>+ OS << "OPTIONX(";<br><br> // The option prefix;<br> std::vector<std::string> prf = R.getValueAsListOfStrings("Prefixes");<br>@@ -228,6 +239,21 @@ void EmitOptParser(RecordKeeper &Records<br> else<br> OS << "INVALID";<br><br>+ // The option alias arguments (if any).<br>+ // Emitted as a \0 separated list in a string, e.g. ["foo", "bar"]<br>+ // would become "foo\0bar\0". Note that the compiler adds an implicit<br>+ // terminating \0 at the end.<br>+ OS << ", ";<br>+ std::vector<std::string> AliasArgs = R.getValueAsListOfStrings("AliasArgs");<br>+ if (AliasArgs.size() == 0) {<br>+ OS << "0";<br>+ } else {<br>+ OS << "\"";<br>+ for (size_t i = 0, e = AliasArgs.size(); i != e; ++i)<br>+ OS << AliasArgs[i] << "<a href="smb://0">\\0</a>";<br>+ OS << "\"";<br>+ }<br>+<br> // The option flags.<br> const ListInit *LI = R.getValueAsListInit("Flags");<br> if (LI->empty()) {<br>@@ -261,6 +287,7 @@ void EmitOptParser(RecordKeeper &Records<br><br> OS << ")\n";<br> }<br>+ OS << "#undef OPTIONX\n"; // FIXME: Remove when option clients are updated.<br> OS << "#endif\n";<br>}<br>} // end namespace llvm<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></div></body></html>