[cfe-dev] [clang-tidy] multiple declaration statement check contribution

Firat Kasmis via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 24 04:41:33 PDT 2016


As far as I can see, the check does not include any FixItHint yet that I
have already implemented for most of the cases. Kirill is it OK for you, if
I keep continuing this and provide a patch?

Regarding differences between CERT and CppCore:
How about providing a general readability-checker that splits up any
init-declarator list into single init-declarators? Then, we may provide
"pseudo" cert-one-name-per-declaration and cppcore-one-name-per-declaration
checks which will register the general readability checker and use Options
to pass the config paramer (cert and cppcore) to the general check.

Something like:

// ReadabilityTidyModule.cpp
CheckFactories.registerCheck<OneNamePerDeclarationCheck>("readability-one-name-per-declaration");

// CERTTidyModule.cpp
CheckFactories.registerCheck<readability::OneNamePerDeclarationCheck>("cert-one-name-per-declaration");

ClangTidyOptions getModuleOptions() override {
    ClangTidyOptions Options;
    auto &Opts = Options.CheckOptions;
    Opts["cert-one-name-per-declaration.style"] = "cert";
    return Options;
}

// CppCoreGuidelinesModule.cpp
CheckFactories.registerCheck<readability::OneNamePerDeclarationCheck>("cppcoreguidelines-one-name-per-declaration");

ClangTidyOptions getModuleOptions() override {
    ClangTidyOptions Options;
    auto &Opts = Options.CheckOptions;
    Opts["cert-one-name-per-declaration.style"] = "ccpcore";
    return Options;
}

Any thoughts on this?



2016-10-21 17:18 GMT+02:00 Malcolm Parsons <malcolm.parsons at gmail.com>:

> On 21 October 2016 at 16:06, Firat Kasmis via cfe-dev
> <cfe-dev at lists.llvm.org> wrote:
> > I would like to know if there is any need for a readability check that
> > checks for multiple declarations in one statement (init-declarator list.
>
> Kirill Bobyrev is working on one.
> See https://reviews.llvm.org/D25024
>
> --
> Malcolm Parsons
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161024/cace5a42/attachment.html>


More information about the cfe-dev mailing list