Skip to content

Commit f33f531

Browse files
committed
Fix source range on ReturnStmt with implicit Result
If Result is implicit, but the return itself is not, we might form an invalid SourceRange. This may not be exercised currently - I couldn't find a way to trigger the issue from the compiler. rdar://26638814
1 parent 4aa3f9c commit f33f531

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/AST/Stmt.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ SourceLoc ReturnStmt::getStartLoc() const {
153153
return ReturnLoc;
154154
}
155155
SourceLoc ReturnStmt::getEndLoc() const {
156-
return (Result ? Result->getEndLoc() : ReturnLoc);
156+
if (Result && Result->getEndLoc().isValid())
157+
return Result->getEndLoc();
158+
return ReturnLoc;
157159
}
158160

159161
SourceLoc ThrowStmt::getEndLoc() const { return SubExpr->getEndLoc(); }

0 commit comments

Comments
 (0)