]> granicus.if.org Git - clang/commitdiff
[libclang] Link clang-tidy plugin into libclang if present.
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 3 Mar 2016 08:58:18 +0000 (08:58 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 3 Mar 2016 08:58:18 +0000 (08:58 +0000)
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

tools/libclang/CIndex.cpp
tools/libclang/CMakeLists.txt

index 59e34b84c09cb944dba80b286e15ca150e04bf45..5741eeaf831822cc8f70575eeedaf48f78f36e68 100644 (file)
@@ -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
index 741e02ab3b2c8ac0371165ca6ce0ccc206d82619..5af5930043b2f29fe3255a05e5f0a25d487762b3 100644 (file)
@@ -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)