diff --git a/clang-tools-extra/clang-tidy/CMakeLists.txt b/clang-tools-extra/clang-tidy/CMakeLists.txt --- a/clang-tools-extra/clang-tidy/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/CMakeLists.txt @@ -46,6 +46,7 @@ add_subdirectory(cert) add_subdirectory(cppcoreguidelines) add_subdirectory(darwin) +add_subdirectory(experimental) add_subdirectory(fuchsia) add_subdirectory(google) add_subdirectory(hicpp) @@ -71,6 +72,7 @@ clangTidyCERTModule clangTidyCppCoreGuidelinesModule clangTidyDarwinModule + clangTidyExperimentalModule clangTidyFuchsiaModule clangTidyGoogleModule clangTidyHICPPModule diff --git a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h --- a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h +++ b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h @@ -50,6 +50,11 @@ static int LLVM_ATTRIBUTE_UNUSED DarwinModuleAnchorDestination = DarwinModuleAnchorSource; +// This anchor is used to force the linker to link the ExperimentalModule. +extern volatile int ExperimentalModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED ExperimentalModuleAnchorDestination = + ExperimentalModuleAnchorSource; + // This anchor is used to force the linker to link the FuchsiaModule. extern volatile int FuchsiaModuleAnchorSource; static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination = diff --git a/clang-tools-extra/clang-tidy/experimental/CMakeLists.txt b/clang-tools-extra/clang-tidy/experimental/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/clang-tools-extra/clang-tidy/experimental/CMakeLists.txt @@ -0,0 +1,14 @@ +set(LLVM_LINK_COMPONENTS support) + +add_clang_library(clangTidyExperimentalModule + ExperimentalTidyModule.cpp + + LINK_LIBS + clangAST + clangASTMatchers + clangBasic + clangLex + clangTidy + clangTidyUtils + clangTooling + ) diff --git a/clang-tools-extra/clang-tidy/experimental/ExperimentalTidyModule.cpp b/clang-tools-extra/clang-tidy/experimental/ExperimentalTidyModule.cpp new file mode 100644 --- /dev/null +++ b/clang-tools-extra/clang-tidy/experimental/ExperimentalTidyModule.cpp @@ -0,0 +1,45 @@ +//===-- ExperimentalTidyModule.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 experimental { + +/// A module containing checks that are experimental versions of future checks +/// that belong to other modules. +class ExperimentalModule : public ClangTidyModule { +public: + void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { + + } + + ClangTidyOptions getModuleOptions() override { + ClangTidyOptions Options; + ClangTidyOptions::OptionMap &Opts = Options.CheckOptions; + + return Options; + } +}; + +// Register the LLVMTidyModule using this statically initialized variable. +static ClangTidyModuleRegistry::Add + X("experimental-module", + "Adds checks for that are experimental versions of future checks."); + +} // namespace experimental + +// This anchor is used to force the linker to link in the generated object file +// and thus register the ExperimentalModule. +volatile int ExperimentalModuleAnchorSource = 0; + +} // namespace tidy +} // namespace clang diff --git a/clang-tools-extra/docs/clang-tidy/index.rst b/clang-tools-extra/docs/clang-tidy/index.rst --- a/clang-tools-extra/docs/clang-tidy/index.rst +++ b/clang-tools-extra/docs/clang-tidy/index.rst @@ -65,6 +65,8 @@ ``clang-analyzer-`` Clang Static Analyzer checks. ``cppcoreguidelines-`` Checks related to C++ Core Guidelines. ``darwin-`` Checks related to Darwin coding conventions. +``experimental-`` Experimental checks that will eventually move to other + groups. ``fuchsia-`` Checks related to Fuchsia coding conventions. ``google-`` Checks related to Google coding conventions. ``hicpp-`` Checks related to High Integrity C++ Coding Standard.