From: Benjamin Kramer Date: Thu, 3 Mar 2016 08:58:18 +0000 (+0000) Subject: [libclang] Link clang-tidy plugin into libclang if present. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e0aa32c7c3151f7c397ffe15d304a4556302b05;p=clang [libclang] Link clang-tidy plugin into libclang if present. This is a sad workaround for the lack of plugin support in libclang. Depends on D17807, a tools-extra change that also contains the test case. This is designed to be easy to remove again if libclang ever grows proper plugin support. Differential Revision: http://reviews.llvm.org/D17808 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262596 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 59e34b84c0..5741eeaf83 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -7933,3 +7933,10 @@ 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; +#endif diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt index 741e02ab3b..5af5930043 100644 --- a/tools/libclang/CMakeLists.txt +++ b/tools/libclang/CMakeLists.txt @@ -47,6 +47,11 @@ if (CLANG_ENABLE_ARCMT) list(APPEND LIBS clangARCMigrate) endif () +if (CLANG_TOOL_EXTRA_BUILD) + add_definitions(-DCLANG_TOOL_EXTRA_BUILD) + list(APPEND LIBS clangTidyPlugin) +endif () + find_library(DL_LIBRARY_PATH dl) if (DL_LIBRARY_PATH) list(APPEND LIBS dl)