[llvm-branch-commits] [clang-tools-extra] 21f3dfb - [clangd] Fix test failure when it's built with compiler flags unknown by clang
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue May 16 22:03:39 PDT 2023
Author: Xi Ruoyao
Date: 2023-05-16T22:03:06-07:00
New Revision: 21f3dfbc26736e4299c154e67065652f48279047
URL: https://github.com/llvm/llvm-project/commit/21f3dfbc26736e4299c154e67065652f48279047
DIFF: https://github.com/llvm/llvm-project/commit/21f3dfbc26736e4299c154e67065652f48279047.diff
LOG: [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 4ddae8b941398a6579d3a6f25aa39a260e441371)
Added:
clang-tools-extra/clangd/test/compile_commands.json
Modified:
clang-tools-extra/clangd/test/CMakeLists.txt
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/test/CMakeLists.txt b/clang-tools-extra/clangd/test/CMakeLists.txt
index 6bb578263ffc8..840fe2bdc12b0 100644
--- a/clang-tools-extra/clangd/test/CMakeLists.txt
+++ b/clang-tools-extra/clangd/test/CMakeLists.txt
@@ -28,6 +28,16 @@ configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
)
+# Copy an empty compile_commands.json to override the compile_commands.json
+# in the top level build directory. Or if a clangd test involves creating a
+# temporary source file in the build directory and run clangd to check it,
+# it can pick up unrecognizable command options when LLVM is built with
+# another compiler or a
diff erent version of Clang.
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json
+ ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
+)
+
add_lit_testsuite(check-clangd "Running the Clangd regression tests"
# clangd doesn't put unittest configs in test/unit like every other project.
# Because of that, this needs to pass two folders here, while every other
diff --git a/clang-tools-extra/clangd/test/compile_commands.json b/clang-tools-extra/clangd/test/compile_commands.json
new file mode 100644
index 0000000000000..fe51488c7066f
--- /dev/null
+++ b/clang-tools-extra/clangd/test/compile_commands.json
@@ -0,0 +1 @@
+[]
More information about the llvm-branch-commits
mailing list