[clang-tools-extra] [clangd] Fix SIGSEGV crash when receiving a textDocument/didOpen request with the URI pointing to a directory (PR #177834)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 1 23:38:30 PST 2026


================
@@ -0,0 +1,26 @@
+# RUN: not --crash clangd -lit-test < %s 2> %t.err
----------------
HighCommander4 wrote:

This is unfortunately poorly documented (I could only find a [comment in the source](https://searchfox.org/llvm/rev/8e7a2d8b42534b5a05df4445ee05f9a19161a8a1/llvm/utils/not/not.cpp#8-12)), but the purpose of `not --crash` is to check that a command **does** crash.

In this case, clangd shouldn't crash, so there's no need to use `not`, the command can just be `clangd -lit-test ...`.

We can also simplify a bit by piping to `FileCheck` like so, which avoids using a temporary file:

```
RUN: clangd -lit-test < %s | FileCheck %s
```

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


More information about the cfe-commits mailing list