Skip to content

Commit efcb5e3

Browse files
committed
[Frontend] Add whether allowing compiler errors to the pretty stacktrace
While this will be in the compiler arguments, it's easy to miss when skimming over the pretty stacktrace. Add an explicit message to make it easier to see while looking over crashes.
1 parent 594faba commit efcb5e3

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,19 +1813,22 @@ createJSONFixItDiagnosticConsumerIfNeeded(
18131813

18141814
/// A PrettyStackTraceEntry to print frontend information useful for debugging.
18151815
class PrettyStackTraceFrontend : public llvm::PrettyStackTraceEntry {
1816-
const LangOptions &LangOpts;
1816+
const CompilerInvocation &Invocation;
18171817

18181818
public:
1819-
PrettyStackTraceFrontend(const LangOptions &langOpts)
1820-
: LangOpts(langOpts) {}
1819+
PrettyStackTraceFrontend(const CompilerInvocation &invocation)
1820+
: Invocation(invocation) {}
18211821

18221822
void print(llvm::raw_ostream &os) const override {
1823-
auto effective = LangOpts.EffectiveLanguageVersion;
1823+
auto effective = Invocation.getLangOptions().EffectiveLanguageVersion;
18241824
if (effective != version::Version::getCurrentLanguageVersion()) {
18251825
os << "Compiling with effective version " << effective;
18261826
} else {
18271827
os << "Compiling with the current language version";
18281828
}
1829+
if (Invocation.getFrontendOptions().AllowModuleWithCompilerErrors) {
1830+
os << " while allowing modules with compiler errors";
1831+
}
18291832
os << "\n";
18301833
};
18311834
};
@@ -1936,7 +1939,7 @@ int swift::performFrontend(ArrayRef<const char *> Args,
19361939
/// (leaks checking is not thread safe).
19371940
Invocation.getSILOptions().checkSILModuleLeaks = true;
19381941

1939-
PrettyStackTraceFrontend frontendTrace(Invocation.getLangOptions());
1942+
PrettyStackTraceFrontend frontendTrace(Invocation);
19401943

19411944
// Make an array of PrettyStackTrace objects to dump the configuration files
19421945
// we used to parse the arguments. These are RAII objects, so they and the

test/Frontend/crash.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: not --crash %target-swift-frontend -typecheck -debug-crash-after-parse -filelist %t.filelist.txt 2>&1 | %FileCheck %s
33

44
// Check that we see the contents of the input file list in the crash log.
5-
// CHECK-NOT: Compiling with {{.*}} while allowing modules with compiler errors enabled
5+
// CHECK-NOT: while allowing modules with compiler errors
66
// CHECK-LABEL: Stack dump
77
// CHECK-NEXT: Program arguments: {{.*swift(-frontend)?(c?)(\.exe)?}}
88
// CHECK-NEXT: Swift version
@@ -14,12 +14,11 @@
1414

1515
// 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
1616
// CHECK-ALLOW: Program arguments: {{.*}} -experimental-allow-module-with-compiler-errors
17-
// CHECK-ALLOW: Compiling with effective version
17+
// CHECK-ALLOW: Compiling with effective version {{.*}} while allowing modules with compiler errors
1818

1919
// RUN: not --crash %target-swift-frontend -typecheck -debug-crash-after-parse -experimental-allow-module-with-compiler-errors -swift-version 5 %s 2>&1 | %FileCheck -check-prefix CHECK-CURRENT %s
2020
// CHECK-CURRENT: Program arguments: {{.*}} -experimental-allow-module-with-compiler-errors
21-
// CHECK-CURRENT: Compiling with the current language version
21+
// CHECK-CURRENT: Compiling with the current language version while allowing modules with compiler errors
2222

2323
func anchor() {}
2424
anchor()
25-

0 commit comments

Comments
 (0)