summaryrefslogtreecommitdiffstats
path: root/lib/Tooling/Refactoring
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-11-14 22:06:55 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-11-14 22:06:55 +0000
commit38cd6e2c89099bb19cc48f1663f1f54942fdbd81 (patch)
treef05dc8259f4757af3d910e6295f460663ae13c54 /lib/Tooling/Refactoring
parent12f3fe3bbd9e79d5623c39abd95e5ddc880fcb6d (diff)
[refactor][selection] canonicalize member expr callee to the full
member call expression We would like to extract the full call when just the callee is selected. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318205 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Tooling/Refactoring')
-rw-r--r--lib/Tooling/Refactoring/ASTSelection.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Tooling/Refactoring/ASTSelection.cpp b/lib/Tooling/Refactoring/ASTSelection.cpp
index 4f1168becf..ae8a3cb7c5 100644
--- a/lib/Tooling/Refactoring/ASTSelection.cpp
+++ b/lib/Tooling/Refactoring/ASTSelection.cpp
@@ -115,6 +115,11 @@ public:
return true;
if (auto *Opaque = dyn_cast<OpaqueValueExpr>(S))
return TraverseOpaqueValueExpr(Opaque);
+ // Avoid selecting implicit 'this' expressions.
+ if (auto *TE = dyn_cast<CXXThisExpr>(S)) {
+ if (TE->isImplicit())
+ return true;
+ }
// FIXME (Alex Lorenz): Improve handling for macro locations.
SourceSelectionKind SelectionKind =
selectionKindFor(CharSourceRange::getTokenRange(S->getSourceRange()));
@@ -268,9 +273,15 @@ void SelectedNodeWithParents::canonicalize() {
// ~~~~~~ ~~~~~~~
if (isa<StringLiteral>(S) && isa<ObjCStringLiteral>(Parent))
Node = Parents.pop_back_val();
+ // The entire call should be selected when just the member expression
+ // that refers to the method is selected.
+ // f.call(args) becomes f.call(args)
+ // ~~~~ ~~~~~~~~~~~~
+ else if (isa<MemberExpr>(S) && isa<CXXMemberCallExpr>(Parent) &&
+ cast<CXXMemberCallExpr>(Parent)->getCallee() == S)
+ Node = Parents.pop_back_val();
// FIXME: Syntactic form -> Entire pseudo-object expr.
// FIXME: Callee -> Call.
- // FIXME: Callee member expr -> Call.
}
/// Finds the set of bottom-most selected AST nodes that are in the selection