mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Serialization] Add whether allowing errors to the pretty stack output
It's currently not obvious in crash reports whether compiling with errors is enabled or not. Since this option can make previously "impossible" paths now possible, add a message to both the pretty stack output and fatal deserialization diagnostics to point out that it is enabled.
This commit is contained in:
@@ -793,8 +793,9 @@ ERROR(serialization_fatal,Fatal,
|
|||||||
SWIFT_BUG_REPORT_MESSAGE,
|
SWIFT_BUG_REPORT_MESSAGE,
|
||||||
(StringRef))
|
(StringRef))
|
||||||
NOTE(serialization_misc_version,none,
|
NOTE(serialization_misc_version,none,
|
||||||
"module '%0' full misc version is '%1'",
|
"module '%0' full misc version is '%1'"
|
||||||
(StringRef, StringRef))
|
"%select{ (built while allowing compiler errors)|}2",
|
||||||
|
(StringRef, StringRef, bool))
|
||||||
NOTE(serialization_compatibility_version_mismatch,none,
|
NOTE(serialization_compatibility_version_mismatch,none,
|
||||||
"compiling as Swift %0, with '%1' built as Swift %2 "
|
"compiling as Swift %0, with '%1' built as Swift %2 "
|
||||||
"(this is supported but may expose additional compiler issues)",
|
"(this is supported but may expose additional compiler issues)",
|
||||||
|
|||||||
@@ -2046,6 +2046,11 @@ int swift::performFrontend(ArrayRef<const char *> Args,
|
|||||||
return finishDiagProcessing(1, /*verifierEnabled*/ false);
|
return finishDiagProcessing(1, /*verifierEnabled*/ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Optional<llvm::PrettyStackTraceString> allowErrorsStackTrace;
|
||||||
|
if (Invocation.getFrontendOptions().AllowModuleWithCompilerErrors)
|
||||||
|
allowErrorsStackTrace.emplace("While allowing modules with compiler errors "
|
||||||
|
"enabled");
|
||||||
|
|
||||||
// Make an array of PrettyStackTrace objects to dump the configuration files
|
// Make an array of PrettyStackTrace objects to dump the configuration files
|
||||||
// we used to parse the arguments. These are RAII objects, so they and the
|
// we used to parse the arguments. These are RAII objects, so they and the
|
||||||
// buffers they refer to must be kept alive in order to be useful. (That is,
|
// buffers they refer to must be kept alive in order to be useful. (That is,
|
||||||
|
|||||||
@@ -169,8 +169,9 @@ static void skipRecord(llvm::BitstreamCursor &cursor, unsigned recordKind) {
|
|||||||
void ModuleFile::fatal(llvm::Error error) {
|
void ModuleFile::fatal(llvm::Error error) {
|
||||||
if (FileContext) {
|
if (FileContext) {
|
||||||
getContext().Diags.diagnose(SourceLoc(), diag::serialization_fatal, Core->Name);
|
getContext().Diags.diagnose(SourceLoc(), diag::serialization_fatal, Core->Name);
|
||||||
getContext().Diags.diagnose(SourceLoc(), diag::serialization_misc_version,
|
getContext().Diags.diagnose(
|
||||||
Core->Name, Core->MiscVersion);
|
SourceLoc(), diag::serialization_misc_version, Core->Name,
|
||||||
|
Core->MiscVersion, allowCompilerErrors());
|
||||||
|
|
||||||
if (!Core->CompatibilityVersion.empty()) {
|
if (!Core->CompatibilityVersion.empty()) {
|
||||||
if (getContext().LangOpts.EffectiveLanguageVersion
|
if (getContext().LangOpts.EffectiveLanguageVersion
|
||||||
@@ -6706,3 +6707,9 @@ Optional<ForeignAsyncConvention> ModuleFile::maybeReadForeignAsyncConvention() {
|
|||||||
completionHandlerErrorFlagParamIndex,
|
completionHandlerErrorFlagParamIndex,
|
||||||
errorFlagPolarity);
|
errorFlagPolarity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void serialization::PrettyStackTraceModuleFile::outputModuleBuildInfo(
|
||||||
|
raw_ostream &os) const {
|
||||||
|
if (MF.compiledAllowingCompilerErrors())
|
||||||
|
os << " (built while allowing compiler errors)";
|
||||||
|
}
|
||||||
|
|||||||
@@ -470,8 +470,12 @@ public:
|
|||||||
: PrettyStackTraceModuleFile("While reading from", module) {}
|
: PrettyStackTraceModuleFile("While reading from", module) {}
|
||||||
|
|
||||||
void print(raw_ostream &os) const override {
|
void print(raw_ostream &os) const override {
|
||||||
os << Action << " \'" << getNameOfModule(&MF) << "'\n";
|
os << Action << " \'" << getNameOfModule(&MF) << "'";
|
||||||
|
outputModuleBuildInfo(os);
|
||||||
|
os << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void outputModuleBuildInfo(raw_ostream &os) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PrettyStackTraceModuleFileCore : public llvm::PrettyStackTraceEntry {
|
class PrettyStackTraceModuleFileCore : public llvm::PrettyStackTraceEntry {
|
||||||
|
|||||||
@@ -10,6 +10,11 @@
|
|||||||
// CHECK-NEXT: test{{[\\/]}}Frontend{{[\\/]}}crash.swift{{$}}
|
// CHECK-NEXT: test{{[\\/]}}Frontend{{[\\/]}}crash.swift{{$}}
|
||||||
// CHECK-NEXT: ---
|
// CHECK-NEXT: ---
|
||||||
|
|
||||||
|
// Check that a message when allowing errors is output
|
||||||
|
// RUN: not --crash %target-swift-frontend -typecheck -debug-crash-after-parse -experimental-allow-module-with-compiler-errors %s 2>&1 | %FileCheck -check-prefix CHECK-ALLOW %s
|
||||||
|
// CHECK-ALLOW-LABEL: Stack dump
|
||||||
|
// CHECK-ALLOW: While allowing modules with compiler errors enabled
|
||||||
|
|
||||||
func anchor() {}
|
func anchor() {}
|
||||||
anchor()
|
anchor()
|
||||||
|
|
||||||
|
|||||||
16
test/Serialization/AllowErrors/crash-adds-message.swift
Normal file
16
test/Serialization/AllowErrors/crash-adds-message.swift
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// RUN: %empty-directory(%t)
|
||||||
|
// RUN: touch %t/empty.swift
|
||||||
|
|
||||||
|
// RUN: %target-swift-frontend -emit-module -o %t/errors.partial.swiftmodule -module-name errors -experimental-allow-module-with-compiler-errors %s
|
||||||
|
// RUN: %target-swift-frontend -emit-module -o %t/errorsempty.partial.swiftmodule -module-name errors %t/empty.swift
|
||||||
|
|
||||||
|
// Note - running the merge without allow errors to force a crash, we want
|
||||||
|
// to check if there's a message about allowing compiler errors for the
|
||||||
|
// deserialized module
|
||||||
|
// RUN: not --crash %target-swift-frontend -module-name errors -emit-module -o %t/errors.swiftmodule %t/errors.partial.swiftmodule %t/errorsempty.partial.swiftmodule 2>&1 | %FileCheck %s
|
||||||
|
|
||||||
|
// REQUIRES: asserts
|
||||||
|
|
||||||
|
typealias AnAlias = SomeStruct
|
||||||
|
|
||||||
|
// CHECK: While reading from 'errors' (built while allowing compiler errors)
|
||||||
19
test/Serialization/AllowErrors/invalid-alias.swift
Normal file
19
test/Serialization/AllowErrors/invalid-alias.swift
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
// RUN: %empty-directory(%t)
|
||||||
|
|
||||||
|
// RUN: touch %t/empty.swift
|
||||||
|
// RUN: %{python} %utils/split_file.py -o %t %s
|
||||||
|
|
||||||
|
// RUN: %target-swift-frontend -verify -emit-module -o %t/errors.partial.swiftmodule -module-name errors -experimental-allow-module-with-compiler-errors %t/errors.swift
|
||||||
|
// RUN: %target-swift-frontend -emit-module -o %t/errorsempty.partial.swiftmodule -module-name errors %t/empty.swift
|
||||||
|
|
||||||
|
// RUN: %target-swift-frontend -module-name errors -emit-module -o %t/errors.swiftmodule -experimental-allow-module-with-compiler-errors %t/errors.partial.swiftmodule %t/errorsempty.partial.swiftmodule
|
||||||
|
|
||||||
|
// RUN: %target-swift-frontend -emit-module -o %t/mods/uses.swiftmodule -experimental-allow-module-with-compiler-errors -I %t/mods %t/uses.swift 2>&1 | %FileCheck -check-prefix=CHECK-USES %s
|
||||||
|
|
||||||
|
// BEGIN errors.swift
|
||||||
|
typealias AnAlias = undefined // expected-error {{cannot find type 'undefined'}}
|
||||||
|
|
||||||
|
// BEGIN uses.swift
|
||||||
|
import errors
|
||||||
|
func test(a: AnAlias) {}
|
||||||
|
// CHECK-USES-NOT: cannot find type 'AnAlias' in scope
|
||||||
Reference in New Issue
Block a user