This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Add library for clang-tidy main function
ClosedPublic

Authored by DmitryPolukhin on Jan 23 2020, 2:46 PM.

Details

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.

Event Timeline

DmitryPolukhin created this revision.Jan 23 2020, 2:46 PM
Eugene.Zelenko added inline comments.
clang-tools-extra/clang-tidy/tool/ClangTidyMain.h
6

License seems to be old.

clang-tools-extra/clang-tidy/tool/ClangTidyToolMain.cpp
6

License seems to be old.

Fix license text

DmitryPolukhin marked 2 inline comments as done.Jan 23 2020, 3:16 PM

@Eugene.Zelenko thank you for the catch

gribozavr2 accepted this revision.Jan 24 2020, 1:56 AM
gribozavr2 added a reviewer: gribozavr2.
gribozavr2 added a subscriber: gribozavr2.
gribozavr2 added inline comments.
clang-tools-extra/clang-tidy/tool/ClangTidyMain.h
9

"... declares the main function for the clang-tidy tool."

This revision is now accepted and ready to land.Jan 24 2020, 1:56 AM

Updated comment per review suggestion.

DmitryPolukhin marked an inline comment as done.Jan 24 2020, 9:37 AM

Added #include "ClangTidyMain.h" in ClangTidyMain.cpp

This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.Jan 27 2020, 6:44 AM
thakis added inline comments.
clang-tools-extra/clang-tidy/tool/CMakeLists.txt
22

Normally we have a single cmake target per CMakeLists.txt. Maybe the library could be in clang-tidy/lib and clang-tidy/tool could use it? Then you wouldn't need the LLVM_OPTIONAL_SOURCES hack and it'd be all a bit nicer.

DmitryPolukhin marked an inline comment as done.Jan 27 2020, 7:40 AM
DmitryPolukhin added inline comments.
clang-tools-extra/clang-tidy/tool/CMakeLists.txt
22

I'll prepare patch with files move if you think it worths doing. I see multiple targets in several CMakeLists.txt:

llvm-project> grep LLVM_OPTIONAL_SOURCES ./ -r
./clang-tools-extra/clang-tidy/tool/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES ClangTidyMain.cpp ClangTidyToolMain.cpp)
./clang-tools-extra/clangd/xpc/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES Conversion.cpp XPCTransport.cpp)
./clang/tools/clang-fuzzer/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
./clang/tools/clang-fuzzer/CMakeLists.txt:  set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})
./clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES proto_to_cxx.cpp proto_to_cxx_main.cpp
./clang/tools/clang-fuzzer/proto-to-llvm/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES loop_proto_to_llvm.cpp loop_proto_to_llvm_main.cpp)
./lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt:  list(APPEND LLVM_OPTIONAL_SOURCES
./lldb/source/Symbol/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES LocateSymbolFileMacOSX.cpp)
./lldb/tools/debugserver/source/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES ${lldbDebugserverCommonSources})
./llvm/cmake/modules/AddLLVM.cmake:    set(LLVM_OPTIONAL_SOURCES ${ARG_DUMMY_MAIN})
./llvm/cmake/modules/AddLLVM.cmake:    set(LLVM_OPTIONAL_SOURCES ${ARG_DUMMY_MAIN})
./llvm/cmake/modules/LLVMProcessSources.cmake:      list(FIND LLVM_OPTIONAL_SOURCES ${entry} idx)
./llvm/unittests/Passes/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES PluginsTest.cpp TestPlugin.cpp)
./llvm/unittests/Support/DynamicLibrary/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES ExportedFuncs.cpp PipSqueak.cpp)
./mlir/lib/EDSC/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
./mlir/lib/Support/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
./mlir/test/lib/TestDialect/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
./mlir/test/mlir-cpu-runner/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
./mlir/tools/mlir-cuda-runner/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES
./mlir/tools/mlir-opt/CMakeLists.txt:set(LLVM_OPTIONAL_SOURCES

@thakis I'm sorry sorry if it was not clear. Please let me know if you still prefer to have separate directory for clangTidyMain to have only one target per CMakeLists.txt.