r262596 - [libclang] Link clang-tidy plugin into libclang if present.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 3 00:58:18 PST 2016


Author: d0k
Date: Thu Mar  3 02:58:18 2016
New Revision: 262596

URL: http://llvm.org/viewvc/llvm-project?rev=262596&view=rev
Log:
[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

Modified:
    cfe/trunk/tools/libclang/CIndex.cpp
    cfe/trunk/tools/libclang/CMakeLists.txt

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=262596&r1=262595&r2=262596&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Mar  3 02:58:18 2016
@@ -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

Modified: cfe/trunk/tools/libclang/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CMakeLists.txt?rev=262596&r1=262595&r2=262596&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CMakeLists.txt (original)
+++ cfe/trunk/tools/libclang/CMakeLists.txt Thu Mar  3 02:58:18 2016
@@ -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)




More information about the cfe-commits mailing list