diff --git a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt --- a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt @@ -5,8 +5,24 @@ support ) -add_clang_tool(clang-tidy +# Needed by LLVM's CMake checks because this file defines multiple targets. +set(LLVM_OPTIONAL_SOURCES ClangTidyMain.cpp ClangTidyToolMain.cpp) + +add_clang_library(clangTidyMain ClangTidyMain.cpp + + LINK_LIBS + clangAST + clangASTMatchers + clangBasic + clangTidy + ${ALL_CLANG_TIDY_CHECKS} + clangTooling + clangToolingCore + ) + +add_clang_tool(clang-tidy + ClangTidyToolMain.cpp ) add_dependencies(clang-tidy clang-resource-headers @@ -22,6 +38,7 @@ target_link_libraries(clang-tidy PRIVATE clangTidy + clangTidyMain ${ALL_CLANG_TIDY_CHECKS} ) diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.h b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.h new file mode 100644 --- /dev/null +++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.h @@ -0,0 +1,23 @@ +//===--- tools/extra/clang-tidy/ClangTidyMain.h - Clang tidy tool -------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file This file declares clang-tidy tool main function. +/// +/// This tool uses the Clang Tooling infrastructure, see +/// http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html +/// for details on setting it up with LLVM source tree. +/// +//===----------------------------------------------------------------------===// + +namespace clang { +namespace tidy { + +int clangTidyMain(int argc, const char **argv); + +} // namespace tidy +} // namespace clang diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp --- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp +++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp @@ -327,7 +327,7 @@ return FS; } -static int clangTidyMain(int argc, const char **argv) { +int clangTidyMain(int argc, const char **argv) { llvm::InitLLVM X(argc, argv); CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory, cl::ZeroOrMore); @@ -488,7 +488,3 @@ } // namespace tidy } // namespace clang - -int main(int argc, const char **argv) { - return clang::tidy::clangTidyMain(argc, argv); -} diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyToolMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyToolMain.cpp new file mode 100644 --- /dev/null +++ b/clang-tools-extra/clang-tidy/tool/ClangTidyToolMain.cpp @@ -0,0 +1,21 @@ +//===--- tools/extra/clang-tidy/ClangTidyToolMain.cpp - Clang tidy tool ---===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file This file contains clang-tidy tool entry point main function. +/// +/// This tool uses the Clang Tooling infrastructure, see +/// http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html +/// for details on setting it up with LLVM source tree. +/// +//===----------------------------------------------------------------------===// + +#include "ClangTidyMain.h" + +int main(int argc, const char **argv) { + return clang::tidy::clangTidyMain(argc, argv); +}