[clang-tools-extra] [clangd] Handle lambda scopes inside Node::getDeclContext() (PR #76329)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 7 19:30:41 PST 2024


https://github.com/HighCommander4 approved this pull request.

Thanks, the change looks good to me!

I went through the existing callers of `Node::getDeclContext()`, and I was able to construct a test case where the patch actually changes behaviour (in a good way):

```c++
namespace NS {
void unrelated();
void foo();
}

auto L = [] {
  using NS::unrelated;
  NS::foo();
};
```

Here, if the "add using-declaration" code action is invoked on `NS::foo`, before this patch the result is:

```c++
namespace NS {
void unrelated();
void foo();
}

using NS::foo;

auto L = [] {
  using NS::unrelated;
  foo();
};
```

but after this patch the result is:

```c++
namespace NS {
void unrelated();
void foo();
}

auto L = [] {
  using NS::foo;
  using NS::unrelated;
  foo();
};
```

Let's add this test case to `AddUsingTests` while we're at it.

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


More information about the cfe-commits mailing list