Index: llvm/include/llvm/Support/CommandLine.h =================================================================== --- llvm/include/llvm/Support/CommandLine.h +++ llvm/include/llvm/Support/CommandLine.h @@ -1476,6 +1476,8 @@ const OptionValue &V = this->getDefault(); if (V.hasValue()) this->setValue(V.getValue()); + else + this->setValue(T()); } template Option("option"); + StackOption Str("str"); StackOption> Sink(cl::Sink); StackOption Input(cl::Positional); StackOption> ExtraArgs(cl::ConsumeAfter); - const char *Args[] = {"prog", "-option", "-unknown", "input", "-arg"}; + const char *Args[] = {"prog", "-option", "-str=STR", "-unknown", "input", "-arg"}; std::string Errs; raw_string_ostream OS(Errs); - EXPECT_TRUE(cl::ParseCommandLineOptions(5, Args, StringRef(), &OS)); + EXPECT_TRUE(cl::ParseCommandLineOptions(6, Args, StringRef(), &OS)); EXPECT_TRUE(OS.str().empty()); EXPECT_TRUE(Option); + EXPECT_EQ("STR", Str); EXPECT_EQ(1, (int)Sink.size()); EXPECT_EQ("-unknown", Sink[0]); EXPECT_EQ("input", Input); @@ -1925,6 +1927,7 @@ cl::ResetAllOptionOccurrences(); EXPECT_FALSE(Option); + EXPECT_EQ("", Str); EXPECT_EQ(0, (int)Sink.size()); EXPECT_EQ(0, Input.getNumOccurrences()); EXPECT_EQ(0, (int)ExtraArgs.size());