[llvm] 52b8e10 - [libclang] Remove LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 1 10:22:21 PST 2021


Author: Nico Weber
Date: 2021-03-01T13:21:59-05:00
New Revision: 52b8e10597315a96bc7cbc7cfe618e301c1e6e6c

URL: https://github.com/llvm/llvm-project/commit/52b8e10597315a96bc7cbc7cfe618e301c1e6e6c
DIFF: https://github.com/llvm/llvm-project/commit/52b8e10597315a96bc7cbc7cfe618e301c1e6e6c.diff

LOG: [libclang] Remove LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA

LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA causes clang-tools-extra tools
to be included in libclang, which caused a dependency cycle. The option
has been off by default for two releases now, and (based on a web search
and mailing list feedback) nobody seems to turn it on. Remove it, like
planned on https://reviews.llvm.org/D79599

Differential Revision: https://reviews.llvm.org/D97693

Added: 
    

Modified: 
    clang-tools-extra/test/CMakeLists.txt
    clang-tools-extra/test/lit.site.cfg.py.in
    clang/docs/ReleaseNotes.rst
    clang/tools/libclang/CIndex.cpp
    clang/tools/libclang/CMakeLists.txt
    llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
    llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn

Removed: 
    clang-tools-extra/test/clang-tidy/infrastructure/nolint-plugin.cpp
    clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline-plugin.cpp
    llvm/utils/gn/secondary/clang/tools/libclang/include_clang_tools_extra.gni


################################################################################
diff  --git a/clang-tools-extra/test/CMakeLists.txt b/clang-tools-extra/test/CMakeLists.txt
index 662b138e9f46..06be00015223 100644
--- a/clang-tools-extra/test/CMakeLists.txt
+++ b/clang-tools-extra/test/CMakeLists.txt
@@ -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
-  LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA
   )
 
 configure_lit_site_cfg(
@@ -68,10 +67,6 @@ set(CLANG_TOOLS_TEST_DEPS
   # Clang-tidy tests need clang for building modules.
   clang
 )
-if (LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA)
-  # For the clang-tidy libclang integration test.
-  set(CLANG_TOOLS_TEST_DEPS ${CLANG_TOOLS_TEST_DEPS} "c-index-test")
-endif ()
 
 # Add lit test dependencies.
 set(LLVM_UTILS_DEPS

diff  --git a/clang-tools-extra/test/clang-tidy/infrastructure/nolint-plugin.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/nolint-plugin.cpp
deleted file mode 100644
index d10c16620749..000000000000
--- a/clang-tools-extra/test/clang-tidy/infrastructure/nolint-plugin.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-// REQUIRES: static-analyzer, libclang_include_clang_tools_extra
-// RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-tidy -Xclang -plugin-arg-clang-tidy -Xclang -checks='-*,google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult' -Wunused-variable -I%S/Inputs/nolint 2>&1 | FileCheck %s
-
-#include "trigger_warning.h"
-void I(int& Out) {
-  int In;
-  A1(In, Out);
-}
-// CHECK-NOT: trigger_warning.h:{{.*}} warning
-// CHECK-NOT: :[[@LINE-4]]:{{.*}} note
-
-class A { A(int i); };
-// CHECK-DAG: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-class B { B(int i); }; // NOLINT
-
-class C { C(int i); }; // NOLINT(for-some-other-check)
-// CHECK-DAG: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-class C1 { C1(int i); }; // NOLINT(*)
-
-class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
-
-class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
-
-class C4 { C4(int i); }; // NOLINT(some-check, google-explicit-constructor)
-
-class C5 { C5(int i); }; // NOLINT without-brackets-skip-all, another-check
-
-void f() {
-  int i;
-// CHECK-DAG: :[[@LINE-1]]:7: warning: unused variable 'i' [-Wunused-variable]
-//                          31:7: warning: unused variable 'i' [-Wunused-variable]
-//  int j; // NOLINT
-//  int k; // NOLINT(clang-diagnostic-unused-variable)
-}
-
-#define MACRO(X) class X { X(int i); };
-MACRO(D)
-// CHECK-DAG: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
-MACRO(E) // NOLINT
-
-#define MACRO_NOARG class F { F(int i); };
-MACRO_NOARG // NOLINT
-
-#define MACRO_NOLINT class G { G(int i); }; // NOLINT
-MACRO_NOLINT
-
-#define DOUBLE_MACRO MACRO(H) // NOLINT
-DOUBLE_MACRO

diff  --git a/clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline-plugin.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline-plugin.cpp
deleted file mode 100644
index 4835f4c52a45..000000000000
--- a/clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline-plugin.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-// REQUIRES: libclang_include_clang_tools_extra
-// RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-tidy -Xclang -plugin-arg-clang-tidy -Xclang -checks='-*,google-explicit-constructor' 2>&1 | FileCheck %s
-
-class A { A(int i); };
-// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-// NOLINTNEXTLINE
-class B { B(int i); };
-
-// NOLINTNEXTLINE(for-some-other-check)
-class C { C(int i); };
-// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-// NOLINTNEXTLINE(*)
-class C1 { C1(int i); };
-
-// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
-class C2 { C2(int i); };
-
-// NOLINTNEXTLINE(google-explicit-constructor)
-class C3 { C3(int i); };
-
-// NOLINTNEXTLINE(some-check, google-explicit-constructor)
-class C4 { C4(int i); };
-
-// NOLINTNEXTLINE without-brackets-skip-all, another-check
-class C5 { C5(int i); };
-
-
-// NOLINTNEXTLINE
-
-class D { D(int i); };
-// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-// NOLINTNEXTLINE
-//
-class E { E(int i); };
-// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-#define MACRO(X) class X { X(int i); };
-MACRO(F)
-// CHECK: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
-// NOLINTNEXTLINE
-MACRO(G)
-
-#define MACRO_NOARG class H { H(int i); };
-// NOLINTNEXTLINE
-MACRO_NOARG
-

diff  --git a/clang-tools-extra/test/lit.site.cfg.py.in b/clang-tools-extra/test/lit.site.cfg.py.in
index 7eef661b85fd..f8300c1dd39d 100644
--- a/clang-tools-extra/test/lit.site.cfg.py.in
+++ b/clang-tools-extra/test/lit.site.cfg.py.in
@@ -11,7 +11,6 @@ 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.libclang_include_clang_tools_extra = @LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA@
 
 # 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.

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6a0ebd9ab3ee..9db9a0edc391 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -151,6 +151,10 @@ Build System Changes
 These are major changes to the build system that have happened since the 12.0.0
 release of Clang. Users of the build system should adjust accordingly.
 
+- The option ``LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA`` no longer exists. There were
+  two releases with that flag forced off, and no uses were added that forced it
+  on. The recommended replacement is clangd.
+
 - ...
 
 AST Matchers

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index f1acecc03e16..1aaf69548efb 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -9161,16 +9161,3 @@ cxindex::Logger::~Logger() {
     OS << "--------------------------------------------------\n";
   }
 }
-
-#ifdef CLANG_TOOL_EXTRA_BUILD
-// This anchor is used to force the linker to link the clang-tidy plugin.
-extern volatile int ClangTidyPluginAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED ClangTidyPluginAnchorDestination =
-    ClangTidyPluginAnchorSource;
-
-// This anchor is used to force the linker to link the clang-include-fixer
-// plugin.
-extern volatile int ClangIncludeFixerPluginAnchorSource;
-static int LLVM_ATTRIBUTE_UNUSED ClangIncludeFixerPluginAnchorDestination =
-    ClangIncludeFixerPluginAnchorSource;
-#endif

diff  --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt
index 51ff2e7e1565..8fde9aed0191 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -52,22 +52,6 @@ if (CLANG_ENABLE_ARCMT)
   list(APPEND LIBS clangARCMigrate)
 endif ()
 
-option(LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA
-  "Include code from clang-tools-extra in libclang." OFF)
-
-if (LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA)
-  if (TARGET clangTidyPlugin)
-    add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
-    list(APPEND LIBS clangTidyPlugin)
-    list(APPEND LIBS clangIncludeFixerPlugin)
-    if(LLVM_ENABLE_MODULES)
-      list(APPEND LLVM_COMPILE_FLAGS "-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD")
-    endif()
-  else ()
-    message(FATAL_ERROR "LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA needs clang-tools-extra in LLVM_ENABLE_PROJECTS")
-  endif ()
-endif ()
-
 if (HAVE_LIBDL)
   list(APPEND LIBS ${CMAKE_DL_LIBS})
 elseif (CLANG_BUILT_STANDALONE)

diff  --git a/llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn b/llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
index e8b1f155a520..136d6b64c3ff 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/test/BUILD.gn
@@ -1,6 +1,5 @@
 import("//clang-tools-extra/clang-tidy/enable.gni")
 import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
-import("//clang/tools/libclang/include_clang_tools_extra.gni")
 import("//llvm/triples.gni")
 import("//llvm/utils/gn/build/write_cmake_config.gni")
 import("clang_tools_extra_lit_site_cfg_files.gni")
@@ -44,12 +43,6 @@ write_lit_config("lit_site_cfg") {
   } else {
     extra_values += [ "CLANG_TIDY_ENABLE_STATIC_ANALYZER=0" ]
   }
-
-  if (libclang_include_clang_tools_extra) {
-    extra_values += [ "LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA=1" ]
-  } else {
-    extra_values += [ "LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA=0" ]
-  }
 }
 
 write_lit_config("lit_unit_site_cfg") {

diff  --git a/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn b/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
index 4cef8fa50271..d0cddcfaad04 100644
--- a/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
@@ -1,5 +1,4 @@
 import("//clang/lib/ARCMigrate/enable.gni")
-import("//clang/tools/libclang/include_clang_tools_extra.gni")
 import("//llvm/version.gni")
 
 # This build file is just enough to get check-clang to pass, it's missing
@@ -40,16 +39,6 @@ target(libclang_target_type, "libclang") {
 
   defines = []
 
-  # FIXME: Once the GN build has a way to select which bits to build,
-  # only include this dependency if clang-tools-extra is part of the build.
-  if (libclang_include_clang_tools_extra) {
-    defines += [ "CLANG_TOOL_EXTRA_BUILD" ]
-    deps += [
-      "//clang-tools-extra/clang-include-fixer/plugin",
-      "//clang-tools-extra/clang-tidy/plugin",
-    ]
-  }
-
   if (host_os == "win") {
     defines += [ "_CINDEX_LIB_" ]
   }

diff  --git a/llvm/utils/gn/secondary/clang/tools/libclang/include_clang_tools_extra.gni b/llvm/utils/gn/secondary/clang/tools/libclang/include_clang_tools_extra.gni
deleted file mode 100644
index 0beaa37c7ec1..000000000000
--- a/llvm/utils/gn/secondary/clang/tools/libclang/include_clang_tools_extra.gni
+++ /dev/null
@@ -1,4 +0,0 @@
-declare_args() {
-  # Whether to include code from clang-tools-extra in libclang.
-  libclang_include_clang_tools_extra = false
-}


        


More information about the llvm-commits mailing list