summaryrefslogtreecommitdiffstats
path: root/lib/Tooling/Refactoring
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-11-01 00:07:12 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-11-01 00:07:12 +0000
commit3d102c8ddd12ab268a8484ee21f828ef5cd8f2c9 (patch)
tree7a7fb16ea72648261d13635c411ceed09d6fbc56 /lib/Tooling/Refactoring
parent8f5bfda4bc94a60372086d755198224a5497d87f (diff)
[refactor][selection] code ranges can be selected in objc methods
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@317054 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Tooling/Refactoring')
-rw-r--r--lib/Tooling/Refactoring/ASTSelection.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Tooling/Refactoring/ASTSelection.cpp b/lib/Tooling/Refactoring/ASTSelection.cpp
index 6ac432622c..71a0d44be1 100644
--- a/lib/Tooling/Refactoring/ASTSelection.cpp
+++ b/lib/Tooling/Refactoring/ASTSelection.cpp
@@ -347,6 +347,11 @@ CodeRangeASTSelection::create(SourceRange SelectionRange,
/*AreChildrenSelected=*/true);
}
+static bool isFunctionLikeDeclaration(const Decl *D) {
+ // FIXME (Alex L): Test for BlockDecl.
+ return isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D);
+}
+
bool CodeRangeASTSelection::isInFunctionLikeBodyOfCode() const {
bool IsPrevCompound = false;
// Scan through the parents (bottom-to-top) and check if the selection is
@@ -355,8 +360,7 @@ bool CodeRangeASTSelection::isInFunctionLikeBodyOfCode() const {
for (const auto &Parent : llvm::reverse(Parents)) {
const DynTypedNode &Node = Parent.get().Node;
if (const auto *D = Node.get<Decl>()) {
- // FIXME (Alex L): Test for BlockDecl && ObjCMethodDecl.
- if (isa<FunctionDecl>(D))
+ if (isFunctionLikeDeclaration(D))
return IsPrevCompound;
// FIXME (Alex L): We should return false on top-level decls in functions
// e.g. we don't want to extract:
@@ -372,8 +376,7 @@ const Decl *CodeRangeASTSelection::getFunctionLikeNearestParent() const {
for (const auto &Parent : llvm::reverse(Parents)) {
const DynTypedNode &Node = Parent.get().Node;
if (const auto *D = Node.get<Decl>()) {
- // FIXME (Alex L): Test for BlockDecl && ObjCMethodDecl.
- if (isa<FunctionDecl>(D))
+ if (isFunctionLikeDeclaration(D))
return D;
}
}