summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling/Refactoring/ASTSelection.cpp
diff options
context:
space:
mode:
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