This is an archive of the discontinued LLVM Phabricator instance.

[Support][CommandLine] Add cl::Option::setDefault()
ClosedPublic

Authored by emankov on Aug 18 2017, 9:15 AM.

Details

Summary

Add abstract virtual method setDefault() to class Option() and implement it in its inheritors in order to be able to set all the options to its default values in user's code without actually knowing all these options. For instance:

for (auto SC : llvm::cl::getRegisteredSubcommands()) {
  for (auto &OM : SC->OptionsMap) {
    llvm::cl::Option *O = OM.second;
    // added functionality:
    O->setDefault();
  }
}

Diff Detail

Repository
rL LLVM

Event Timeline

emankov created this revision.Aug 18 2017, 9:15 AM
rampitec edited edge metadata.Aug 22 2017, 11:38 AM

I think you need a test here.

include/llvm/Support/CommandLine.h
1514 ↗(On Diff #111683)

Please run Clang-format over diff. Isn't this should be?

void setDefault() override {}

emankov updated this revision to Diff 112338.Aug 23 2017, 5:36 AM

formatting

This comment was removed by emankov.
emankov marked an inline comment as done.Aug 23 2017, 5:52 AM
emankov updated this revision to Diff 112578.Aug 24 2017, 10:39 AM
emankov added a reviewer: kasaurov.

Test is added.

rampitec accepted this revision.Aug 24 2017, 10:41 AM

LGTM, but someone else should approve too.

This revision is now accepted and ready to land.Aug 24 2017, 10:41 AM
kasaurov accepted this revision.Aug 24 2017, 10:52 AM

The test looks fine to me.

dberris accepted this revision.Aug 27 2017, 5:24 PM

LGTM

This revision was automatically updated to reflect the committed changes.