Index: clang-tidy/CMakeLists.txt =================================================================== --- clang-tidy/CMakeLists.txt +++ clang-tidy/CMakeLists.txt @@ -37,6 +37,7 @@ add_subdirectory(misc) add_subdirectory(modernize) add_subdirectory(mpi) +add_subdirectory(objc) add_subdirectory(performance) add_subdirectory(plugin) add_subdirectory(readability) Index: clang-tidy/objc/CMakeLists.txt =================================================================== --- /dev/null +++ clang-tidy/objc/CMakeLists.txt @@ -0,0 +1,14 @@ +set(LLVM_LINK_COMPONENTS support) + +add_clang_library(clangTidyObjCModule + ObjCTidyModule.cpp + + LINK_LIBS + clangAST + clangASTMatchers + clangBasic + clangLex + clangTidy + clangTidyReadabilityModule + clangTidyUtils + ) Index: clang-tidy/objc/ObjCTidyModule.cpp =================================================================== --- /dev/null +++ clang-tidy/objc/ObjCTidyModule.cpp @@ -0,0 +1,39 @@ +//===--- ObjCTidyModule.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" + +using namespace clang::ast_matchers; + +namespace clang { +namespace tidy { +namespace objc { + +class ObjCModule : public ClangTidyModule { +public: + void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { + // TODO(D39142): Add checks here. + } +}; + +// Register the ObjCTidyModule using this statically initialized variable. +static ClangTidyModuleRegistry::Add X( + "objc-module", + "Adds Objective-C lint checks."); + +} // namespace objc + +// This anchor is used to force the linker to link in the generated object file +// and thus register the ObjCModule. +volatile int ObjCModuleAnchorSource = 0; + +} // namespace tidy +} // namespace clang Index: clang-tidy/plugin/CMakeLists.txt =================================================================== --- clang-tidy/plugin/CMakeLists.txt +++ clang-tidy/plugin/CMakeLists.txt @@ -17,6 +17,7 @@ clangTidyMiscModule clangTidyModernizeModule clangTidyMPIModule + clangTidyObjCModule clangTidyPerformanceModule clangTidyReadabilityModule clangTooling Index: clang-tidy/tool/CMakeLists.txt =================================================================== --- clang-tidy/tool/CMakeLists.txt +++ clang-tidy/tool/CMakeLists.txt @@ -27,6 +27,7 @@ clangTidyMiscModule clangTidyModernizeModule clangTidyMPIModule + clangTidyObjCModule clangTidyPerformanceModule clangTidyReadabilityModule clangTooling Index: docs/ReleaseNotes.rst =================================================================== --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -57,6 +57,8 @@ Improvements to clang-tidy -------------------------- +- New module `objc` for Objective-C style checks. + - Renamed checks to use correct term "implicit conversion" instead of "implicit cast" and modified messages and option names accordingly: Index: docs/clang-tidy/index.rst =================================================================== --- docs/clang-tidy/index.rst +++ docs/clang-tidy/index.rst @@ -68,6 +68,7 @@ ``modernize-`` Checks that advocate usage of modern (currently "modern" means "C++11") language constructs. ``mpi-`` Checks related to MPI (Message Passing Interface). +``objc-`` Checks related to Objective-C coding conventions. ``performance-`` Checks that target performance-related issues. ``readability-`` Checks that target readability-related issues that don't relate to any particular coding style. @@ -341,6 +342,11 @@ |-- LLVMTidyModule.cpp |-- LLVMTidyModule.h ... + |-- objc/ # Objective-C clang-tidy module. + |-+ + |-- ObjCTidyModule.cpp + |-- ObjCTidyModule.h + ... |-- tool/ # Sources of the clang-tidy binary. ... test/clang-tidy/ # Integration tests. @@ -349,6 +355,7 @@ |-- ClangTidyTest.h |-- GoogleModuleTest.cpp |-- LLVMModuleTest.cpp + |-- ObjCModuleTest.cpp ... Index: unittests/clang-tidy/CMakeLists.txt =================================================================== --- unittests/clang-tidy/CMakeLists.txt +++ unittests/clang-tidy/CMakeLists.txt @@ -14,6 +14,7 @@ LLVMModuleTest.cpp MiscModuleTest.cpp NamespaceAliaserTest.cpp + ObjCModuleTest.cpp OverlappingReplacementsTest.cpp UsingInserterTest.cpp ReadabilityModuleTest.cpp) @@ -29,6 +30,7 @@ clangTidyGoogleModule clangTidyLLVMModule clangTidyMiscModule + clangTidyObjCModule clangTidyReadabilityModule clangTidyUtils clangTooling Index: unittests/clang-tidy/ObjCModuleTest.cpp =================================================================== --- /dev/null +++ unittests/clang-tidy/ObjCModuleTest.cpp @@ -0,0 +1,12 @@ +#include "ClangTidyTest.h" +#include "gtest/gtest.h" + +namespace clang { +namespace tidy { +namespace test { + +// TODO(D39142) Add unit tests for the ObjC module here once a check lands. + +} // namespace test +} // namespace tidy +} // namespace clang