diff --git a/lib/FrontendTool/FrontendTool.cpp b/lib/FrontendTool/FrontendTool.cpp index d23a6c0afcc2e..8d8f579640d92 100644 --- a/lib/FrontendTool/FrontendTool.cpp +++ b/lib/FrontendTool/FrontendTool.cpp @@ -1986,12 +1986,18 @@ int swift::performFrontend(ArrayRef Args, auto configurationFileStackTraces = std::make_unique[]>( configurationFileBuffers.size()); - for_each(configurationFileBuffers.begin(), configurationFileBuffers.end(), - &configurationFileStackTraces[0], - [](const std::unique_ptr &buffer, - std::optional &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 &buffer, + std::optional &trace) { + trace.emplace(*buffer); + }); + } // The compiler invocation is now fully configured; notify our observer. if (observer) { diff --git a/test/Frontend/crash-whole-module.swift b/test/Frontend/crash-whole-module.swift new file mode 100644 index 0000000000000..2bac92594787a --- /dev/null +++ b/test/Frontend/crash-whole-module.swift @@ -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() diff --git a/test/Frontend/crash.swift b/test/Frontend/crash.swift index 476dff6089332..30374acd4b130 100644 --- a/test/Frontend/crash.swift +++ b/test/Frontend/crash.swift @@ -1,5 +1,10 @@ -// 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 @@ -7,9 +12,14 @@ // 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