Merge pull request #27786 from davidungar/fix-lazy-function-bodies-rdar-56384593

[NameLookup, ASTScope] Create lazily-parsed function body scopes.
This commit is contained in:
David Ungar
2019-10-18 21:48:28 -07:00
committed by GitHub
4 changed files with 39 additions and 26 deletions

View File

@@ -1359,8 +1359,8 @@ void AbstractFunctionDeclScope::expandAScopeThatDoesNotCreateANewInsertionPoint(
}
// Create scope for the body.
// We create body scopes when there is no body for source kit to complete
// erroneous code in bodies. But don't let compiler synthesize one.
if (decl->getBodySourceRange().isValid() && decl->getBody(false)) {
// erroneous code in bodies.
if (decl->getBodySourceRange().isValid()) {
if (AbstractFunctionBodyScope::isAMethod(decl))
scopeCreator.constructExpandAndInsertUncheckable<MethodBodyScope>(leaf,
decl);
@@ -1901,6 +1901,7 @@ void AbstractFunctionBodyScope::beCurrent() {
bodyWhenLastExpanded = decl->getBody(false);
}
bool AbstractFunctionBodyScope::isCurrentIfWasExpanded() const {
// Pass in false to keep the compiler from synthesizing one.
return bodyWhenLastExpanded == decl->getBody(false);
}