Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1986,12 +1986,18 @@ int swift::performFrontend(ArrayRef<const char *> Args,
auto configurationFileStackTraces =
std::make_unique<std::optional<PrettyStackTraceFileContents>[]>(
configurationFileBuffers.size());
for_each(configurationFileBuffers.begin(), configurationFileBuffers.end(),
&configurationFileStackTraces[0],
[](const std::unique_ptr<llvm::MemoryBuffer> &buffer,
std::optional<PrettyStackTraceFileContents> &trace) {
trace.emplace(*buffer);
});

// If the compile is a whole module job, then the contents of the filelist
// is every file in the module, which is not very interesting and could be
// hundreds or thousands of lines. Skip dumping this output in that case.
if (!Invocation.getFrontendOptions().InputsAndOutputs.isWholeModule()) {
for_each(configurationFileBuffers.begin(), configurationFileBuffers.end(),
&configurationFileStackTraces[0],
[](const std::unique_ptr<llvm::MemoryBuffer> &buffer,
std::optional<PrettyStackTraceFileContents> &trace) {
trace.emplace(*buffer);
});
}

// The compiler invocation is now fully configured; notify our observer.
if (observer) {
Expand Down
14 changes: 14 additions & 0 deletions test/Frontend/crash-whole-module.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: %empty-directory(%t)
// RUN: echo %s > %t/filelist.txt
// RUN: not --crash %target-swift-frontend -typecheck -debug-crash-after-parse -filelist %t/filelist.txt 2>&1 | %FileCheck %s

// CHECK-LABEL: Stack dump
// CHECK-NEXT: Program arguments: {{.*swift(-frontend)?(c?)(\.exe)?}}
// CHECK-NEXT: Swift version
// CHECK-NEXT: Compiling with effective version

// Filelist contents should be omitted since this is a whole-module compile.
// CHECK-NOT: Contents of

func anchor() {}
anchor()
18 changes: 14 additions & 4 deletions test/Frontend/crash.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
// RUN: echo %s > %t.filelist.txt
// RUN: not --crash %target-swift-frontend -typecheck -debug-crash-after-parse -filelist %t.filelist.txt 2>&1 | %FileCheck %s
// RUN: %empty-directory(%t)
// RUN: echo %s > %t/primary.filelist.txt
// RUN: echo "" > %t/empty.swift
// RUN: echo "%t/empty.swift" > %t/all.filelist.txt
// RUN: echo %s >> %t/all.filelist.txt

// RUN: not --crash %target-swift-frontend -typecheck -debug-crash-after-parse -primary-filelist %t/primary.filelist.txt -filelist %t/all.filelist.txt 2>&1 | %FileCheck %s

// Check that we see the contents of the input file list in the crash log.
// CHECK-NOT: while allowing modules with compiler errors
// CHECK-LABEL: Stack dump
// CHECK-NEXT: Program arguments: {{.*swift(-frontend)?(c?)(\.exe)?}}
// CHECK-NEXT: Swift version
// CHECK-NEXT: Compiling with effective version
// CHECK-NEXT: Contents of {{.*}}.filelist.txt:
// CHECK-NEXT: Contents of {{.*}}/all.filelist.txt:
// CHECK-NEXT: ---
// CHECK-NEXT: {{[\\/]}}empty.swift{{$}}
// CHECK-NEXT: {{[\\/]}}crash.swift{{$}}
// CHECK-NEXT: ---
// CHECK-NEXT: Contents of {{.*}}/primary.filelist.txt:
// CHECK-NEXT: ---
// CHECK-NEXT: test{{[\\/]}}Frontend{{[\\/]}}crash.swift{{$}}
// CHECK-NEXT: {{[\\/]}}crash.swift{{$}}
// CHECK-NEXT: ---

// 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
Expand Down