[clang-tools-extra] r202970 - Added a module for checks not related to LLVM or Google coding style.

Alexander Kornienko alexfh at google.com
Wed Mar 5 05:14:32 PST 2014


Author: alexfh
Date: Wed Mar  5 07:14:32 2014
New Revision: 202970

URL: http://llvm.org/viewvc/llvm-project?rev=202970&view=rev
Log:
Added a module for checks not related to LLVM or Google coding style.

Added:
    clang-tools-extra/trunk/clang-tidy/misc/
    clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
    clang-tools-extra/trunk/clang-tidy/misc/Makefile
    clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
Modified:
    clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
    clang-tools-extra/trunk/clang-tidy/Makefile
    clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
    clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
    clang-tools-extra/trunk/clang-tidy/tool/Makefile

Modified: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/CMakeLists.txt?rev=202970&r1=202969&r2=202970&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt Wed Mar  5 07:14:32 2014
@@ -23,3 +23,4 @@ add_clang_library(clangTidy
 add_subdirectory(tool)
 add_subdirectory(llvm)
 add_subdirectory(google)
+add_subdirectory(misc)

Modified: clang-tools-extra/trunk/clang-tidy/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/Makefile?rev=202970&r1=202969&r2=202970&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/Makefile (original)
+++ clang-tools-extra/trunk/clang-tidy/Makefile Wed Mar  5 07:14:32 2014
@@ -11,6 +11,6 @@ CLANG_LEVEL := ../../..
 LIBRARYNAME := clangTidy
 include $(CLANG_LEVEL)/../../Makefile.config
 
-DIRS = llvm google tool
+DIRS = llvm google misc tool
 
 include $(CLANG_LEVEL)/Makefile

Added: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=202970&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (added)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Wed Mar  5 07:14:32 2014
@@ -0,0 +1,11 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_library(clangTidyMiscModule
+  MiscTidyModule.cpp
+
+  LINK_LIBS
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangTidy
+  )

Added: clang-tools-extra/trunk/clang-tidy/misc/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/Makefile?rev=202970&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/Makefile (added)
+++ clang-tools-extra/trunk/clang-tidy/misc/Makefile Wed Mar  5 07:14:32 2014
@@ -0,0 +1,12 @@
+##===- clang-tidy/misc/Makefile ----------------------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+CLANG_LEVEL := ../../../..
+LIBRARYNAME := clangTidyMiscModule
+
+include $(CLANG_LEVEL)/Makefile

Added: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=202970&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Wed Mar  5 07:14:32 2014
@@ -0,0 +1,32 @@
+//===--- MiscTidyModule.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"
+
+namespace clang {
+namespace tidy {
+
+class MiscModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+  }
+};
+
+// Register the MiscTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add<MiscModule>
+X("misc-module", "Adds miscellaneous lint checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the MiscModule.
+volatile int MiscModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang

Modified: clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt?rev=202970&r1=202969&r2=202970&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt Wed Mar  5 07:14:32 2014
@@ -11,6 +11,7 @@ target_link_libraries(clang-tidy
   clangTidy
   clangTidyGoogleModule
   clangTidyLLVMModule
+  clangTidyMiscModule
   clangTooling
   )
 

Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=202970&r1=202969&r2=202970&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Wed Mar  5 07:14:32 2014
@@ -47,11 +47,9 @@ int main(int argc, const char **argv) {
 
   // FIXME: Allow using --list-checks without positional arguments.
   if (ListChecks) {
-    std::vector<std::string> CheckNames =
-        clang::tidy::getCheckNames(Checks, DisableChecks);
     llvm::outs() << "Enabled checks:";
-    for (unsigned i = 0; i < CheckNames.size(); ++i)
-      llvm::outs() << "\n    " << CheckNames[i];
+    for (auto CheckName : clang::tidy::getCheckNames(Checks, DisableChecks))
+      llvm::outs() << "\n    " << CheckName;
     llvm::outs() << "\n\n";
     return 0;
   }
@@ -76,5 +74,9 @@ static int LLVMModuleAnchorDestination =
 extern volatile int GoogleModuleAnchorSource;
 static int GoogleModuleAnchorDestination = GoogleModuleAnchorSource;
 
+// This anchor is used to force the linker to link the MiscModule.
+extern volatile int MiscModuleAnchorSource;
+static int MiscModuleAnchorDestination = MiscModuleAnchorSource;
+
 } // namespace tidy
 } // namespace clang

Modified: clang-tools-extra/trunk/clang-tidy/tool/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/Makefile?rev=202970&r1=202969&r2=202970&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/tool/Makefile (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/Makefile Wed Mar  5 07:14:32 2014
@@ -17,6 +17,7 @@ TOOL_NO_EXPORTS = 1
 include $(CLANG_LEVEL)/../../Makefile.config
 LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
 USEDLIBS = clangTidy.a clangTidyLLVMModule.a clangTidyGoogleModule.a \
+	   clangTidyMiscModule.a \
 	   clangStaticAnalyzerFrontend.a clangStaticAnalyzerCheckers.a \
 	   clangStaticAnalyzerCore.a \
 	   clangFormat.a clangASTMatchers.a clangTooling.a clangFrontend.a \





More information about the cfe-commits mailing list