summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling/Refactoring/ASTSelection.cpp
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
commit7cd48cd8a96185dfc9b4ba2b4ee364bbac1e068b (patch)
tree3d3b5f46dac73a038577a973ccb1b47be8d1361a /clang/lib/Tooling/Refactoring/ASTSelection.cpp
parent173b47ca059e7c6399ad6957dd89761a7d2fffa4 (diff)
downloadbcm5719-llvm-7cd48cd8a96185dfc9b4ba2b4ee364bbac1e068b.tar.gz
bcm5719-llvm-7cd48cd8a96185dfc9b4ba2b4ee364bbac1e068b.zip
[refactor][selection] code ranges can be selected in objc methods
llvm-svn: 317054
Diffstat (limited to 'clang/lib/Tooling/Refactoring/ASTSelection.cpp')
-rw-r--r--clang/lib/Tooling/Refactoring/ASTSelection.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/Tooling/Refactoring/ASTSelection.cpp b/clang/lib/Tooling/Refactoring/ASTSelection.cpp
index 6ac432622c5..71a0d44be1d 100644
--- a/clang/lib/Tooling/Refactoring/ASTSelection.cpp
+++ b/clang/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;
}
}
OpenPOWER on IntegriCloud