This patch makes opt::setDefaultImpl() set the option value to the option type's default value if the Default field is not set. This results in option value reset by Option::reset() or ResetAllOptionOccurrences() even if the cl::init() is not specified.
Example:
StackOption<std::string> Str("str"); // No cl::init().
Str = "some value";
cl::ResetAllOptionOccurrences();
EXPECT_EQ("", Str); // The Str is reset.
clang-format: please reformat the code
- const char *Args[] = {"prog", "-option", "-str=STR", "-unknown", "input", "-arg"}; + const char *Args[] = {"prog", "-option", "-str=STR", + "-unknown", "input", "-arg"};