[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 14 21:47:07 PST 2024
================
@@ -104,9 +104,12 @@ bool isRootStmt(const Node *N) {
// Root statement cannot be partially selected.
if (N->Selected == SelectionTree::Partial)
return false;
- // Only DeclStmt can be an unselected RootStmt since VarDecls claim the entire
- // selection range in selectionTree.
- if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get<DeclStmt>())
+ // A DeclStmt can be an unselected RootStmt since VarDecls claim the entire
+ // selection range in selectionTree. Additionally, a CXXOperatorCallExpr of a
+ // binary operation can be unselected because it's children claim the entire
+ // selection range in the selection tree (e.g. <<).
+ if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get<DeclStmt>() &&
----------------
HighCommander4 wrote:
I guess the difference is that a `DeclStmt` can have a **single** `VarDecl` child which could be completely selected, leaving the `DeclStmt` unselected. There is no analogous situation for a `CXXOperatorCallExpr` which has multiple children.
https://github.com/llvm/llvm-project/pull/81640
More information about the cfe-commits
mailing list