Index: clang-tools-extra/clang-tidy/CMakeLists.txt =================================================================== --- clang-tools-extra/clang-tidy/CMakeLists.txt +++ clang-tools-extra/clang-tidy/CMakeLists.txt @@ -73,6 +73,7 @@ add_subdirectory(performance) add_subdirectory(portability) add_subdirectory(readability) +add_subdirectory(concurrent) add_subdirectory(zircon) set(ALL_CLANG_TIDY_CHECKS clangTidyAndroidModule @@ -81,6 +82,7 @@ clangTidyBoostModule clangTidyBugproneModule clangTidyCERTModule + clangTidyConcurrentModule clangTidyCppCoreGuidelinesModule clangTidyDarwinModule clangTidyFuchsiaModule Index: clang-tools-extra/clang-tidy/ClangTidyForceLinker.h =================================================================== --- clang-tools-extra/clang-tidy/ClangTidyForceLinker.h +++ clang-tools-extra/clang-tidy/ClangTidyForceLinker.h @@ -45,6 +45,11 @@ static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination = CERTModuleAnchorSource; +// This anchor is used to force the linker to link the ConcurrentModule. +extern volatile int ConcurrentModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED ConcurrentModuleAnchorDestination = + ConcurrentModuleAnchorSource; + // This anchor is used to force the linker to link the CppCoreGuidelinesModule. extern volatile int CppCoreGuidelinesModuleAnchorSource; static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination = Index: clang-tools-extra/clang-tidy/concurrent/CMakeLists.txt =================================================================== --- /dev/null +++ clang-tools-extra/clang-tidy/concurrent/CMakeLists.txt @@ -0,0 +1,23 @@ +set(LLVM_LINK_COMPONENTS + FrontendOpenMP + Support + ) + +add_clang_library(clangTidyConcurrentModule + ConcurrentTidyModule.cpp + + LINK_LIBS + clangTidy + clangTidyUtils + ) + +clang_target_link_libraries(clangTidyConcurrentModule + PRIVATE + clangAnalysis + clangAST + clangASTMatchers + clangBasic + clangLex + clangSerialization + clangTooling + ) Index: clang-tools-extra/clang-tidy/concurrent/ConcurrentTidyModule.cpp =================================================================== --- /dev/null +++ clang-tools-extra/clang-tidy/concurrent/ConcurrentTidyModule.cpp @@ -0,0 +1,33 @@ +//===--- ConcurrentTidyModule.cpp - clang-tidy ----------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "../ClangTidy.h" +#include "../ClangTidyModule.h" +#include "../ClangTidyModuleRegistry.h" + +namespace clang { +namespace tidy { +namespace concurrent { + +class ConcurrentModule : public ClangTidyModule { +public: + void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {} +}; + +} // namespace concurrent + +// Register the ConcurrentTidyModule using this statically initialized variable. +static ClangTidyModuleRegistry::Add + X("concurrent-module", "Adds concurrent checks."); + +// This anchor is used to force the linker to link in the generated object file +// and thus register the ConcurrentModule. +volatile int ConcurrentModuleAnchorSource = 0; + +} // namespace tidy +} // namespace clang Index: clang-tools-extra/docs/ReleaseNotes.rst =================================================================== --- clang-tools-extra/docs/ReleaseNotes.rst +++ clang-tools-extra/docs/ReleaseNotes.rst @@ -82,6 +82,10 @@ `Altera SDK for OpenCL: Best Practices Guide `_. +- New ``concurrent`` module. + + Includes checks related to concurrent programming (e.g. threads, fibers, coroutines, etc.). + New checks ^^^^^^^^^^ Index: clang-tools-extra/docs/clang-tidy/index.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/index.rst +++ clang-tools-extra/docs/clang-tidy/index.rst @@ -64,6 +64,8 @@ ``bugprone-`` Checks that target bugprone code constructs. ``cert-`` Checks related to CERT Secure Coding Guidelines. ``clang-analyzer-`` Clang Static Analyzer checks. +``concurrent-`` Checks related to concurrent programming (including + threads, fibers, coroutines, etc.). ``cppcoreguidelines-`` Checks related to C++ Core Guidelines. ``darwin-`` Checks related to Darwin coding conventions. ``fuchsia-`` Checks related to Fuchsia coding conventions.