[clang-tools-extra] r367113 - [Clangd] Disable ExtractVariable for all types of assignments
Shaurya Gupta via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 26 07:08:27 PDT 2019
Author: sureyeaah
Date: Fri Jul 26 07:08:27 2019
New Revision: 367113
URL: http://llvm.org/viewvc/llvm-project?rev=367113&view=rev
Log:
[Clangd] Disable ExtractVariable for all types of assignments
Reviewers: sammccall, kadircet
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65332
Modified:
clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
Modified: clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp?rev=367113&r1=367112&r2=367113&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp (original)
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp Fri Jul 26 07:08:27 2019
@@ -272,7 +272,7 @@ bool ExtractVariable::computeExtractionC
// Extracting Exprs like a = 1 gives dummy = a = 1 which isn't useful.
if (const BinaryOperator *BinOpExpr =
dyn_cast_or_null<BinaryOperator>(SelectedExpr)) {
- if (BinOpExpr->getOpcode() == BinaryOperatorKind::BO_Assign)
+ if (BinOpExpr->isAssignmentOp())
return false;
}
// For function and member function DeclRefs, we look for a parent that is a
Modified: clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp?rev=367113&r1=367112&r2=367113&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp Fri Jul 26 07:08:27 2019
@@ -371,6 +371,8 @@ TEST(TweakTest, ExtractVariable) {
auto lamb = [&[[a]], &[[b]]](int r = [[1]]) {return 1;}
// assigment
[[a = 5]];
+ [[a >>= 5]];
+ [[a *= 5]];
// Variable DeclRefExpr
a = [[b]];
// label statement
More information about the cfe-commits
mailing list