Skip to content

Commit 6d1b866

Browse files
committed
AST: Fix FuncDecl::getSourceRange() to do the right thing for accessors with synthesized bodies
1 parent 6f243d4 commit 6d1b866

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/AST/Decl.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5892,22 +5892,25 @@ ObjCSelector DestructorDecl::getObjCSelector() const {
58925892

58935893
SourceRange FuncDecl::getSourceRange() const {
58945894
SourceLoc StartLoc = getStartLoc();
5895-
if (StartLoc.isInvalid() ||
5896-
getBodyKind() == BodyKind::Synthesize)
5895+
5896+
if (StartLoc.isInvalid())
58975897
return SourceRange();
58985898

58995899
if (getBodyKind() == BodyKind::Unparsed ||
59005900
getBodyKind() == BodyKind::Skipped)
59015901
return { StartLoc, BodyRange.End };
59025902

5903-
if (auto *B = getBody()) {
5903+
if (auto *B = getBody(/*canSynthesize=*/false)) {
59045904
if (!B->isImplicit())
59055905
return { StartLoc, B->getEndLoc() };
59065906
}
59075907

59085908
if (isa<AccessorDecl>(this))
59095909
return StartLoc;
59105910

5911+
if (getBodyKind() == BodyKind::Synthesize)
5912+
return SourceRange();
5913+
59115914
auto TrailingWhereClauseSourceRange = getGenericTrailingWhereClauseSourceRange();
59125915
if (TrailingWhereClauseSourceRange.isValid())
59135916
return { StartLoc, TrailingWhereClauseSourceRange.End };

0 commit comments

Comments
 (0)