-
Notifications
You must be signed in to change notification settings - Fork 10.5k
RangeInfo: Rework the criterion for valid selection of multiple statements, i.e. they should have a common brace statement as parent. #8129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ments, i.e. they should have a common brace statement as parent.
@swift-ci please smoke test |
@swift-ci please smoke test |
@@ -320,6 +320,11 @@ static bool hasUnhandledError(ArrayRef<ASTNode> Nodes) { | |||
}); | |||
} | |||
|
|||
static bool | |||
hasNodeThat(ArrayRef<ASTNode> Nodes, llvm::function_ref<bool(ASTNode)> Pred) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is any_of
in STLExtras.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I mean llvm::any_of
is just your hasNodeThat
with generics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's the case, I still prefer it extracted to avoid typing begin()
and end()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
llvm::any_of(StartMatches, IsCase)
. It's the same thing you have now.
|
||
// Multi-statement should have a common parent of brace statement, this | ||
// can be implicit brace statement, e.g. in case statement. | ||
if (Parent.isStmt(StmtKind::Brace)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where's the part that checks if they're all the same parent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The is implied in ContextInfo
; they won't end up here if they are not siblings.
@swift-ci please smoke test |
Suggested by @jrose-apple .