[clang-tools-extra] [clangd] Fix crash on completion with out-of-range position (PR #196112)

Krzysztof Jędruczyk via cfe-commits cfe-commits at lists.llvm.org
Wed May 6 10:04:42 PDT 2026


kjedruczyk wrote:

E.g. If I change this path in following way:

```c++
  if (!Offset) {
    vlog("could not convert position '{0}' to offset for file '{1}': {2}",
         Params.position, Params.textDocument.uri.file(), Offset.takeError());
    return true; // completion code will log the error for invalid position.
  }
```

We'll get the vlog output:

```
I[18:02:49.090] <-- textDocument/completion(1)
V[18:02:49.090] could not convert position '97:0' to offset for file '/tmp/test.cpp': Line value is out of range (97)
E[18:02:49.091] Code completion position was invalid Line value is out of range (97)
I[18:02:49.091] --> reply:textDocument/completion(1) 0 ms
```

I guess it is nicer than consuming the error?

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


More information about the cfe-commits mailing list