diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-10-31 01:28:17 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-10-31 01:28:17 +0000 |
commit | b87b6bf73a37152e9c5765c3b78b568fcc2a0a00 (patch) | |
tree | 9024a6c7e63bac8a6735c91eaa4c6b031e549854 /clang/lib/Tooling/Refactoring | |
parent | 336c30e299f148f511f56b2a6d70a71ff2886d6e (diff) | |
download | bcm5719-llvm-b87b6bf73a37152e9c5765c3b78b568fcc2a0a00.tar.gz bcm5719-llvm-b87b6bf73a37152e9c5765c3b78b568fcc2a0a00.zip |
[refactor] select the entire DeclStmt if one ifs decls is selected
llvm-svn: 316971
Diffstat (limited to 'clang/lib/Tooling/Refactoring')
-rw-r--r-- | clang/lib/Tooling/Refactoring/ASTSelection.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/clang/lib/Tooling/Refactoring/ASTSelection.cpp b/clang/lib/Tooling/Refactoring/ASTSelection.cpp index 9d0683a2858..6ac432622c5 100644 --- a/clang/lib/Tooling/Refactoring/ASTSelection.cpp +++ b/clang/lib/Tooling/Refactoring/ASTSelection.cpp @@ -279,11 +279,23 @@ static void findDeepestWithKind( llvm::SmallVectorImpl<SelectedNodeWithParents> &MatchingNodes, SourceSelectionKind Kind, llvm::SmallVectorImpl<SelectedASTNode::ReferenceType> &ParentStack) { - if (!hasAnyDirectChildrenWithKind(ASTSelection, Kind)) { - // This node is the bottom-most. - MatchingNodes.push_back(SelectedNodeWithParents{ - std::cref(ASTSelection), {ParentStack.begin(), ParentStack.end()}}); - return; + if (ASTSelection.Node.get<DeclStmt>()) { + // Select the entire decl stmt when any of its child declarations is the + // bottom-most. + for (const auto &Child : ASTSelection.Children) { + if (!hasAnyDirectChildrenWithKind(Child, Kind)) { + MatchingNodes.push_back(SelectedNodeWithParents{ + std::cref(ASTSelection), {ParentStack.begin(), ParentStack.end()}}); + return; + } + } + } else { + if (!hasAnyDirectChildrenWithKind(ASTSelection, Kind)) { + // This node is the bottom-most. + MatchingNodes.push_back(SelectedNodeWithParents{ + std::cref(ASTSelection), {ParentStack.begin(), ParentStack.end()}}); + return; + } } // Search in the children. ParentStack.push_back(std::cref(ASTSelection)); |