[clang-tools-extra] [clangd] Do not offer extraction to variable for decl init expression (PR #69477)

Christian Kandeler via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 19 08:30:38 PST 2024


================
@@ -490,6 +491,13 @@ bool eligibleForExtraction(const SelectionTree::Node *N) {
         BO->getRHS() == OuterImplicit.ASTNode.get<Expr>())
       return false;
   }
+  if (const auto *Decl = Parent->ASTNode.get<VarDecl>()) {
+    if (!Decl->isInitCapture() &&
----------------
ckandeler wrote:

Note also that there are already (pre-existing) tests for such selections, e.g.:
```
      {R"cpp(void f() {
                   int x = 1 + 2 + [[3 + 4 + 5]];
                 })cpp",
       R"cpp(void f() {
                   auto placeholder = 3 + 4 + 5; int x = 1 + 2 + placeholder;
                 })cpp"},
```

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


More information about the cfe-commits mailing list