Skip to content

Remove -enable-astscope-lookup flag #33805

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

Merged

Conversation

slavapestov
Copy link
Contributor

No description provided.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@davidungar davidungar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So nice to see the old stuff go! My one comment is maybe the title of the PR, and/or the description needs more explanation. The changes go beyond, although may be a consequence of, just removing one flag.

Comment on lines -678 to -740

struct AddLabeledStmt {
StmtChecker ≻
AddLabeledStmt(StmtChecker &SC, LabeledStmt *LS) : SC(SC) {
// Verify that we don't have label shadowing.
auto sourceFile = SC.DC->getParentSourceFile();
checkLabeledStmtShadowing(SC.getASTContext(), sourceFile, LS);

// In any case, remember that we're in this labeled statement so that
// break and continue are aware of it.
SC.ActiveLabeledStmts.push_back(LS);

// Verify that the ASTScope-based query for active labeled statements
// is equivalent to what we have here.
if (LS->getStartLoc().isValid() && sourceFile &&
SC.getASTContext().LangOpts.EnableASTScopeLookup &&
!SC.getASTContext().Diags.hadAnyError() &&
!SC.LeaveBraceStmtBodyUnchecked) {
// The labeled statements from ASTScope lookup have the
// innermost labeled statement first, so reverse it to
// match the data structure maintained here.
auto activeFromASTScope = ASTScope::lookupLabeledStmts(
sourceFile, LS->getStartLoc());
assert(activeFromASTScope.front() == LS);
std::reverse(activeFromASTScope.begin(), activeFromASTScope.end());
if (activeFromASTScope != SC.ActiveLabeledStmts) {
llvm::errs() << "Old: ";
llvm::interleave(SC.ActiveLabeledStmts, [&](LabeledStmt *LS) {
llvm::errs() << LS;
}, [&] {
llvm::errs() << ' ';
});
llvm::errs() << "\nNew: ";
llvm::interleave(activeFromASTScope, [&](LabeledStmt *LS) {
llvm::errs() << LS;
}, [&] {
llvm::errs() << ' ';
});
llvm::errs() << "\n";
}
assert(activeFromASTScope == SC.ActiveLabeledStmts);
}
}
~AddLabeledStmt() {
SC.ActiveLabeledStmts.pop_back();
}
};

struct AddSwitchNest {
StmtChecker &SC;
CaseStmt *OuterFallthroughSource;
CaseStmt *OuterFallthroughDest;
AddSwitchNest(StmtChecker &SC)
: SC(SC),
OuterFallthroughSource(SC.FallthroughSource),
OuterFallthroughDest(SC.FallthroughDest) {
}

~AddSwitchNest() {
SC.FallthroughSource = OuterFallthroughSource;
SC.FallthroughDest = OuterFallthroughDest;
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious that this change belongs in a PR named "remove ... flag". Was it only used to cross-check ASTScopes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the old implementation of fall-through case statements. It's no longer needed since we can always use the new implementation. This change is also in a separate commit.

@slavapestov slavapestov force-pushed the remove-enable-astscope-lookup-flag branch from 4369aca to 193cf0d Compare September 4, 2020 23:59
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov merged commit 56f6d9e into swiftlang:master Sep 5, 2020
dabrahams pushed a commit that referenced this pull request Sep 14, 2020
-enable-astscope-lookup was removed in #33805
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants