2013-07-29 16:19:24 +08:00
|
|
|
//===--- ClangTidyModule.h - clang-tidy -------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-07-29 16:19:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-03-10 00:52:33 +08:00
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYMODULE_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYMODULE_H
|
2013-07-29 16:19:24 +08:00
|
|
|
|
|
|
|
#include "ClangTidy.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2014-09-10 19:25:43 +08:00
|
|
|
#include <functional>
|
|
|
|
#include <map>
|
2019-09-26 21:47:29 +08:00
|
|
|
#include <memory>
|
2014-09-10 19:25:43 +08:00
|
|
|
#include <string>
|
2013-07-29 16:19:24 +08:00
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace tidy {
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// A collection of \c ClangTidyCheckFactory instances.
|
2013-07-29 16:19:24 +08:00
|
|
|
///
|
|
|
|
/// All clang-tidy modules register their check factories with an instance of
|
|
|
|
/// this object.
|
|
|
|
class ClangTidyCheckFactories {
|
|
|
|
public:
|
2019-09-26 21:47:29 +08:00
|
|
|
using CheckFactory = std::function<std::unique_ptr<ClangTidyCheck>(
|
|
|
|
StringRef Name, ClangTidyContext *Context)>;
|
2014-09-12 16:53:36 +08:00
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Registers check \p Factory with name \p Name.
|
2014-09-10 19:25:43 +08:00
|
|
|
///
|
|
|
|
/// For all checks that have default constructors, use \c registerCheck.
|
2014-09-12 16:53:36 +08:00
|
|
|
void registerCheckFactory(StringRef Name, CheckFactory Factory);
|
2014-09-10 19:06:43 +08:00
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Registers the \c CheckType with the name \p Name.
|
2014-09-10 19:25:43 +08:00
|
|
|
///
|
|
|
|
/// This method should be used for all \c ClangTidyChecks that don't require
|
|
|
|
/// constructor parameters.
|
|
|
|
///
|
|
|
|
/// For example, if have a clang-tidy check like:
|
|
|
|
/// \code
|
|
|
|
/// class MyTidyCheck : public ClangTidyCheck {
|
|
|
|
/// void registerMatchers(ast_matchers::MatchFinder *Finder) override {
|
|
|
|
/// ..
|
|
|
|
/// }
|
|
|
|
/// };
|
|
|
|
/// \endcode
|
|
|
|
/// you can register it with:
|
|
|
|
/// \code
|
|
|
|
/// class MyModule : public ClangTidyModule {
|
|
|
|
/// void addCheckFactories(ClangTidyCheckFactories &Factories) override {
|
|
|
|
/// Factories.registerCheck<MyTidyCheck>("myproject-my-check");
|
|
|
|
/// }
|
|
|
|
/// };
|
|
|
|
/// \endcode
|
2014-09-12 16:53:36 +08:00
|
|
|
template <typename CheckType> void registerCheck(StringRef CheckName) {
|
|
|
|
registerCheckFactory(CheckName,
|
|
|
|
[](StringRef Name, ClangTidyContext *Context) {
|
2019-09-26 21:47:29 +08:00
|
|
|
return std::make_unique<CheckType>(Name, Context);
|
2016-11-08 15:50:19 +08:00
|
|
|
});
|
2014-09-10 19:06:43 +08:00
|
|
|
}
|
2013-07-29 16:19:24 +08:00
|
|
|
|
2019-09-26 21:55:01 +08:00
|
|
|
/// Create instances of checks that are enabled.
|
|
|
|
std::vector<std::unique_ptr<ClangTidyCheck>>
|
|
|
|
createChecks(ClangTidyContext *Context);
|
2013-07-29 16:19:24 +08:00
|
|
|
|
2014-09-12 16:53:36 +08:00
|
|
|
typedef std::map<std::string, CheckFactory> FactoryMap;
|
Clang-tidy: added --disable-checks, --list-checks options.
Summary:
Allow disabling checks by regex. By default, disable alpha.* checks,
that are not particularly good tested (e.g. IdempotentOperationChecker, see
http://llvm-reviews.chandlerc.com/D2427).
Fixed a bug, that would disable all analyzer checks, when using a regex more
strict, than 'clang-analyzer-', for example --checks='clang-analyzer-deadcode-'.
Added --list-checks to list all enabled checks. This is useful to test specific
values in --checks/--disable-checks.
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D2444
llvm-svn: 197717
2013-12-20 03:57:05 +08:00
|
|
|
FactoryMap::const_iterator begin() const { return Factories.begin(); }
|
|
|
|
FactoryMap::const_iterator end() const { return Factories.end(); }
|
2014-02-14 00:10:47 +08:00
|
|
|
bool empty() const { return Factories.empty(); }
|
Clang-tidy: added --disable-checks, --list-checks options.
Summary:
Allow disabling checks by regex. By default, disable alpha.* checks,
that are not particularly good tested (e.g. IdempotentOperationChecker, see
http://llvm-reviews.chandlerc.com/D2427).
Fixed a bug, that would disable all analyzer checks, when using a regex more
strict, than 'clang-analyzer-', for example --checks='clang-analyzer-deadcode-'.
Added --list-checks to list all enabled checks. This is useful to test specific
values in --checks/--disable-checks.
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D2444
llvm-svn: 197717
2013-12-20 03:57:05 +08:00
|
|
|
|
2013-07-29 16:19:24 +08:00
|
|
|
private:
|
Clang-tidy: added --disable-checks, --list-checks options.
Summary:
Allow disabling checks by regex. By default, disable alpha.* checks,
that are not particularly good tested (e.g. IdempotentOperationChecker, see
http://llvm-reviews.chandlerc.com/D2427).
Fixed a bug, that would disable all analyzer checks, when using a regex more
strict, than 'clang-analyzer-', for example --checks='clang-analyzer-deadcode-'.
Added --list-checks to list all enabled checks. This is useful to test specific
values in --checks/--disable-checks.
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D2444
llvm-svn: 197717
2013-12-20 03:57:05 +08:00
|
|
|
FactoryMap Factories;
|
2013-07-29 16:19:24 +08:00
|
|
|
};
|
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// A clang-tidy module groups a number of \c ClangTidyChecks and gives
|
2014-09-10 19:25:43 +08:00
|
|
|
/// them a prefixed name.
|
|
|
|
class ClangTidyModule {
|
|
|
|
public:
|
2015-10-21 05:45:52 +08:00
|
|
|
virtual ~ClangTidyModule() {}
|
2014-09-10 19:25:43 +08:00
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Implement this function in order to register all \c CheckFactories
|
2014-09-10 19:25:43 +08:00
|
|
|
/// belonging to this module.
|
|
|
|
virtual void addCheckFactories(ClangTidyCheckFactories &CheckFactories) = 0;
|
2014-10-16 19:27:57 +08:00
|
|
|
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// Gets default options for checks defined in this module.
|
2014-10-16 19:27:57 +08:00
|
|
|
virtual ClangTidyOptions getModuleOptions();
|
2014-09-10 19:25:43 +08:00
|
|
|
};
|
|
|
|
|
2013-07-29 16:19:24 +08:00
|
|
|
} // end namespace tidy
|
|
|
|
} // end namespace clang
|
|
|
|
|
2015-03-10 00:52:33 +08:00
|
|
|
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYMODULE_H
|