[AST] NFC: Formalize Decl validation tracking via RAII

After this change, RAII ensures that the validation state is accurate as
possible.
This commit is contained in:
David Zarzycki
2018-05-16 07:51:05 -04:00
parent 274114d4a2
commit b29d2784ed
14 changed files with 173 additions and 136 deletions

View File

@@ -2103,7 +2103,11 @@ void ValueDecl::setInterfaceType(Type type) {
}
bool ValueDecl::hasValidSignature() const {
return hasInterfaceType() && !isBeingValidated();
if (!hasInterfaceType())
return false;
// FIXME -- The build blows up if the correct code is used:
// return getValidationState() > ValidationState::CheckingWithValidSignature;
return getValidationState() != ValidationState::Checking;
}
Optional<ObjCSelector> ValueDecl::getObjCRuntimeName() const {
@@ -2707,7 +2711,7 @@ SourceRange TypeAliasDecl::getSourceRange() const {
}
void TypeAliasDecl::setUnderlyingType(Type underlying) {
setValidationStarted();
setValidationToChecked();
// lldb creates global typealiases containing archetypes
// sometimes...
@@ -2925,7 +2929,7 @@ void ClassDecl::addImplicitDestructor() {
auto *DD = new (ctx) DestructorDecl(getLoc(), selfDecl, this);
DD->setImplicit();
DD->setValidationStarted();
DD->setValidationToChecked();
// Create an empty body for the destructor.
DD->setBody(BraceStmt::create(ctx, getLoc(), { }, getLoc(), true));
@@ -4507,7 +4511,7 @@ ParamDecl *ParamDecl::createSelf(SourceLoc loc, DeclContext *DC,
Identifier(), loc, C.Id_self, Type(), DC);
selfDecl->setImplicit();
selfDecl->setInterfaceType(selfInterfaceType);
selfDecl->setValidationStarted();
selfDecl->setValidationToChecked();
return selfDecl;
}