[clang-tidy] A new OpenMP module
authorRoman Lebedev <lebedev.ri@gmail.com>
Fri, 22 Mar 2019 19:46:01 +0000 (19:46 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Fri, 22 Mar 2019 19:46:01 +0000 (19:46 +0000)
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
clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
clang-tools-extra/clang-tidy/openmp/CMakeLists.txt [new file with mode: 0644]
clang-tools-extra/clang-tidy/openmp/OpenMPTidyModule.cpp [new file with mode: 0644]
clang-tools-extra/clang-tidy/plugin/CMakeLists.txt
clang-tools-extra/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/index.rst

index d329cf8..1cdd021 100644 (file)
@@ -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)
index 966aeb2..6100cf6 100644 (file)
@@ -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 (file)
index 0000000..4bd4dff
--- /dev/null
@@ -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 (file)
index 0000000..9dcc258
--- /dev/null
@@ -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<OpenMPModule>
+    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
index 7a12d7f..25b094f 100644 (file)
@@ -21,6 +21,7 @@ add_clang_library(clangTidyPlugin
   clangTidyMiscModule
   clangTidyModernizeModule
   clangTidyObjCModule
+  clangTidyOpenMPModule
   clangTidyPerformanceModule
   clangTidyPortabilityModule
   clangTidyReadabilityModule
index 4110735..71d57ff 100644 (file)
@@ -30,6 +30,7 @@ target_link_libraries(clang-tidy
   clangTidyMiscModule
   clangTidyModernizeModule
   clangTidyObjCModule
+  clangTidyOpenMPModule
   clangTidyPerformanceModule
   clangTidyPortabilityModule
   clangTidyReadabilityModule
index f69d3e7..d85ba1b 100644 (file)
@@ -67,6 +67,10 @@ The improvements are...
 Improvements to clang-tidy
 --------------------------
 
+- New OpenMP module.
+
+  For checks specific to `OpenMP <https://www.openmp.org/>`_ API.
+
 - New :doc:`abseil-duration-addition
   <clang-tidy/checks/abseil-duration-addition>` check.
 
index 12a32df..1b5af60 100644 (file)
@@ -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.