summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clang-tidy')
-rw-r--r--clang-tools-extra/clang-tidy/google/CMakeLists.txt2
-rw-r--r--clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp11
-rw-r--r--clang-tools-extra/clang-tidy/llvm/CMakeLists.txt2
-rw-r--r--clang-tools-extra/clang-tidy/misc/CMakeLists.txt2
-rw-r--r--clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp11
-rw-r--r--clang-tools-extra/clang-tidy/readability/CMakeLists.txt3
-rw-r--r--clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp44
-rw-r--r--clang-tools-extra/clang-tidy/tool/CMakeLists.txt1
-rw-r--r--clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp4
9 files changed, 62 insertions, 18 deletions
diff --git a/clang-tools-extra/clang-tidy/google/CMakeLists.txt b/clang-tools-extra/clang-tidy/google/CMakeLists.txt
index 7b0912d32e7..bbe9b4d02d8 100644
--- a/clang-tools-extra/clang-tidy/google/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/google/CMakeLists.txt
@@ -20,5 +20,5 @@ add_clang_library(clangTidyGoogleModule
clangBasic
clangLex
clangTidy
- clangTidyReadability
+ clangTidyReadabilityModule
)
diff --git a/clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp b/clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp
index 9ff5caec377..16ebfe577bb 100644
--- a/clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp
@@ -22,7 +22,9 @@
#include "UnnamedNamespaceInHeaderCheck.h"
#include "UsingNamespaceDirectiveCheck.h"
#include "../readability/BracesAroundStatementsCheck.h"
+#include "../readability/FunctionSize.h"
#include "../readability/NamespaceCommentCheck.h"
+#include "../readability/RedundantSmartptrGet.h"
using namespace clang::ast_matchers;
@@ -54,10 +56,14 @@ public:
"google-readability-function");
CheckFactories.registerCheck<readability::TodoCommentCheck>(
"google-readability-todo");
- CheckFactories.registerCheck<readability::NamespaceCommentCheck>(
- "google-readability-namespace-comments");
CheckFactories.registerCheck<readability::BracesAroundStatementsCheck>(
"google-readability-braces-around-statements");
+ CheckFactories.registerCheck<readability::FunctionSizeCheck>(
+ "google-readability-function-size");
+ CheckFactories.registerCheck<readability::NamespaceCommentCheck>(
+ "google-readability-namespace-comments");
+ CheckFactories.registerCheck<readability::RedundantSmartptrGet>(
+ "google-readability-redundant-smartptr-get");
}
ClangTidyOptions getModuleOptions() override {
@@ -65,6 +71,7 @@ public:
auto &Opts = Options.CheckOptions;
Opts["google-readability-braces-around-statements.ShortStatementLines"] =
"1";
+ Opts["google-readability-function-size.StatementThreshold"] = "800";
Opts["google-readability-namespace-comments.ShortNamespaceLines"] = "1";
Opts["google-readability-namespace-comments.SpacesBeforeComments"] = "2";
return Options;
diff --git a/clang-tools-extra/clang-tidy/llvm/CMakeLists.txt b/clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
index 360e9308e90..ce69c05f349 100644
--- a/clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
@@ -12,7 +12,7 @@ add_clang_library(clangTidyLLVMModule
clangBasic
clangLex
clangTidy
- clangTidyReadability
+ clangTidyReadabilityModule
clangTidyUtils
clangTooling
)
diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
index abedee91ace..ef29603e701 100644
--- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -15,6 +15,4 @@ add_clang_library(clangTidyMiscModule
clangBasic
clangLex
clangTidy
- # Some readability checks are currently registered in the misc module.
- clangTidyReadability
)
diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
index c2220b6e464..d4ba1db7a7c 100644
--- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
@@ -10,11 +10,6 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
-// FIXME: Figure out if we want to create a separate module for readability
-// checks instead of registering them here.
-#include "../readability/BracesAroundStatementsCheck.h"
-#include "../readability/FunctionSize.h"
-#include "../readability/RedundantSmartptrGet.h"
#include "ArgumentCommentCheck.h"
#include "BoolPointerImplicitConversion.h"
#include "SwappedArgumentsCheck.h"
@@ -31,12 +26,6 @@ public:
CheckFactories.registerCheck<ArgumentCommentCheck>("misc-argument-comment");
CheckFactories.registerCheck<BoolPointerImplicitConversion>(
"misc-bool-pointer-implicit-conversion");
- CheckFactories.registerCheck<readability::BracesAroundStatementsCheck>(
- "misc-braces-around-statements");
- CheckFactories.registerCheck<readability::FunctionSizeCheck>(
- "misc-function-size");
- CheckFactories.registerCheck<readability::RedundantSmartptrGet>(
- "misc-redundant-smartptr-get");
CheckFactories.registerCheck<SwappedArgumentsCheck>(
"misc-swapped-arguments");
CheckFactories.registerCheck<UndelegatedConstructorCheck>(
diff --git a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
index edbeb1fb39a..cf1248c196a 100644
--- a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
@@ -1,9 +1,10 @@
set(LLVM_LINK_COMPONENTS support)
-add_clang_library(clangTidyReadability
+add_clang_library(clangTidyReadabilityModule
BracesAroundStatementsCheck.cpp
FunctionSize.cpp
NamespaceCommentCheck.cpp
+ ReadabilityTidyModule.cpp
RedundantSmartptrGet.cpp
LINK_LIBS
diff --git a/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp b/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
new file mode 100644
index 00000000000..9e7187573c9
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -0,0 +1,44 @@
+//===--- ReadabilityTidyModule.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"
+#include "BracesAroundStatementsCheck.h"
+#include "FunctionSize.h"
+#include "RedundantSmartptrGet.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+class ReadabilityModule : public ClangTidyModule {
+public:
+ void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+ CheckFactories.registerCheck<BracesAroundStatementsCheck>(
+ "readability-braces-around-statements");
+ CheckFactories.registerCheck<FunctionSizeCheck>(
+ "readability-function-size");
+ CheckFactories.registerCheck<RedundantSmartptrGet>(
+ "readability-redundant-smartptr-get");
+ }
+};
+
+} // namespace readability
+
+// Register the MiscTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<readability::ReadabilityModule>
+X("readability-module", "Adds readability-related checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the MiscModule.
+volatile int ReadabilityModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
diff --git a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt
index a4f20854f7f..a20dcb714bd 100644
--- a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt
@@ -12,6 +12,7 @@ target_link_libraries(clang-tidy
clangTidyGoogleModule
clangTidyLLVMModule
clangTidyMiscModule
+ clangTidyReadabilityModule
clangTooling
)
diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 72d841e3f63..01de2e0902d 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -302,6 +302,10 @@ static int GoogleModuleAnchorDestination = GoogleModuleAnchorSource;
extern volatile int MiscModuleAnchorSource;
static int MiscModuleAnchorDestination = MiscModuleAnchorSource;
+// This anchor is used to force the linker to link the ReadabilityModule.
+extern volatile int ReadabilityModuleAnchorSource;
+static int ReadabilityModuleAnchorDestination = ReadabilityModuleAnchorSource;
+
} // namespace tidy
} // namespace clang
OpenPOWER on IntegriCloud