[clang-tools-extra] [clangd] Make clangd-indexer respect .clangd configuration files (PR #214951)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 31 23:04:28 PDT 2026


================
@@ -0,0 +1,25 @@
+# Test that clangd-indexer respects CompileFlags
+
+# RUN: rm -rf %t.dir && mkdir -p %t.dir
+# RUN: split-file %s %t.dir
+
+# By default config is disabled, so the .clangd file's CompileFlags.Add is not
+# applied and the #error below must fire.
+# RUN: clangd-indexer %t.dir/test.cpp 2>&1 | FileCheck --check-prefix=DISABLED %s
+# DISABLED: error: "FROM_CLANGD_FILE not defined - .clangd file was not applied"
+
+# With config enabled, the .clangd file's CompileFlags.Add should define
+# FROM_CLANGD_FILE, so the #error below must not fire.
+# RUN: clangd-indexer --enable-config %t.dir/test.cpp 2>&1 \
----------------
HighCommander4 wrote:

Please use `XDG_CONFIG_HOME=%t` the way [this test](https://searchfox.org/llvm/rev/76080a43202b5ae30f77f43845ecc9ca7a7b709d/clang-tools-extra/clangd/test/config.test#12) does. (Also needs [this](https://searchfox.org/llvm/rev/76080a43202b5ae30f77f43845ecc9ca7a7b709d/clang-tools-extra/clangd/test/config.test#1-3) to go along with it.)

Otherwise, the test is going to pick up `~/.config/clangd/config.yaml` in the home directory of whoever happens to be running it locally.

https://github.com/llvm/llvm-project/pull/214951


More information about the cfe-commits mailing list