[NFC] Drop llvm::Expected from Evaluation Points

A request is intended to be a pure function of its inputs. That function could, in theory, fail. In practice, there were basically no requests taking advantage of this ability - the few that were using it to explicitly detect cycles can just return reasonable defaults instead of forwarding the error on up the stack.

This is because cycles are checked by *the Evaluator*, and are unwound by the Evaluator.

Therefore, restore the idea that the evaluate functions are themselves pure, but keep the idea that *evaluation* of those requests may fail. This model enables the best of both worlds: we not only keep the evaluator flexible enough to handle future use cases like cancellation and diagnostic invalidation, but also request-based dependencies using the values computed at the evaluation points. These aforementioned use cases would use the llvm::Expected interface and the regular evaluation-point interface respectively.
This commit is contained in:
Robert Widmann
2020-03-26 18:27:46 -07:00
parent f2a1abc5dd
commit 987cd55f50
48 changed files with 374 additions and 367 deletions

View File

@@ -795,7 +795,7 @@ static void diagnoseMissingRequiredInitializer(
diag::required_initializer_here);
}
llvm::Expected<bool> AreAllStoredPropertiesDefaultInitableRequest::evaluate(
bool AreAllStoredPropertiesDefaultInitableRequest::evaluate(
Evaluator &evaluator, NominalTypeDecl *decl) const {
assert(!decl->hasClangNode());
@@ -849,7 +849,7 @@ static bool areAllStoredPropertiesDefaultInitializable(Evaluator &eval,
eval, AreAllStoredPropertiesDefaultInitableRequest{decl}, false);
}
llvm::Expected<bool>
bool
HasUserDefinedDesignatedInitRequest::evaluate(Evaluator &evaluator,
NominalTypeDecl *decl) const {
assert(!decl->hasClangNode());
@@ -1015,7 +1015,7 @@ static void addImplicitInheritedConstructorsToClass(ClassDecl *decl) {
}
}
llvm::Expected<bool>
bool
InheritsSuperclassInitializersRequest::evaluate(Evaluator &eval,
ClassDecl *decl) const {
// Check if we parsed the @_inheritsConvenienceInitializers attribute.
@@ -1085,7 +1085,7 @@ void TypeChecker::addImplicitConstructors(NominalTypeDecl *decl) {
(void)decl->getDefaultInitializer();
}
llvm::Expected<evaluator::SideEffect>
evaluator::SideEffect
ResolveImplicitMemberRequest::evaluate(Evaluator &evaluator,
NominalTypeDecl *target,
ImplicitMemberAction action) const {
@@ -1165,7 +1165,7 @@ ResolveImplicitMemberRequest::evaluate(Evaluator &evaluator,
return std::make_tuple<>();
}
llvm::Expected<bool>
bool
HasMemberwiseInitRequest::evaluate(Evaluator &evaluator,
StructDecl *decl) const {
if (!shouldAttemptInitializerSynthesis(decl))
@@ -1190,7 +1190,7 @@ HasMemberwiseInitRequest::evaluate(Evaluator &evaluator,
return false;
}
llvm::Expected<ConstructorDecl *>
ConstructorDecl *
SynthesizeMemberwiseInitRequest::evaluate(Evaluator &evaluator,
NominalTypeDecl *decl) const {
// Create the implicit memberwise constructor.
@@ -1201,7 +1201,7 @@ SynthesizeMemberwiseInitRequest::evaluate(Evaluator &evaluator,
return ctor;
}
llvm::Expected<ConstructorDecl *>
ConstructorDecl *
ResolveEffectiveMemberwiseInitRequest::evaluate(Evaluator &evaluator,
NominalTypeDecl *decl) const {
// Compute the access level for the memberwise initializer. The minimum of:
@@ -1288,7 +1288,7 @@ ResolveEffectiveMemberwiseInitRequest::evaluate(Evaluator &evaluator,
return memberwiseInitDecl;
}
llvm::Expected<bool>
bool
HasDefaultInitRequest::evaluate(Evaluator &evaluator,
NominalTypeDecl *decl) const {
assert(isa<StructDecl>(decl) || isa<ClassDecl>(decl));
@@ -1328,7 +1328,7 @@ synthesizeSingleReturnFunctionBody(AbstractFunctionDecl *afd, void *) {
/*isTypeChecked=*/true };
}
llvm::Expected<ConstructorDecl *>
ConstructorDecl *
SynthesizeDefaultInitRequest::evaluate(Evaluator &evaluator,
NominalTypeDecl *decl) const {
auto &ctx = decl->getASTContext();