[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
This commit is contained in:
Nico Weber 2021-03-01 13:20:53 -05:00
parent 3f40dbbbc7
commit 52b8e10597
10 changed files with 4 additions and 156 deletions

View File

@ -17,7 +17,6 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUN
llvm_canonicalize_cmake_booleans( llvm_canonicalize_cmake_booleans(
CLANG_TIDY_ENABLE_STATIC_ANALYZER CLANG_TIDY_ENABLE_STATIC_ANALYZER
LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA
) )
configure_lit_site_cfg( configure_lit_site_cfg(
@ -68,10 +67,6 @@ set(CLANG_TOOLS_TEST_DEPS
# Clang-tidy tests need clang for building modules. # Clang-tidy tests need clang for building modules.
clang 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. # Add lit test dependencies.
set(LLVM_UTILS_DEPS set(LLVM_UTILS_DEPS

View File

@ -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

View File

@ -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

View File

@ -11,7 +11,6 @@ config.clang_libs_dir = "@SHLIBDIR@"
config.python_executable = "@Python3_EXECUTABLE@" config.python_executable = "@Python3_EXECUTABLE@"
config.target_triple = "@TARGET_TRIPLE@" config.target_triple = "@TARGET_TRIPLE@"
config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@ 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 # 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. # used when we can't determine the tool dir at configuration time.

View File

@ -151,6 +151,10 @@ Build System Changes
These are major changes to the build system that have happened since the 12.0.0 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. 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 AST Matchers

View File

@ -9161,16 +9161,3 @@ cxindex::Logger::~Logger() {
OS << "--------------------------------------------------\n"; 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

View File

@ -52,22 +52,6 @@ if (CLANG_ENABLE_ARCMT)
list(APPEND LIBS clangARCMigrate) list(APPEND LIBS clangARCMigrate)
endif () 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) if (HAVE_LIBDL)
list(APPEND LIBS ${CMAKE_DL_LIBS}) list(APPEND LIBS ${CMAKE_DL_LIBS})
elseif (CLANG_BUILT_STANDALONE) elseif (CLANG_BUILT_STANDALONE)

View File

@ -1,6 +1,5 @@
import("//clang-tools-extra/clang-tidy/enable.gni") import("//clang-tools-extra/clang-tidy/enable.gni")
import("//clang/lib/StaticAnalyzer/Frontend/enable.gni") import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
import("//clang/tools/libclang/include_clang_tools_extra.gni")
import("//llvm/triples.gni") import("//llvm/triples.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni") import("//llvm/utils/gn/build/write_cmake_config.gni")
import("clang_tools_extra_lit_site_cfg_files.gni") import("clang_tools_extra_lit_site_cfg_files.gni")
@ -44,12 +43,6 @@ write_lit_config("lit_site_cfg") {
} else { } else {
extra_values += [ "CLANG_TIDY_ENABLE_STATIC_ANALYZER=0" ] 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") { write_lit_config("lit_unit_site_cfg") {

View File

@ -1,5 +1,4 @@
import("//clang/lib/ARCMigrate/enable.gni") import("//clang/lib/ARCMigrate/enable.gni")
import("//clang/tools/libclang/include_clang_tools_extra.gni")
import("//llvm/version.gni") import("//llvm/version.gni")
# This build file is just enough to get check-clang to pass, it's missing # 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 = [] 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") { if (host_os == "win") {
defines += [ "_CINDEX_LIB_" ] defines += [ "_CINDEX_LIB_" ]
} }

View File

@ -1,4 +0,0 @@
declare_args() {
# Whether to include code from clang-tools-extra in libclang.
libclang_include_clang_tools_extra = false
}