Skip to content

Commit

Permalink
[libclang] Link clang-tidy plugin into libclang if present.
Browse files Browse the repository at this point in the history
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

llvm-svn: 262596
  • Loading branch information
d0k committed Mar 3, 2016
1 parent 8f5eb56 commit c1ffdab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions clang/tools/libclang/CIndex.cpp
Expand Up @@ -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
5 changes: 5 additions & 0 deletions clang/tools/libclang/CMakeLists.txt
Expand Up @@ -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)
Expand Down

0 comments on commit c1ffdab

Please sign in to comment.