forked from OSchip/llvm-project
[clang-tidy] Add library for clang-tidy main function
Summary: This library allows to create clang-tidy tools with custom checks outside of llvm repo using prebuilt clang release tarball. Test Plan: Checked that clang-tidy works as before. New library exists in istall dir. Reviewers: smeenai, gribozavr, stephanemoore Subscribers: mgorny, xazax.hun, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D73300
This commit is contained in:
parent
be8e38cbd9
commit
3f8b100e94
|
@ -5,8 +5,24 @@ set(LLVM_LINK_COMPONENTS
|
|||
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 @@ clang_target_link_libraries(clang-tidy
|
|||
target_link_libraries(clang-tidy
|
||||
PRIVATE
|
||||
clangTidy
|
||||
clangTidyMain
|
||||
${ALL_CLANG_TIDY_CHECKS}
|
||||
)
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
///
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "ClangTidyMain.h"
|
||||
#include "../ClangTidy.h"
|
||||
#include "../ClangTidyForceLinker.h"
|
||||
#include "../GlobList.h"
|
||||
|
@ -327,7 +328,7 @@ getVfsFromFile(const std::string &OverlayFile,
|
|||
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 +489,3 @@ static int clangTidyMain(int argc, const char **argv) {
|
|||
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
||||
int main(int argc, const char **argv) {
|
||||
return clang::tidy::clangTidyMain(argc, argv);
|
||||
}
|
||||
|
|
|
@ -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 the main function for the clang-tidy tool.
|
||||
///
|
||||
/// 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
|
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue