2013-07-29 16:19:24 +08:00
|
|
|
//===--- GoogleTidyModule.cpp - clang-tidy --------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "../ClangTidy.h"
|
|
|
|
#include "../ClangTidyModule.h"
|
|
|
|
#include "../ClangTidyModuleRegistry.h"
|
2015-01-14 19:24:38 +08:00
|
|
|
#include "../readability/BracesAroundStatementsCheck.h"
|
2015-03-09 20:18:39 +08:00
|
|
|
#include "../readability/FunctionSizeCheck.h"
|
2015-01-14 19:24:38 +08:00
|
|
|
#include "../readability/NamespaceCommentCheck.h"
|
2015-03-09 20:18:39 +08:00
|
|
|
#include "../readability/RedundantSmartptrGetCheck.h"
|
2014-06-30 06:19:53 +08:00
|
|
|
#include "AvoidCStyleCastsCheck.h"
|
2016-05-09 21:43:58 +08:00
|
|
|
#include "DefaultArgumentsCheck.h"
|
2014-06-18 17:33:46 +08:00
|
|
|
#include "ExplicitConstructorCheck.h"
|
2014-07-15 17:50:32 +08:00
|
|
|
#include "ExplicitMakePairCheck.h"
|
2015-02-12 05:21:05 +08:00
|
|
|
#include "GlobalNamesInHeadersCheck.h"
|
2014-08-29 22:38:46 +08:00
|
|
|
#include "IntegerTypesCheck.h"
|
2014-07-16 22:30:19 +08:00
|
|
|
#include "MemsetZeroLengthCheck.h"
|
2014-07-15 20:48:14 +08:00
|
|
|
#include "OverloadedUnaryAndCheck.h"
|
2016-02-03 01:27:01 +08:00
|
|
|
#include "NonConstReferences.h"
|
2014-07-16 18:00:14 +08:00
|
|
|
#include "StringReferenceMemberCheck.h"
|
2014-09-18 20:53:13 +08:00
|
|
|
#include "TodoCommentCheck.h"
|
2014-07-16 22:16:56 +08:00
|
|
|
#include "UnnamedNamespaceInHeaderCheck.h"
|
|
|
|
#include "UsingNamespaceDirectiveCheck.h"
|
2013-07-29 16:19:24 +08:00
|
|
|
|
|
|
|
using namespace clang::ast_matchers;
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace tidy {
|
2015-03-05 21:46:14 +08:00
|
|
|
namespace google {
|
2013-07-29 16:19:24 +08:00
|
|
|
|
|
|
|
class GoogleModule : public ClangTidyModule {
|
|
|
|
public:
|
2014-03-05 21:01:24 +08:00
|
|
|
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
|
2014-09-10 19:06:43 +08:00
|
|
|
CheckFactories.registerCheck<build::ExplicitMakePairCheck>(
|
|
|
|
"google-build-explicit-make-pair");
|
|
|
|
CheckFactories.registerCheck<build::UnnamedNamespaceInHeaderCheck>(
|
|
|
|
"google-build-namespaces");
|
|
|
|
CheckFactories.registerCheck<build::UsingNamespaceDirectiveCheck>(
|
|
|
|
"google-build-using-namespace");
|
2016-05-09 21:43:58 +08:00
|
|
|
CheckFactories.registerCheck<DefaultArgumentsCheck>(
|
|
|
|
"google-default-arguments");
|
2014-09-10 19:06:43 +08:00
|
|
|
CheckFactories.registerCheck<ExplicitConstructorCheck>(
|
|
|
|
"google-explicit-constructor");
|
|
|
|
CheckFactories.registerCheck<runtime::IntegerTypesCheck>(
|
|
|
|
"google-runtime-int");
|
|
|
|
CheckFactories.registerCheck<runtime::OverloadedUnaryAndCheck>(
|
|
|
|
"google-runtime-operator");
|
2016-02-03 01:27:01 +08:00
|
|
|
CheckFactories.registerCheck<runtime::NonConstReferences>(
|
|
|
|
"google-runtime-references");
|
2014-09-10 19:06:43 +08:00
|
|
|
CheckFactories.registerCheck<runtime::StringReferenceMemberCheck>(
|
|
|
|
"google-runtime-member-string-references");
|
|
|
|
CheckFactories.registerCheck<runtime::MemsetZeroLengthCheck>(
|
|
|
|
"google-runtime-memset");
|
|
|
|
CheckFactories.registerCheck<readability::AvoidCStyleCastsCheck>(
|
|
|
|
"google-readability-casting");
|
2014-09-18 20:53:13 +08:00
|
|
|
CheckFactories.registerCheck<readability::TodoCommentCheck>(
|
|
|
|
"google-readability-todo");
|
2015-03-05 21:46:14 +08:00
|
|
|
CheckFactories
|
|
|
|
.registerCheck<clang::tidy::readability::BracesAroundStatementsCheck>(
|
|
|
|
"google-readability-braces-around-statements");
|
2015-02-12 05:21:05 +08:00
|
|
|
CheckFactories.registerCheck<readability::GlobalNamesInHeadersCheck>(
|
|
|
|
"google-global-names-in-headers");
|
2015-03-05 21:46:14 +08:00
|
|
|
CheckFactories.registerCheck<clang::tidy::readability::FunctionSizeCheck>(
|
2014-10-26 09:41:14 +08:00
|
|
|
"google-readability-function-size");
|
2015-03-05 21:46:14 +08:00
|
|
|
CheckFactories
|
|
|
|
.registerCheck<clang::tidy::readability::NamespaceCommentCheck>(
|
|
|
|
"google-readability-namespace-comments");
|
|
|
|
CheckFactories
|
2015-03-09 20:18:39 +08:00
|
|
|
.registerCheck<clang::tidy::readability::RedundantSmartptrGetCheck>(
|
2015-03-05 21:46:14 +08:00
|
|
|
"google-readability-redundant-smartptr-get");
|
2014-10-16 19:27:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ClangTidyOptions getModuleOptions() override {
|
|
|
|
ClangTidyOptions Options;
|
|
|
|
auto &Opts = Options.CheckOptions;
|
|
|
|
Opts["google-readability-braces-around-statements.ShortStatementLines"] =
|
|
|
|
"1";
|
2014-10-26 09:41:14 +08:00
|
|
|
Opts["google-readability-function-size.StatementThreshold"] = "800";
|
2014-11-20 23:05:32 +08:00
|
|
|
Opts["google-readability-namespace-comments.ShortNamespaceLines"] = "10";
|
2014-10-16 19:27:57 +08:00
|
|
|
Opts["google-readability-namespace-comments.SpacesBeforeComments"] = "2";
|
|
|
|
return Options;
|
2013-07-29 16:19:24 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Register the GoogleTidyModule using this statically initialized variable.
|
|
|
|
static ClangTidyModuleRegistry::Add<GoogleModule> X("google-module",
|
|
|
|
"Adds Google lint checks.");
|
|
|
|
|
2015-03-05 21:46:14 +08:00
|
|
|
} // namespace google
|
|
|
|
|
2013-07-29 16:19:24 +08:00
|
|
|
// This anchor is used to force the linker to link in the generated object file
|
|
|
|
// and thus register the GoogleModule.
|
|
|
|
volatile int GoogleModuleAnchorSource = 0;
|
|
|
|
|
|
|
|
} // namespace tidy
|
|
|
|
} // namespace clang
|