2015-08-14 21:17:11 +08:00
|
|
|
//===--- ModernizeTidyModule.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"
|
2016-05-13 04:06:04 +08:00
|
|
|
#include "AvoidBindCheck.h"
|
2016-02-24 21:36:34 +08:00
|
|
|
#include "DeprecatedHeadersCheck.h"
|
2015-08-19 17:11:46 +08:00
|
|
|
#include "LoopConvertCheck.h"
|
2016-05-03 00:56:39 +08:00
|
|
|
#include "MakeSharedCheck.h"
|
2015-09-29 17:36:41 +08:00
|
|
|
#include "MakeUniqueCheck.h"
|
2015-08-14 21:17:11 +08:00
|
|
|
#include "PassByValueCheck.h"
|
2016-03-28 00:43:44 +08:00
|
|
|
#include "RawStringLiteralCheck.h"
|
2015-10-28 09:36:20 +08:00
|
|
|
#include "RedundantVoidArgCheck.h"
|
2015-08-25 21:03:43 +08:00
|
|
|
#include "ReplaceAutoPtrCheck.h"
|
2017-04-24 17:27:20 +08:00
|
|
|
#include "ReplaceRandomShuffleCheck.h"
|
2017-02-16 01:06:06 +08:00
|
|
|
#include "ReturnBracedInitListCheck.h"
|
2015-08-31 21:17:43 +08:00
|
|
|
#include "ShrinkToFitCheck.h"
|
2017-07-12 21:43:35 +08:00
|
|
|
#include "UnaryStaticAssertCheck.h"
|
2015-08-21 23:08:51 +08:00
|
|
|
#include "UseAutoCheck.h"
|
2016-05-11 19:33:16 +08:00
|
|
|
#include "UseBoolLiteralsCheck.h"
|
2016-12-21 05:26:07 +08:00
|
|
|
#include "UseDefaultMemberInitCheck.h"
|
2016-06-21 23:23:27 +08:00
|
|
|
#include "UseEmplaceCheck.h"
|
2016-12-02 01:24:42 +08:00
|
|
|
#include "UseEqualsDefaultCheck.h"
|
2016-11-11 00:46:59 +08:00
|
|
|
#include "UseEqualsDeleteCheck.h"
|
[clang-tidy] New checker to replace dynamic exception specifications
Summary:
New checker to replace dynamic exception
specifications
This is an alternative to D18575 which relied on reparsing the decl to
find the location of dynamic exception specifications, but couldn't
deal with preprocessor conditionals correctly without reparsing the
entire file.
This approach uses D20428 to find dynamic exception specification
locations and handles all cases correctly.
Reviewers: aaron.ballman, alexfh
Reviewed By: aaron.ballman, alexfh
Subscribers: xazax.hun, mgehre, malcolm.parsons, mgorny, JDevlieghere, cfe-commits, Eugene.Zelenko, etienneb
Patch by Don Hinton!
Differential Revision: https://reviews.llvm.org/D20693
llvm-svn: 304977
2017-06-08 22:04:16 +08:00
|
|
|
#include "UseNoexceptCheck.h"
|
2015-08-20 06:21:37 +08:00
|
|
|
#include "UseNullptrCheck.h"
|
2015-08-31 21:17:43 +08:00
|
|
|
#include "UseOverrideCheck.h"
|
2016-11-16 22:42:10 +08:00
|
|
|
#include "UseTransparentFunctorsCheck.h"
|
2016-06-26 02:37:53 +08:00
|
|
|
#include "UseUsingCheck.h"
|
2015-08-14 21:17:11 +08:00
|
|
|
|
|
|
|
using namespace clang::ast_matchers;
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace tidy {
|
|
|
|
namespace modernize {
|
|
|
|
|
|
|
|
class ModernizeModule : public ClangTidyModule {
|
|
|
|
public:
|
|
|
|
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
|
2016-11-08 15:50:19 +08:00
|
|
|
CheckFactories.registerCheck<AvoidBindCheck>("modernize-avoid-bind");
|
2016-02-24 21:36:34 +08:00
|
|
|
CheckFactories.registerCheck<DeprecatedHeadersCheck>(
|
|
|
|
"modernize-deprecated-headers");
|
2015-08-19 17:11:46 +08:00
|
|
|
CheckFactories.registerCheck<LoopConvertCheck>("modernize-loop-convert");
|
2016-05-03 00:56:39 +08:00
|
|
|
CheckFactories.registerCheck<MakeSharedCheck>("modernize-make-shared");
|
2015-10-21 20:58:15 +08:00
|
|
|
CheckFactories.registerCheck<MakeUniqueCheck>("modernize-make-unique");
|
2015-08-14 21:17:11 +08:00
|
|
|
CheckFactories.registerCheck<PassByValueCheck>("modernize-pass-by-value");
|
2016-03-28 00:43:44 +08:00
|
|
|
CheckFactories.registerCheck<RawStringLiteralCheck>(
|
|
|
|
"modernize-raw-string-literal");
|
2015-10-28 09:36:20 +08:00
|
|
|
CheckFactories.registerCheck<RedundantVoidArgCheck>(
|
|
|
|
"modernize-redundant-void-arg");
|
2015-08-25 21:03:43 +08:00
|
|
|
CheckFactories.registerCheck<ReplaceAutoPtrCheck>(
|
|
|
|
"modernize-replace-auto-ptr");
|
2017-04-24 17:27:20 +08:00
|
|
|
CheckFactories.registerCheck<ReplaceRandomShuffleCheck>(
|
|
|
|
"modernize-replace-random-shuffle");
|
2017-02-16 01:06:06 +08:00
|
|
|
CheckFactories.registerCheck<ReturnBracedInitListCheck>(
|
|
|
|
"modernize-return-braced-init-list");
|
2015-08-31 21:17:43 +08:00
|
|
|
CheckFactories.registerCheck<ShrinkToFitCheck>("modernize-shrink-to-fit");
|
2017-07-12 21:43:35 +08:00
|
|
|
CheckFactories.registerCheck<UnaryStaticAssertCheck>(
|
|
|
|
"modernize-unary-static-assert");
|
2015-08-21 23:08:51 +08:00
|
|
|
CheckFactories.registerCheck<UseAutoCheck>("modernize-use-auto");
|
2016-05-11 19:33:16 +08:00
|
|
|
CheckFactories.registerCheck<UseBoolLiteralsCheck>(
|
|
|
|
"modernize-use-bool-literals");
|
2016-12-21 05:26:07 +08:00
|
|
|
CheckFactories.registerCheck<UseDefaultMemberInitCheck>(
|
|
|
|
"modernize-use-default-member-init");
|
2016-06-21 23:23:27 +08:00
|
|
|
CheckFactories.registerCheck<UseEmplaceCheck>("modernize-use-emplace");
|
2016-12-02 01:24:42 +08:00
|
|
|
CheckFactories.registerCheck<UseEqualsDefaultCheck>("modernize-use-equals-default");
|
2016-11-11 00:46:59 +08:00
|
|
|
CheckFactories.registerCheck<UseEqualsDeleteCheck>(
|
|
|
|
"modernize-use-equals-delete");
|
[clang-tidy] New checker to replace dynamic exception specifications
Summary:
New checker to replace dynamic exception
specifications
This is an alternative to D18575 which relied on reparsing the decl to
find the location of dynamic exception specifications, but couldn't
deal with preprocessor conditionals correctly without reparsing the
entire file.
This approach uses D20428 to find dynamic exception specification
locations and handles all cases correctly.
Reviewers: aaron.ballman, alexfh
Reviewed By: aaron.ballman, alexfh
Subscribers: xazax.hun, mgehre, malcolm.parsons, mgorny, JDevlieghere, cfe-commits, Eugene.Zelenko, etienneb
Patch by Don Hinton!
Differential Revision: https://reviews.llvm.org/D20693
llvm-svn: 304977
2017-06-08 22:04:16 +08:00
|
|
|
CheckFactories.registerCheck<UseNoexceptCheck>("modernize-use-noexcept");
|
2015-08-20 06:21:37 +08:00
|
|
|
CheckFactories.registerCheck<UseNullptrCheck>("modernize-use-nullptr");
|
2015-08-31 21:17:43 +08:00
|
|
|
CheckFactories.registerCheck<UseOverrideCheck>("modernize-use-override");
|
2016-11-16 22:42:10 +08:00
|
|
|
CheckFactories.registerCheck<UseTransparentFunctorsCheck>(
|
|
|
|
"modernize-use-transparent-functors");
|
2016-06-26 02:37:53 +08:00
|
|
|
CheckFactories.registerCheck<UseUsingCheck>("modernize-use-using");
|
2015-08-14 21:17:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ClangTidyOptions getModuleOptions() override {
|
|
|
|
ClangTidyOptions Options;
|
|
|
|
auto &Opts = Options.CheckOptions;
|
2015-10-30 17:37:57 +08:00
|
|
|
// For types whose size in bytes is above this threshold, we prefer taking a
|
|
|
|
// const-reference than making a copy.
|
|
|
|
Opts["modernize-loop-convert.MaxCopySize"] = "16";
|
|
|
|
|
2015-08-19 17:11:46 +08:00
|
|
|
Opts["modernize-loop-convert.MinConfidence"] = "reasonable";
|
2015-09-25 01:02:19 +08:00
|
|
|
Opts["modernize-loop-convert.NamingStyle"] = "CamelCase";
|
2015-10-21 20:58:15 +08:00
|
|
|
Opts["modernize-pass-by-value.IncludeStyle"] = "llvm"; // Also: "google".
|
2015-08-25 21:03:43 +08:00
|
|
|
Opts["modernize-replace-auto-ptr.IncludeStyle"] = "llvm"; // Also: "google".
|
2015-08-20 06:21:37 +08:00
|
|
|
|
|
|
|
// Comma-separated list of macros that behave like NULL.
|
|
|
|
Opts["modernize-use-nullptr.NullMacros"] = "NULL";
|
2015-08-14 21:17:11 +08:00
|
|
|
return Options;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Register the ModernizeTidyModule using this statically initialized variable.
|
|
|
|
static ClangTidyModuleRegistry::Add<ModernizeModule> X("modernize-module",
|
|
|
|
"Add modernize checks.");
|
|
|
|
|
|
|
|
} // namespace modernize
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link in the generated object file
|
|
|
|
// and thus register the ModernizeModule.
|
|
|
|
volatile int ModernizeModuleAnchorSource = 0;
|
|
|
|
|
|
|
|
} // namespace tidy
|
|
|
|
} // namespace clang
|