<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 22, 2015 at 4:27 PM, Justin Bogner <span dir="ltr"><<a href="mailto:mail@justinbogner.com" target="_blank">mail@justinbogner.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> writes:<br>
> Author: dblaikie<br>
> Date: Mon Jun 22 17:06:37 2015<br>
> New Revision: 240345<br>
><br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D240345-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=pSYIAq2dkpPRKEc48734guqToYw-_Ym5D5NKocpezUc&s=D_jN4XPqMQrSro49QFdnjC5j4iY0FNZ2R-Di6DPXkRM&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=240345&view=rev</a><br>
> Log:<br>
> Modify ParseArgs to return the InputArgList by value - there's no need<br>
> for dynamic allocation/ownership here<br>
><br>
> The one caller that does anything other than keep this variable on the<br>
> stack is the single use of DerivedArgList in Clang, which is a bit more<br>
> interesting but can probably be cleaned up/simplified a bit further<br>
> (have DerivedArgList take ownership of the InputArgList rather than<br>
> needing to reference its Args indirectly) which I'll try to after this.<br>
><br>
> Modified:<br>
> llvm/trunk/include/llvm/Option/ArgList.h<br>
> llvm/trunk/include/llvm/Option/OptTable.h<br>
> llvm/trunk/lib/LibDriver/LibDriver.cpp<br>
> llvm/trunk/lib/Option/OptTable.cpp<br>
> llvm/trunk/unittests/Option/OptionParsingTest.cpp<br>
><br>
> Modified: llvm/trunk/include/llvm/Option/ArgList.h<br>
> URL:<br>
> <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_Option_ArgList.h-3Frev-3D240345-26r1-3D240344-26r2-3D240345-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=pSYIAq2dkpPRKEc48734guqToYw-_Ym5D5NKocpezUc&s=4yC2wfzLAnfnPZbPJXLuXtjwj8Fg0WMCDX3bShSWkgg&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Option/ArgList.h?rev=240345&r1=240344&r2=240345&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/Option/ArgList.h (original)<br>
> +++ llvm/trunk/include/llvm/Option/ArgList.h Mon Jun 22 17:06:37 2015<br>
> @@ -92,10 +92,6 @@ public:<br>
> /// check for the presence of Arg instances for a particular Option<br>
> /// and to iterate over groups of arguments.<br>
> class ArgList {<br>
> -private:<br>
> - ArgList(const ArgList &) = delete;<br>
> - void operator=(const ArgList &) = delete;<br>
> -<br>
> public:<br>
> typedef SmallVector<Arg*, 16> arglist_type;<br>
> typedef arglist_type::iterator iterator;<br>
> @@ -108,9 +104,21 @@ private:<br>
> arglist_type Args;<br>
><br>
> protected:<br>
> - // Default ctor provided explicitly as it is not provided implicitly due to<br>
> - // the presence of the (deleted) copy ctor above.<br>
> + // Make the default special members protected so they won't be used to slice<br>
> + // derived objects, but can still be used by derived objects to implement<br>
> + // their own special members.<br>
> ArgList() = default;<br>
> + // Explicit move operations to ensure the container is cleared post-move<br>
> + // otherwise it could lead to a double-delete in the case of moving of an<br>
> + // InputArgList which deletes the contents of the container. If we could fix<br>
> + // up the ownership here (delegate storage/ownership to the derived class so<br>
> + // it can be a container of unique_ptr) this would be simpler.<br>
> + ArgList(ArgList &&RHS) : Args(std::move(RHS.Args)) { RHS.Args.clear(); }<br>
> + ArgList &operator=(ArgList &&RHS) {<br>
> + Args = std::move(RHS.Args);<br>
> + RHS.Args.clear();<br>
> + return *this;<br>
> + }<br>
> // Protect the dtor to ensure this type is never destroyed polymorphically.<br>
> ~ArgList() = default;<br>
><br>
> @@ -319,6 +327,19 @@ private:<br>
><br>
> public:<br>
> InputArgList(const char* const *ArgBegin, const char* const *ArgEnd);<br>
> + // Default move operations implemented for the convenience of MSVC. Nothing<br>
> + // special here.<br>
> + InputArgList(InputArgList &&RHS)<br>
> + : ArgList(std::move(RHS)), ArgStrings(std::move(RHS.ArgStrings)),<br>
> + SynthesizedStrings(std::move(RHS.SynthesizedStrings)),<br>
> + NumInputArgStrings(RHS.NumInputArgStrings) {}<br>
> + InputArgList &operator=(InputArgList &&RHS) {<br>
> + ArgList::operator=(std::move(RHS));<br>
> + ArgStrings = std::move(RHS.ArgStrings);<br>
> + SynthesizedStrings = std::move(RHS.SynthesizedStrings);<br>
> + NumInputArgStrings = RHS.NumInputArgStrings;<br>
> + return *this;<br>
> + }<br>
> ~InputArgList();<br>
><br>
> const char *getArgString(unsigned Index) const override {<br>
><br>
> Modified: llvm/trunk/include/llvm/Option/OptTable.h<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_Option_OptTable.h-3Frev-3D240345-26r1-3D240344-26r2-3D240345-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=pSYIAq2dkpPRKEc48734guqToYw-_Ym5D5NKocpezUc&s=uaBY3irkfCtkr1excInEEv6ZXXprXP-x9vT00MSa7EI&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Option/OptTable.h?rev=240345&r1=240344&r2=240345&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/Option/OptTable.h (original)<br>
> +++ llvm/trunk/include/llvm/Option/OptTable.h Mon Jun 22 17:06:37 2015<br>
> @@ -151,10 +151,9 @@ public:<br>
> /// is the default and means exclude nothing.<br>
> /// \return An InputArgList; on error this will contain all the options<br>
> /// which could be parsed.<br>
> - InputArgList *ParseArgs(ArrayRef<const char *> Args,<br>
> - unsigned &MissingArgIndex, unsigned &MissingArgCount,<br>
> - unsigned FlagsToInclude = 0,<br>
> - unsigned FlagsToExclude = 0) const;<br>
> + InputArgList ParseArgs(ArrayRef<const char *> Args, unsigned &MissingArgIndex,<br>
> + unsigned &MissingArgCount, unsigned FlagsToInclude = 0,<br>
> + unsigned FlagsToExclude = 0) const;<br>
><br>
> /// \brief Render the help text for an option table.<br>
> ///<br>
><br>
> Modified: llvm/trunk/lib/LibDriver/LibDriver.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_LibDriver_LibDriver.cpp-3Frev-3D240345-26r1-3D240344-26r2-3D240345-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=pSYIAq2dkpPRKEc48734guqToYw-_Ym5D5NKocpezUc&s=szjdhK1f2Y_FbudlYREX9BB7d9L3msEwlGsYzKw3uz4&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LibDriver/LibDriver.cpp?rev=240345&r1=240344&r2=240345&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/LibDriver/LibDriver.cpp (original)<br>
> +++ llvm/trunk/lib/LibDriver/LibDriver.cpp Mon Jun 22 17:06:37 2015<br>
> @@ -113,27 +113,27 @@ int llvm::libDriverMain(llvm::ArrayRef<c<br>
> LibOptTable Table;<br>
> unsigned MissingIndex;<br>
> unsigned MissingCount;<br>
> - std::unique_ptr<llvm::opt::InputArgList> Args(<br>
> - Table.ParseArgs(ArgsArr.slice(1), MissingIndex, MissingCount));<br>
> + llvm::opt::InputArgList Args =<br>
> + Table.ParseArgs(ArgsArr.slice(1), MissingIndex, MissingCount);<br>
> if (MissingCount) {<br>
> llvm::errs() << "missing arg value for \""<br>
> - << Args->getArgString(MissingIndex)<br>
> - << "\", expected " << MissingCount<br>
> + << Args.getArgString(MissingIndex) << "\", expected "<br>
> + << MissingCount<br>
> << (MissingCount == 1 ? " argument.\n" : " arguments.\n");<br>
> return 1;<br>
> }<br>
> - for (auto *Arg : Args->filtered(OPT_UNKNOWN))<br>
> + for (auto *Arg : Args.filtered(OPT_UNKNOWN))<br>
> llvm::errs() << "ignoring unknown argument: " << Arg->getSpelling() << "\n";<br>
><br>
> - if (Args->filtered_begin(OPT_INPUT) == Args->filtered_end()) {<br>
> + if (Args.filtered_begin(OPT_INPUT) == Args.filtered_end()) {<br>
> llvm::errs() << "no input files.\n";<br>
> return 1;<br>
> }<br>
><br>
> - std::vector<StringRef> SearchPaths = getSearchPaths(Args.get(), Saver);<br>
> + std::vector<StringRef> SearchPaths = getSearchPaths(&Args, Saver);<br>
><br>
> std::vector<llvm::NewArchiveIterator> Members;<br>
> - for (auto *Arg : Args->filtered(OPT_INPUT)) {<br>
> + for (auto *Arg : Args.filtered(OPT_INPUT)) {<br>
> Optional<std::string> Path = findInputFile(Arg->getValue(), SearchPaths);<br>
> if (!Path.hasValue()) {<br>
> llvm::errs() << Arg->getValue() << ": no such file or directory\n";<br>
> @@ -143,8 +143,8 @@ int llvm::libDriverMain(llvm::ArrayRef<c<br>
> llvm::sys::path::filename(Arg->getValue()));<br>
> }<br>
><br>
> - std::pair<StringRef, std::error_code> Result = llvm::writeArchive(<br>
> - getOutputPath(Args.get()), Members, /*WriteSymtab=*/true);<br>
> + std::pair<StringRef, std::error_code> Result =<br>
> + llvm::writeArchive(getOutputPath(&Args), Members, /*WriteSymtab=*/true);<br>
> if (Result.second) {<br>
> if (Result.first.empty())<br>
> Result.first = ArgsArr[0];<br>
><br>
> Modified: llvm/trunk/lib/Option/OptTable.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Option_OptTable.cpp-3Frev-3D240345-26r1-3D240344-26r2-3D240345-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=pSYIAq2dkpPRKEc48734guqToYw-_Ym5D5NKocpezUc&s=1q1_oO-V6uxHxLEjLRtXhs-ypoySjCXPkSnFTrDaojo&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Option/OptTable.cpp?rev=240345&r1=240344&r2=240345&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Option/OptTable.cpp (original)<br>
> +++ llvm/trunk/lib/Option/OptTable.cpp Mon Jun 22 17:06:37 2015<br>
> @@ -247,12 +247,12 @@ Arg *OptTable::ParseOneArg(const ArgList<br>
> return new Arg(getOption(TheUnknownOptionID), Str, Index++, Str);<br>
> }<br>
><br>
> -InputArgList *OptTable::ParseArgs(ArrayRef<const char *> ArgArr,<br>
> - unsigned &MissingArgIndex,<br>
> - unsigned &MissingArgCount,<br>
> - unsigned FlagsToInclude,<br>
> - unsigned FlagsToExclude) const {<br>
> - InputArgList *Args = new InputArgList(ArgArr.begin(), ArgArr.end());<br>
> +InputArgList OptTable::ParseArgs(ArrayRef<const char *> ArgArr,<br>
> + unsigned &MissingArgIndex,<br>
> + unsigned &MissingArgCount,<br>
> + unsigned FlagsToInclude,<br>
> + unsigned FlagsToExclude) const {<br>
> + InputArgList Args(ArgArr.begin(), ArgArr.end());<br>
><br>
> // FIXME: Handle '@' args (or at least error on them).<br>
><br>
> @@ -260,19 +260,19 @@ InputArgList *OptTable::ParseArgs(ArrayR<br>
> unsigned Index = 0, End = ArgArr.size();<br>
> while (Index < End) {<br>
> // Ingore nullptrs, they are response file's EOL markers<br>
> - if (Args->getArgString(Index) == nullptr) {<br>
> + if (Args.getArgString(Index) == nullptr) {<br>
> ++Index;<br>
> continue;<br>
> }<br>
> // Ignore empty arguments (other things may still take them as arguments).<br>
> - StringRef Str = Args->getArgString(Index);<br>
> + StringRef Str = Args.getArgString(Index);<br>
> if (Str == "") {<br>
> ++Index;<br>
> continue;<br>
> }<br>
><br>
> unsigned Prev = Index;<br>
> - Arg *A = ParseOneArg(*Args, Index, FlagsToInclude, FlagsToExclude);<br>
> + Arg *A = ParseOneArg(Args, Index, FlagsToInclude, FlagsToExclude);<br>
> assert(Index > Prev && "Parser failed to consume argument.");<br>
><br>
> // Check for missing argument error.<br>
> @@ -284,10 +284,10 @@ InputArgList *OptTable::ParseArgs(ArrayR<br>
> break;<br>
> }<br>
><br>
> - Args->append(A);<br>
> + Args.append(A);<br>
> }<br>
><br>
> - return Args;<br>
> + return std::move(Args);<br>
<br>
</div></div>This move shouldn't be necessary and it prevents NRVO.<br></blockquote><div><br>Right you are - looks like Logan Chen already cleaned this up in r240355 & perhaps I need to update my host compiler to include the pessimizing move warning that was recently added.<br><br>- David<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
> }<br>
><br>
> static std::string getOptionHelpName(const OptTable &Opts, OptSpecifier Id) {<br>
><br>
> Modified: llvm/trunk/unittests/Option/OptionParsingTest.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_unittests_Option_OptionParsingTest.cpp-3Frev-3D240345-26r1-3D240344-26r2-3D240345-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=pSYIAq2dkpPRKEc48734guqToYw-_Ym5D5NKocpezUc&s=Ri8Y_1PPQffUesAW3G54Pfqv5EEaabVGLy0oE7xBgdk&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Option/OptionParsingTest.cpp?rev=240345&r1=240344&r2=240345&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/unittests/Option/OptionParsingTest.cpp (original)<br>
> +++ llvm/trunk/unittests/Option/OptionParsingTest.cpp Mon Jun 22 17:06:37 2015<br>
> @@ -67,26 +67,26 @@ const char *Args[] = {<br>
> TEST(Option, OptionParsing) {<br>
> TestOptTable T;<br>
> unsigned MAI, MAC;<br>
> - std::unique_ptr<InputArgList> AL(T.ParseArgs(Args, MAI, MAC));<br>
> + InputArgList AL = T.ParseArgs(Args, MAI, MAC);<br>
><br>
> // Check they all exist.<br>
> - EXPECT_TRUE(AL->hasArg(OPT_A));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_B));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_C));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_D));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_E));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_F));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_G));<br>
> + EXPECT_TRUE(AL.hasArg(OPT_A));<br>
> + EXPECT_TRUE(AL.hasArg(OPT_B));<br>
> + EXPECT_TRUE(AL.hasArg(OPT_C));<br>
> + EXPECT_TRUE(AL.hasArg(OPT_D));<br>
> + EXPECT_TRUE(AL.hasArg(OPT_E));<br>
> + EXPECT_TRUE(AL.hasArg(OPT_F));<br>
> + EXPECT_TRUE(AL.hasArg(OPT_G));<br>
><br>
> // Check the values.<br>
> - EXPECT_EQ(AL->getLastArgValue(OPT_B), "hi");<br>
> - EXPECT_EQ(AL->getLastArgValue(OPT_C), "bye");<br>
> - EXPECT_EQ(AL->getLastArgValue(OPT_D), "adena");<br>
> - std::vector<std::string> Es = AL->getAllArgValues(OPT_E);<br>
> + EXPECT_EQ(AL.getLastArgValue(OPT_B), "hi");<br>
> + EXPECT_EQ(AL.getLastArgValue(OPT_C), "bye");<br>
> + EXPECT_EQ(AL.getLastArgValue(OPT_D), "adena");<br>
> + std::vector<std::string> Es = AL.getAllArgValues(OPT_E);<br>
> EXPECT_EQ(Es[0], "apple");<br>
> EXPECT_EQ(Es[1], "bloom");<br>
> - EXPECT_EQ(AL->getLastArgValue(OPT_F), "42");<br>
> - std::vector<std::string> Gs = AL->getAllArgValues(OPT_G);<br>
> + EXPECT_EQ(AL.getLastArgValue(OPT_F), "42");<br>
> + std::vector<std::string> Gs = AL.getAllArgValues(OPT_G);<br>
> EXPECT_EQ(Gs[0], "chuu");<br>
> EXPECT_EQ(Gs[1], "2");<br>
><br>
> @@ -97,11 +97,11 @@ TEST(Option, OptionParsing) {<br>
> EXPECT_NE(Help.find("-A"), std::string::npos);<br>
><br>
> // Test aliases.<br>
> - arg_iterator Cs = AL->filtered_begin(OPT_C);<br>
> - ASSERT_NE(Cs, AL->filtered_end());<br>
> + arg_iterator Cs = AL.filtered_begin(OPT_C);<br>
> + ASSERT_NE(Cs, AL.filtered_end());<br>
> EXPECT_EQ(StringRef((*Cs)->getValue()), "desu");<br>
> ArgStringList ASL;<br>
> - (*Cs)->render(*AL, ASL);<br>
> + (*Cs)->render(AL, ASL);<br>
> ASSERT_EQ(ASL.size(), 2u);<br>
> EXPECT_EQ(StringRef(ASL[0]), "-C");<br>
> EXPECT_EQ(StringRef(ASL[1]), "desu");<br>
> @@ -110,30 +110,29 @@ TEST(Option, OptionParsing) {<br>
> TEST(Option, ParseWithFlagExclusions) {<br>
> TestOptTable T;<br>
> unsigned MAI, MAC;<br>
> - std::unique_ptr<InputArgList> AL;<br>
><br>
> // Exclude flag3 to avoid parsing as OPT_SLASH_C.<br>
> - AL.reset(T.ParseArgs(Args, MAI, MAC,<br>
> - /*FlagsToInclude=*/0,<br>
> - /*FlagsToExclude=*/OptFlag3));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_A));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_C));<br>
> - EXPECT_FALSE(AL->hasArg(OPT_SLASH_C));<br>
> + InputArgList AL = T.ParseArgs(Args, MAI, MAC,<br>
> + /*FlagsToInclude=*/0,<br>
> + /*FlagsToExclude=*/OptFlag3);<br>
> + EXPECT_TRUE(AL.hasArg(OPT_A));<br>
> + EXPECT_TRUE(AL.hasArg(OPT_C));<br>
> + EXPECT_FALSE(AL.hasArg(OPT_SLASH_C));<br>
><br>
> // Exclude flag1 to avoid parsing as OPT_C.<br>
> - AL.reset(T.ParseArgs(Args, MAI, MAC,<br>
> - /*FlagsToInclude=*/0,<br>
> - /*FlagsToExclude=*/OptFlag1));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_B));<br>
> - EXPECT_FALSE(AL->hasArg(OPT_C));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_SLASH_C));<br>
> + AL = T.ParseArgs(Args, MAI, MAC,<br>
> + /*FlagsToInclude=*/0,<br>
> + /*FlagsToExclude=*/OptFlag1);<br>
> + EXPECT_TRUE(AL.hasArg(OPT_B));<br>
> + EXPECT_FALSE(AL.hasArg(OPT_C));<br>
> + EXPECT_TRUE(AL.hasArg(OPT_SLASH_C));<br>
><br>
> const char *NewArgs[] = { "/C", "foo", "--C=bar" };<br>
> - AL.reset(T.ParseArgs(NewArgs, MAI, MAC));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_SLASH_C));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_C));<br>
> - EXPECT_EQ(AL->getLastArgValue(OPT_SLASH_C), "foo");<br>
> - EXPECT_EQ(AL->getLastArgValue(OPT_C), "bar");<br>
> + AL = T.ParseArgs(NewArgs, MAI, MAC);<br>
> + EXPECT_TRUE(AL.hasArg(OPT_SLASH_C));<br>
> + EXPECT_TRUE(AL.hasArg(OPT_C));<br>
> + EXPECT_EQ(AL.getLastArgValue(OPT_SLASH_C), "foo");<br>
> + EXPECT_EQ(AL.getLastArgValue(OPT_C), "bar");<br>
> }<br>
><br>
> TEST(Option, ParseAliasInGroup) {<br>
> @@ -141,8 +140,8 @@ TEST(Option, ParseAliasInGroup) {<br>
> unsigned MAI, MAC;<br>
><br>
> const char *MyArgs[] = { "-I" };<br>
> - std::unique_ptr<InputArgList> AL(T.ParseArgs(MyArgs, MAI, MAC));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_H));<br>
> + InputArgList AL = T.ParseArgs(MyArgs, MAI, MAC);<br>
> + EXPECT_TRUE(AL.hasArg(OPT_H));<br>
> }<br>
><br>
> TEST(Option, AliasArgs) {<br>
> @@ -150,10 +149,10 @@ TEST(Option, AliasArgs) {<br>
> unsigned MAI, MAC;<br>
><br>
> const char *MyArgs[] = { "-J", "-Joo" };<br>
> - std::unique_ptr<InputArgList> AL(T.ParseArgs(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>
> + InputArgList AL = T.ParseArgs(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>
> TEST(Option, IgnoreCase) {<br>
> @@ -161,9 +160,9 @@ TEST(Option, IgnoreCase) {<br>
> unsigned MAI, MAC;<br>
><br>
> const char *MyArgs[] = { "-a", "-joo" };<br>
> - std::unique_ptr<InputArgList> AL(T.ParseArgs(MyArgs, MAI, MAC));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_A));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_B));<br>
> + InputArgList AL = T.ParseArgs(MyArgs, MAI, MAC);<br>
> + EXPECT_TRUE(AL.hasArg(OPT_A));<br>
> + EXPECT_TRUE(AL.hasArg(OPT_B));<br>
> }<br>
><br>
> TEST(Option, DoNotIgnoreCase) {<br>
> @@ -171,9 +170,9 @@ TEST(Option, DoNotIgnoreCase) {<br>
> unsigned MAI, MAC;<br>
><br>
> const char *MyArgs[] = { "-a", "-joo" };<br>
> - std::unique_ptr<InputArgList> AL(T.ParseArgs(MyArgs, MAI, MAC));<br>
> - EXPECT_FALSE(AL->hasArg(OPT_A));<br>
> - EXPECT_FALSE(AL->hasArg(OPT_B));<br>
> + InputArgList AL = T.ParseArgs(MyArgs, MAI, MAC);<br>
> + EXPECT_FALSE(AL.hasArg(OPT_A));<br>
> + EXPECT_FALSE(AL.hasArg(OPT_B));<br>
> }<br>
><br>
> TEST(Option, SlurpEmpty) {<br>
> @@ -181,10 +180,10 @@ TEST(Option, SlurpEmpty) {<br>
> unsigned MAI, MAC;<br>
><br>
> const char *MyArgs[] = { "-A", "-slurp" };<br>
> - std::unique_ptr<InputArgList> AL(T.ParseArgs(MyArgs, MAI, MAC));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_A));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_Slurp));<br>
> - EXPECT_EQ(AL->getAllArgValues(OPT_Slurp).size(), 0U);<br>
> + InputArgList AL = T.ParseArgs(MyArgs, MAI, MAC);<br>
> + EXPECT_TRUE(AL.hasArg(OPT_A));<br>
> + EXPECT_TRUE(AL.hasArg(OPT_Slurp));<br>
> + EXPECT_EQ(AL.getAllArgValues(OPT_Slurp).size(), 0U);<br>
> }<br>
><br>
> TEST(Option, Slurp) {<br>
> @@ -192,15 +191,15 @@ TEST(Option, Slurp) {<br>
> unsigned MAI, MAC;<br>
><br>
> const char *MyArgs[] = { "-A", "-slurp", "-B", "--", "foo" };<br>
> - std::unique_ptr<InputArgList> AL(T.ParseArgs(MyArgs, MAI, MAC));<br>
> - EXPECT_EQ(AL->size(), 2U);<br>
> - EXPECT_TRUE(AL->hasArg(OPT_A));<br>
> - EXPECT_FALSE(AL->hasArg(OPT_B));<br>
> - EXPECT_TRUE(AL->hasArg(OPT_Slurp));<br>
> - EXPECT_EQ(AL->getAllArgValues(OPT_Slurp).size(), 3U);<br>
> - EXPECT_EQ(AL->getAllArgValues(OPT_Slurp)[0], "-B");<br>
> - EXPECT_EQ(AL->getAllArgValues(OPT_Slurp)[1], "--");<br>
> - EXPECT_EQ(AL->getAllArgValues(OPT_Slurp)[2], "foo");<br>
> + InputArgList AL = T.ParseArgs(MyArgs, MAI, MAC);<br>
> + EXPECT_EQ(AL.size(), 2U);<br>
> + EXPECT_TRUE(AL.hasArg(OPT_A));<br>
> + EXPECT_FALSE(AL.hasArg(OPT_B));<br>
> + EXPECT_TRUE(AL.hasArg(OPT_Slurp));<br>
> + EXPECT_EQ(AL.getAllArgValues(OPT_Slurp).size(), 3U);<br>
> + EXPECT_EQ(AL.getAllArgValues(OPT_Slurp)[0], "-B");<br>
> + EXPECT_EQ(AL.getAllArgValues(OPT_Slurp)[1], "--");<br>
> + EXPECT_EQ(AL.getAllArgValues(OPT_Slurp)[2], "foo");<br>
> }<br>
><br>
> TEST(Option, FlagAliasToJoined) {<br>
> @@ -209,9 +208,9 @@ TEST(Option, FlagAliasToJoined) {<br>
><br>
> // Check that a flag alias provides an empty argument to a joined option.<br>
> const char *MyArgs[] = { "-K" };<br>
> - std::unique_ptr<InputArgList> AL(T.ParseArgs(MyArgs, MAI, MAC));<br>
> - EXPECT_EQ(AL->size(), 1U);<br>
> - EXPECT_TRUE(AL->hasArg(OPT_B));<br>
> - EXPECT_EQ(AL->getAllArgValues(OPT_B).size(), 1U);<br>
> - EXPECT_EQ(AL->getAllArgValues(OPT_B)[0], "");<br>
> + InputArgList AL = T.ParseArgs(MyArgs, MAI, MAC);<br>
> + EXPECT_EQ(AL.size(), 1U);<br>
> + EXPECT_TRUE(AL.hasArg(OPT_B));<br>
> + EXPECT_EQ(AL.getAllArgValues(OPT_B).size(), 1U);<br>
> + EXPECT_EQ(AL.getAllArgValues(OPT_B)[0], "");<br>
> }<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" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div></div>