This is an archive of the discontinued LLVM Phabricator instance.

Implemented clang-tidy-check-specific options.
ClosedPublic

Authored by alexfh on Sep 10 2014, 8:10 AM.

Details

Summary

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.

Diff Detail

Event Timeline

alexfh updated this revision to Diff 13545.Sep 10 2014, 8:10 AM
alexfh retitled this revision from to Implemented clang-tidy-check-specific options..
alexfh updated this object.
alexfh edited the test plan for this revision. (Show Details)
alexfh added reviewers: klimek, bkramer.
alexfh added a subscriber: Unknown Object (MLST).
alexfh updated this revision to Diff 13550.Sep 10 2014, 10:08 AM

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.

klimek added inline comments.Sep 11 2014, 5:35 AM
clang-tidy/ClangTidy.h
99–100

or *it* has been overridden?

104–150

I think those should go somewhere else.

I'd vote for free-standing functions...

clang-tidy/llvm/NamespaceCommentCheck.cpp
21–28

\o/

alexfh added inline comments.Sep 11 2014, 6:40 AM
clang-tidy/ClangTidy.h
99–100

Done.

104–150

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.

alexfh updated this revision to Diff 13591.Sep 11 2014, 10:40 AM

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?

klimek accepted this revision.Sep 12 2014, 1:01 AM
klimek edited edge metadata.

LG

This revision is now accepted and ready to land.Sep 12 2014, 1:01 AM
alexfh closed this revision.Sep 12 2014, 2:03 AM