Page MenuHomePhabricator

[clang-tidy] Allow `TransformerClangTidyCheck` clients to set the rule directly.

Authored by ymandel on Nov 16 2020, 7:48 AM.



Adds support for setting the Rule field. In the process, refactors the code that accesses that field and adds a constructor that doesn't require a rule argument.

This feature is needed by checks that must set the rule *after* the check class
is constructed. For example, any check that maintains state to be accessed from
the rule needs this support. Since the object's fields are not initialized when
the superclass constructor is called, they can't be (safely) captured by a rule
passed to the existing constructor. This patch allows constructing the check
superclass fully before setting the rule.

As a driveby fix, removed the "optional" from the rule, since rules are just a
set of cases, so empty rules are evident.

Diff Detail

Event Timeline

ymandel created this revision.Nov 16 2020, 7:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 16 2020, 7:48 AM
Herald added a subscriber: xazax.hun. · View Herald Transcript
ymandel requested review of this revision.Nov 16 2020, 7:48 AM
gribozavr2 accepted this revision.Nov 18 2020, 8:03 AM
This revision is now accepted and ready to land.Nov 18 2020, 8:03 AM
tdl-g accepted this revision.Nov 18 2020, 9:45 AM