Page MenuHomePhabricator

[clang-tidy][NFC] Added convienence methods for getting optional options

Authored by njames93 on Jul 28 2020, 5:59 PM.



These methods abstract away Error handling when trying to read options that can't be parsed by logging the error automatically and returning None.

Diff Detail

Event Timeline

njames93 created this revision.Jul 28 2020, 5:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2020, 5:59 PM
njames93 requested review of this revision.Jul 28 2020, 5:59 PM
njames93 updated this revision to Diff 281433.Jul 28 2020, 6:00 PM

Fix wrong patch diff

gribozavr2 added inline comments.Jul 28 2020, 9:57 PM

Is this specialization defined only because parsing a string option can never fail? I'd let this special case behavior fall out of the primary template if possible.


"logIfOptionParsingError" to express the conditionality of behavior?

njames93 updated this revision to Diff 281492.Jul 29 2020, 3:10 AM

Rename logOptionParsingError

njames93 marked an inline comment as done.Jul 29 2020, 3:13 AM
njames93 added inline comments.

It's because the call to get that returns a std::string isn't a template.
So in the actual template definition of getOptional, trying to call get<T> when T is a std::string results in a compile time error.
Consuming the error makes sense knowing the it will always be a MissingOptionError

gribozavr2 accepted this revision.Jul 29 2020, 4:26 AM
This revision is now accepted and ready to land.Jul 29 2020, 4:26 AM
njames93 updated this revision to Diff 281752.Jul 29 2020, 3:31 PM

Revert to using warning for logging parsing errors

This revision was landed with ongoing or failed builds.Jul 31 2020, 5:46 PM
This revision was automatically updated to reflect the committed changes.