Skip to content

Commit

Permalink
Revert "enable plugins for clang-tidy"
Browse files Browse the repository at this point in the history
This reverts commit 3689272 which
breaks the build when LLVM_INSTALL_TOOLCHAIN_ONLY is enabled with:

  CMake Error at cmake/modules/AddLLVM.cmake:683 (add_dependencies):
  The dependency target "clang-tidy-headers" of target "CTTestTidyModule"
  does not exist.
  • Loading branch information
petrhosek committed Jan 31, 2022
1 parent 4810051 commit ab3b898
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 139 deletions.
13 changes: 2 additions & 11 deletions clang-tools-extra/clang-tidy/tool/CMakeLists.txt
Expand Up @@ -29,17 +29,11 @@ clang_target_link_libraries(clangTidyMain
clangToolingCore
)

# Support plugins.
if(CLANG_PLUGIN_SUPPORT)
set(support_plugins SUPPORT_PLUGINS)
endif()

add_clang_tool(clang-tidy
ClangTidyToolMain.cpp

DEPENDS
)
add_dependencies(clang-tidy
clang-resource-headers
${support_plugins}
)
clang_target_link_libraries(clang-tidy
PRIVATE
Expand All @@ -56,9 +50,6 @@ target_link_libraries(clang-tidy
${ALL_CLANG_TIDY_CHECKS}
)

if(CLANG_PLUGIN_SUPPORT)
export_executable_symbols_for_plugins(clang-tidy)
endif()

install(PROGRAMS clang-tidy-diff.py
DESTINATION "${CMAKE_INSTALL_DATADIR}/clang"
Expand Down
6 changes: 0 additions & 6 deletions clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
Expand Up @@ -20,7 +20,6 @@
#include "../GlobList.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/TargetSelect.h"
Expand Down Expand Up @@ -387,11 +386,6 @@ getVfsFromFile(const std::string &OverlayFile,

int clangTidyMain(int argc, const char **argv) {
llvm::InitLLVM X(argc, argv);

// Enable help for -load option, if plugins are enabled.
if (cl::Option *LoadOpt = cl::getRegisteredOptions().lookup("load"))
LoadOpt->addCategory(ClangTidyCategory);

llvm::Expected<CommonOptionsParser> OptionsParser =
CommonOptionsParser::create(argc, argv, ClangTidyCategory,
cl::ZeroOrMore);
Expand Down
2 changes: 0 additions & 2 deletions clang-tools-extra/docs/ReleaseNotes.rst
Expand Up @@ -76,8 +76,6 @@ Improvements to clang-tidy
- Added support for `NOLINTBEGIN` ... `NOLINTEND` comments to suppress
Clang-Tidy warnings over multiple lines.

- Added support for external plugin checks with `-load`.

New checks
^^^^^^^^^^

Expand Down
20 changes: 0 additions & 20 deletions clang-tools-extra/docs/clang-tidy/Contributing.rst
Expand Up @@ -634,26 +634,6 @@ This keeps the test directory from getting cluttered.
.. _FileCheck: https://llvm.org/docs/CommandGuide/FileCheck.html
.. _test/clang-tidy/google-readability-casting.cpp: https://reviews.llvm.org/diffusion/L/browse/clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp

Out-of-tree check plugins
-------------------------

Developing an out-of-tree check as a plugin largely follows the steps
outlined above. The plugin is a shared library whose code lives outside
the clang-tidy build system. Build and link this shared library against
LLVM as done for other kinds of Clang plugins.

The plugin can be loaded by passing `-load` to `clang-tidy` in addition to the
names of the checks to enable.

.. code-block:: console
$ clang-tidy --checks=-*,my-explicit-constructor -list-checks -load myplugin.so
There is no expectations regarding ABI and API stability, so the plugin must be
compiled against the version of clang-tidy that will be loading the plugin.

The plugins can use threads, TLS, or any other facilities available to in-tree
code which is accessible from the external headers.

Running clang-tidy on LLVM
--------------------------
Expand Down
9 changes: 0 additions & 9 deletions clang-tools-extra/docs/clang-tidy/index.rst
Expand Up @@ -218,15 +218,6 @@ An overview of all the command-line options:
--list-checks -
List all enabled checks and exit. Use with
-checks=* to list all available checks.
-load=<plugin> -
Load the dynamic object ``plugin``. This
object should register new static analyzer
or clang-tidy passes. Once loaded, the
object will add new command line options
to run various analyses. To see the new
complete list of passes, use the
:option:`--list-checks` and
:option:`-load` options together.
-p=<string> - Build path
--quiet -
Run clang-tidy in quiet mode. This suppresses
Expand Down
17 changes: 0 additions & 17 deletions clang-tools-extra/test/CMakeLists.txt
Expand Up @@ -17,7 +17,6 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUN

llvm_canonicalize_cmake_booleans(
CLANG_TIDY_ENABLE_STATIC_ANALYZER
LLVM_ENABLE_PLUGINS
)

configure_lit_site_cfg(
Expand Down Expand Up @@ -79,22 +78,6 @@ foreach(dep ${LLVM_UTILS_DEPS})
endif()
endforeach()

llvm_add_library(
CTTestTidyModule
MODULE clang-tidy/CTTestTidyModule.cpp
PLUGIN_TOOL clang-tidy
DEPENDS clang-tidy-headers)

if(TARGET CTTestTidyModule)
list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule LLVMHello)
target_include_directories(CTTestTidyModule PUBLIC BEFORE "${CLANG_TOOLS_SOURCE_DIR}")
if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
set(LLVM_LINK_COMPONENTS
Support
)
endif()
endif()

add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CLANG_TOOLS_TEST_DEPS}
Expand Down
66 changes: 0 additions & 66 deletions clang-tools-extra/test/clang-tidy/CTTestTidyModule.cpp

This file was deleted.

6 changes: 0 additions & 6 deletions clang-tools-extra/test/lit.cfg.py
Expand Up @@ -149,9 +149,3 @@
"clangd", "benchmarks")
config.substitutions.append(('%clangd-benchmark-dir',
'%s' % (clangd_benchmarks_dir)))
config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
config.substitutions.append(('%pluginext', config.llvm_plugin_ext))

# Plugins (loadable modules)
if config.has_plugins and config.llvm_plugin_ext:
config.available_features.add('plugins')
2 changes: 0 additions & 2 deletions clang-tools-extra/test/lit.site.cfg.py.in
Expand Up @@ -4,15 +4,13 @@ import sys

config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
config.clang_libs_dir = "@SHLIBDIR@"
config.python_executable = "@Python3_EXECUTABLE@"
config.target_triple = "@TARGET_TRIPLE@"
config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
config.has_plugins = @LLVM_ENABLE_PLUGINS@

# Support substitution of the tools and libs dirs with user parameters. This is
# used when we can't determine the tool dir at configuration time.
Expand Down

0 comments on commit ab3b898

Please sign in to comment.