[PATCH] D17808: [libclang] Link clang-tidy plugin into libclang if present.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 2 06:48:05 PST 2016


bkramer created this revision.
bkramer added a reviewer: klimek.
bkramer added a subscriber: cfe-commits.

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.

http://reviews.llvm.org/D17808

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

Index: tools/libclang/CMakeLists.txt
===================================================================
--- tools/libclang/CMakeLists.txt
+++ tools/libclang/CMakeLists.txt
@@ -47,6 +47,11 @@
   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)
Index: tools/libclang/CIndex.cpp
===================================================================
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -7930,3 +7930,10 @@
     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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17808.49616.patch
Type: text/x-patch
Size: 972 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160302/d4be3152/attachment.bin>


More information about the cfe-commits mailing list