[clangd] Disallow extraction of expression-statements.
authorSam McCall <sam.mccall@gmail.com>
Fri, 9 Aug 2019 23:40:54 +0000 (23:40 +0000)
committerSam McCall <sam.mccall@gmail.com>
Fri, 9 Aug 2019 23:40:54 +0000 (23:40 +0000)
commit1aaef90c2aab94407b047ee82b8ed9d3aecd532f
treefaab5aae91c665df8a26f5dc13230c35aa29633f
parent795c3667d91010c486877563014092db1313644b
[clangd] Disallow extraction of expression-statements.

Summary:
I split out the "extract parent instead of this" logic from the "this isn't
worth extracting" logic (now in eligibleForExtraction()), because I found it
hard to reason about.

While here, handle overloaded as well as builtin assignment operators.

Also this uncovered a bug in getCallExpr() which I fixed.

Reviewers: SureYeaah

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65337

llvm-svn: 368500
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/Selection.h
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/unittests/SelectionTests.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp