summaryrefslogtreecommitdiff
path: root/lib/Tooling/Refactoring/ASTSelection.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-10-31 01:28:17 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-10-31 01:28:17 +0000
commited8a16203bd96d50875a9ce3dff6ada8daa50cff (patch)
tree600fbddd36beef6a073f48f8571cabdd819eb2b9 /lib/Tooling/Refactoring/ASTSelection.cpp
parent597fe911c137f5d3ccd6678925a0848d2cc1455e (diff)
downloadclang-ed8a16203bd96d50875a9ce3dff6ada8daa50cff.tar.gz
[refactor] select the entire DeclStmt if one ifs decls is selected
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316971 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Tooling/Refactoring/ASTSelection.cpp')
-rw-r--r--lib/Tooling/Refactoring/ASTSelection.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/Tooling/Refactoring/ASTSelection.cpp b/lib/Tooling/Refactoring/ASTSelection.cpp
index 9d0683a285..6ac432622c 100644
--- a/lib/Tooling/Refactoring/ASTSelection.cpp
+++ b/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));