Each check can implement readOptions and storeOptions methods to read
and store custom options. Each check's options are stored in a local namespace
to avoid name collisions and provide some sort of context to the user.
Details
Diff Detail
Event Timeline
This is another variant of doing the same. Here we pass check name and context
via constructor arguments. This way we need to delegate the corresponding
constructor in each check, but we reduce the ClangTidyCheck API significantly
and allow getting options in the constructor, which is more straightforward.
clang-tidy/ClangTidy.h | ||
---|---|---|
149–150 | Done. | |
154–200 | These functions call ClangTidyCheck::getQualifiedOptionName which otherwise would need to be called from the user code: ... : ShortNamespaceLines(getOption<unsigned>(getQualifiedOptionName("ShortNamespaceLines"), 1u)), SpacesBeforeComments(getOption<unsigned>(getQualifiedOptionName("SpacesBeforeComments"), 1u)) ... IMO, we need to reduce boilerplate code here as much as we can. |
An alternative way to access options in the checks: use a separate OptionsView
class that accepts the check name and appends it to the check-local option name
to get the real option name.
WDYT?
or *it* has been overridden?