feat(tidy): add fairmq-clangd for editor integration

- Add the option BUILD_TIDY_CLANGD (default OFF). It builds
  fairmq-clangd from clangdMain plus the fairmq-* module.
- clangd cannot load plugins, but creates its clang-tidy checks from the
  same registry. Thus the checks run on the AST that clangd builds anyway,
  and editors show their fixes as quick fixes.
- Point clangd to the resource directory of the LLVM installation it was
  built with, unless --resource-dir is given.
- Test each check over LSP with test/tidy/ClangdCheck.py: open the input,
  expect a diagnostic of the check and a quick fix for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-11-09 22:42:03 +00:00
parent 622daae350
commit 661fc96fbb
4 changed files with 192 additions and 0 deletions

View File

@@ -80,3 +80,23 @@ install(TARGETS ${target}
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
)
# fairmq-clangd: the clangd language server plus the fairmq-* checks.
option(BUILD_TIDY_CLANGD "Build fairmq-clangd, the clangd language server with the fairmq-* checks." OFF)
if(BUILD_TIDY_CLANGD)
if(NOT TARGET clangdMain)
message(FATAL_ERROR "BUILD_TIDY_CLANGD=ON needs the clangd libraries "
"(clangdMain, clangDaemon) of the found Clang ${LLVM_PACKAGE_VERSION} "
"installation at ${Clang_DIR}.")
endif()
set(target fairmq-clangd)
add_executable(${target} runClangd.cxx)
add_executable("${PROJECT_NAME}::${target}" ALIAS ${target})
target_compile_definitions(${target} PRIVATE
FAIRMQ_TIDY_CLANG_RESOURCE_DIR="${FAIRMQ_TIDY_CLANG_RESOURCE_DIR}"
)
target_link_libraries(${target} PRIVATE fairmq-tidy-module clangdMain)
install(TARGETS ${target}
EXPORT ${PROJECT_EXPORT_SET}
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
)
endif()