From 819bedf3a1ba3f09037fe9a4a732dccbd9defb94 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Fri, 22 Mar 2019 19:46:01 +0000 Subject: [PATCH] [clang-tidy] A new OpenMP module Summary: Just the empty skeleton. Previously reviewed as part of D57113. Reviewers: JonasToth, aaron.ballman, alexfh, xazax.hun, hokein, gribozavr Reviewed By: JonasToth, gribozavr Subscribers: jdoerfert, mgorny, rnkovacs, guansong, arphaman, cfe-commits Tags: #clang-tools-extra, #openmp, #clang Differential Revision: https://reviews.llvm.org/D57571 llvm-svn: 356800 --- clang-tools-extra/clang-tidy/CMakeLists.txt | 1 + .../clang-tidy/ClangTidyForceLinker.h | 5 ++++ clang-tools-extra/clang-tidy/openmp/CMakeLists.txt | 11 +++++++ .../clang-tidy/openmp/OpenMPTidyModule.cpp | 35 ++++++++++++++++++++++ clang-tools-extra/clang-tidy/plugin/CMakeLists.txt | 1 + clang-tools-extra/clang-tidy/tool/CMakeLists.txt | 1 + clang-tools-extra/docs/ReleaseNotes.rst | 4 +++ clang-tools-extra/docs/clang-tidy/index.rst | 1 + 8 files changed, 59 insertions(+) create mode 100644 clang-tools-extra/clang-tidy/openmp/CMakeLists.txt create mode 100644 clang-tools-extra/clang-tidy/openmp/OpenMPTidyModule.cpp diff --git a/clang-tools-extra/clang-tidy/CMakeLists.txt b/clang-tools-extra/clang-tidy/CMakeLists.txt index d329cf8..1cdd021 100644 --- a/clang-tools-extra/clang-tidy/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/CMakeLists.txt @@ -50,6 +50,7 @@ if(CLANG_ENABLE_STATIC_ANALYZER) add_subdirectory(mpi) endif() add_subdirectory(objc) +add_subdirectory(openmp) add_subdirectory(performance) add_subdirectory(plugin) add_subdirectory(portability) diff --git a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h index 966aeb2..6100cf6 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h +++ b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h @@ -77,6 +77,11 @@ static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination = MPIModuleAnchorSource; #endif +// This anchor is used to force the linker to link the OpenMPModule. +extern volatile int OpenMPModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED OpenMPModuleAnchorDestination = + OpenMPModuleAnchorSource; + // This anchor is used to force the linker to link the PerformanceModule. extern volatile int PerformanceModuleAnchorSource; static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination = diff --git a/clang-tools-extra/clang-tidy/openmp/CMakeLists.txt b/clang-tools-extra/clang-tidy/openmp/CMakeLists.txt new file mode 100644 index 0000000..4bd4dff --- /dev/null +++ b/clang-tools-extra/clang-tidy/openmp/CMakeLists.txt @@ -0,0 +1,11 @@ +set(LLVM_LINK_COMPONENTS support) + +add_clang_library(clangTidyOpenMPModule + OpenMPTidyModule.cpp + + LINK_LIBS + clangAST + clangASTMatchers + clangBasic + clangTidy + ) diff --git a/clang-tools-extra/clang-tidy/openmp/OpenMPTidyModule.cpp b/clang-tools-extra/clang-tidy/openmp/OpenMPTidyModule.cpp new file mode 100644 index 0000000..9dcc258 --- /dev/null +++ b/clang-tools-extra/clang-tidy/openmp/OpenMPTidyModule.cpp @@ -0,0 +1,35 @@ +//===--- OpenMPTidyModule.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 openmp { + +/// This module is for OpenMP-specific checks. +class OpenMPModule : public ClangTidyModule { +public: + void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { + } +}; + +// Register the OpenMPTidyModule using this statically initialized variable. +static ClangTidyModuleRegistry::Add + X("openmp-module", "Adds OpenMP-specific checks."); + +} // namespace openmp + +// This anchor is used to force the linker to link in the generated object file +// and thus register the OpenMPModule. +volatile int OpenMPModuleAnchorSource = 0; + +} // namespace tidy +} // namespace clang diff --git a/clang-tools-extra/clang-tidy/plugin/CMakeLists.txt b/clang-tools-extra/clang-tidy/plugin/CMakeLists.txt index 7a12d7f..25b094f 100644 --- a/clang-tools-extra/clang-tidy/plugin/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/plugin/CMakeLists.txt @@ -21,6 +21,7 @@ add_clang_library(clangTidyPlugin clangTidyMiscModule clangTidyModernizeModule clangTidyObjCModule + clangTidyOpenMPModule clangTidyPerformanceModule clangTidyPortabilityModule clangTidyReadabilityModule diff --git a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt index 4110735..71d57ff 100644 --- a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt @@ -30,6 +30,7 @@ target_link_libraries(clang-tidy clangTidyMiscModule clangTidyModernizeModule clangTidyObjCModule + clangTidyOpenMPModule clangTidyPerformanceModule clangTidyPortabilityModule clangTidyReadabilityModule diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index f69d3e7..d85ba1b 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -67,6 +67,10 @@ The improvements are... Improvements to clang-tidy -------------------------- +- New OpenMP module. + + For checks specific to `OpenMP `_ API. + - New :doc:`abseil-duration-addition ` check. diff --git a/clang-tools-extra/docs/clang-tidy/index.rst b/clang-tools-extra/docs/clang-tidy/index.rst index 12a32df..1b5af60 100644 --- a/clang-tools-extra/docs/clang-tidy/index.rst +++ b/clang-tools-extra/docs/clang-tidy/index.rst @@ -73,6 +73,7 @@ Name prefix Description means "C++11") language constructs. ``mpi-`` Checks related to MPI (Message Passing Interface). ``objc-`` Checks related to Objective-C coding conventions. +``openmp-`` Checks related to OpenMP API. ``performance-`` Checks that target performance-related issues. ``portability-`` Checks that target portability-related issues that don't relate to any particular coding style. -- 2.7.4