[Serialization|NFC] Move free floating functions to methods

Move some deserialization error handling services to methods under ModuleFile.
This will give access to the ASTContext and allow to report diagnostics.

Also rename `consumeErrorIfXRefNonLoadedModule` into the more general
`consumeExpectedError` that is more appropriate for future improvements.
This commit is contained in:
Alexis Laferrière
2023-05-08 16:45:30 -07:00
parent f2b02c165d
commit e0014b4ed7
2 changed files with 23 additions and 9 deletions

View File

@@ -341,6 +341,12 @@ private:
template <typename T, typename ...Args>
T *createDecl(Args &&... args);
Decl *handleErrorAndSupplyMissingMiscMember(llvm::Error &&error) const;
Decl *handleErrorAndSupplyMissingMember(ASTContext &context,
Decl *container,
llvm::Error &&error) const;
public:
/// Change the status of the current module.
Status error(Status issue) {
@@ -404,6 +410,13 @@ public:
return llvm::consumeError(diagnoseFatal(msg));
}
/// Consume errors that are usually safe to ignore because they
/// are expected to support language features or caused by project
/// misconfigurations.
///
/// If the error is handled, success is returned, otherwise the original
/// error is returned.
llvm::Error consumeExpectedError(llvm::Error &&error);
/// Report an unexpected format error that could happen only from a
/// memory-level inconsistency. Please prefer passing an error to