Skip to content

Commit 21f3dfb

Browse files
xry111tstellar
authored andcommitted
[clangd] Fix test failure when it's built with compiler flags unknown by clang
If LLVM is built with a compiler other than clang, the `compile_commands.json` file may contain compiler flags unknown by clang. When a clangd test is copied into the build directory and checked, clangd will pick the unknown flag from the file and cause a test failure. Create an empty `compile_commands.json` in the test directory nested in the build directory to override it. Reviewed By: thesamesam Differential Revision: https://reviews.llvm.org/D150582 (cherry picked from commit 4ddae8b)
1 parent 82b4446 commit 21f3dfb

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang-tools-extra/clangd/test/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ configure_lit_site_cfg(
2828
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
2929
)
3030

31+
# Copy an empty compile_commands.json to override the compile_commands.json
32+
# in the top level build directory. Or if a clangd test involves creating a
33+
# temporary source file in the build directory and run clangd to check it,
34+
# it can pick up unrecognizable command options when LLVM is built with
35+
# another compiler or a different version of Clang.
36+
configure_file(
37+
${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json
38+
${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
39+
)
40+
3141
add_lit_testsuite(check-clangd "Running the Clangd regression tests"
3242
# clangd doesn't put unittest configs in test/unit like every other project.
3343
# Because of that, this needs to pass two folders here, while every other
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

0 commit comments

Comments
 (0)