refactoring: when RangeInfo is of kind PartOfExpression, we should use the dedicated field to get the parent expression. rdar://36755861 (#14088)

This commit is contained in:
Xi Ge
2018-01-23 12:53:50 -08:00
committed by GitHub
parent 689ddaada9
commit cf36346021
2 changed files with 27 additions and 7 deletions

View File

@@ -1684,16 +1684,25 @@ bool RefactoringActionCollapseNestedIfExpr::performChange() {
}
static std::unique_ptr<llvm::SetVector<Expr*>>
findConcatenatedExpressions(ResolvedRangeInfo Info, ASTContext &Ctx) {
if (Info.Kind != RangeKind::SingleExpression
&& Info.Kind != RangeKind::PartOfExpression)
return nullptr;
findConcatenatedExpressions(ResolvedRangeInfo Info, ASTContext &Ctx) {
Expr *E = nullptr;
// FIXME: We should always have a valid node.
if (Info.ContainedNodes.empty())
switch (Info.Kind) {
case RangeKind::SingleExpression:
// FIXME: the range info kind should imply non-empty list.
if (!Info.ContainedNodes.empty())
E = Info.ContainedNodes[0].get<Expr*>();
else
return nullptr;
break;
case RangeKind::PartOfExpression:
E = Info.CommonExprParent;
break;
default:
return nullptr;
}
Expr *E = Info.ContainedNodes[0].get<Expr*>();
assert(E);
struct StringInterpolationExprFinder: public SourceEntityWalker {
std::unique_ptr<llvm::SetVector<Expr*>> Bucket = llvm::