Skip to content

Commit d43099f

Browse files
authored
Merge pull request #10387 from DougGregor/ast-verifier-parsed
2 parents 77de3dc + d40e869 commit d43099f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/AST/ASTVerifier.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,28 @@ class Verifier : public ASTWalker {
463463
bool shouldVerifyChecked(Pattern *S) { return S->hasType(); }
464464
bool shouldVerifyChecked(Decl *S) { return true; }
465465

466+
// Only verify functions if they have bodies we can safely walk.
467+
// FIXME: This is a bit of a hack; we should be able to check the
468+
// invariants of a parsed body as well.
469+
bool shouldVerify(AbstractFunctionDecl *afd) {
470+
switch (afd->getBodyKind()) {
471+
case AbstractFunctionDecl::BodyKind::None:
472+
case AbstractFunctionDecl::BodyKind::TypeChecked:
473+
case AbstractFunctionDecl::BodyKind::Skipped:
474+
case AbstractFunctionDecl::BodyKind::MemberwiseInitializer:
475+
return true;
476+
477+
case AbstractFunctionDecl::BodyKind::Unparsed:
478+
case AbstractFunctionDecl::BodyKind::Parsed:
479+
case AbstractFunctionDecl::BodyKind::Synthesize:
480+
if (auto SF = dyn_cast<SourceFile>(afd->getModuleScopeContext())) {
481+
return SF->ASTStage < SourceFile::TypeChecked;
482+
}
483+
484+
return false;
485+
}
486+
}
487+
466488
// Default cases for cleaning up as we exit a node.
467489
void cleanup(Expr *E) { }
468490
void cleanup(Stmt *S) { }

0 commit comments

Comments
 (0)