Add all deserialization fatal output to the pretty stack trace

Rather than outputting diagnostics and to stderr, output all the extra
information added when deserialization fatally fails to the pretty stack
trace instead. Since the pretty stack trace is added to crash logs, this
should avoid the dance of requesting the compiler output

  - Moves the previous "**** DESERIALIZATION FAILURE ..." output to the
    last pretty stack trace line

  - Removes the module and compiler version notes added to the fatal
    diagnostic

  - Adds a new effective compiler version line for all frontend failure.
    Somewhat duplicates the line from the driver, but adds in the
    effective version

  - Adds a new line for the full misc version of the module that failed.
    May double up with previous "While reading from ..." lines that are
    added in various deserialization methods, but better to have it
    twice than not at all
This commit is contained in:
Ben Barham
2021-06-02 16:12:55 +10:00
parent dd543e630b
commit 599ba8bdbd
12 changed files with 123 additions and 125 deletions

View File

@@ -75,8 +75,6 @@ class ModuleFile
llvm::BitstreamCursor SILIndexCursor;
llvm::BitstreamCursor DeclMemberTablesCursor;
friend StringRef getNameOfModule(const ModuleFile *);
public:
static std::unique_ptr<llvm::MemoryBuffer> getModuleName(ASTContext &Ctx,
StringRef modulePath,
@@ -333,24 +331,27 @@ public:
return issue;
}
/// Emits one last diagnostic, logs the error, and then aborts for the stack
/// trace.
LLVM_ATTRIBUTE_NORETURN void fatal(llvm::Error error);
void fatalIfNotSuccess(llvm::Error error) {
/// Emits one last diagnostic, adds the current module details and errors to
/// the pretty stack trace, and then aborts.
LLVM_ATTRIBUTE_NORETURN void fatal(llvm::Error error) const;
void fatalIfNotSuccess(llvm::Error error) const {
if (error)
fatal(std::move(error));
}
template <typename T> T fatalIfUnexpected(llvm::Expected<T> expected) {
template <typename T> T fatalIfUnexpected(llvm::Expected<T> expected) const {
if (expected)
return std::move(expected.get());
fatal(expected.takeError());
}
LLVM_ATTRIBUTE_NORETURN void fatal() {
LLVM_ATTRIBUTE_NORETURN void fatal() const {
fatal(llvm::make_error<llvm::StringError>(
"(see \"While...\" info below)", llvm::inconvertibleErrorCode()));
}
/// Outputs information useful for diagnostics to \p out
void outputDiagnosticInfo(llvm::raw_ostream &os) const;
ASTContext &getContext() const {
assert(FileContext && "no associated context yet");
return FileContext->getParentModule()->getASTContext();