abrachet updated this revision to Diff 417754.
abrachet added a comment.
Herald added a subscriber: arphaman.

Fix test failures outside of Driver/


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122335/new/

https://reviews.llvm.org/D122335

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-diagnostics-dir.c
  clang/test/Driver/crash-report-clang-cl.cpp
  clang/test/Driver/crash-report-header.h
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-spaces.c
  clang/test/Driver/crash-report-with-asserts.c
  clang/test/Driver/crash-report.cpp
  clang/test/Driver/rewrite-map-in-diagnostics.c
  clang/test/Index/create-libclang-completion-reproducer.c
  clang/test/Index/create-libclang-parsing-reproducer.c
  clang/test/Modules/crash-vfs-path-emptydir-entries.m
  clang/test/Modules/crash-vfs-path-symlink-component.m
  clang/test/Modules/crash-vfs-path-symlink-topheader.m
  clang/test/Modules/crash-vfs-path-traversal.m
  clang/test/Modules/crash-vfs-relative-overlay.m
  clang/test/Modules/crash-vfs-umbrella-frameworks.m

Index: clang/test/Modules/crash-vfs-umbrella-frameworks.m
===================================================================
--- clang/test/Modules/crash-vfs-umbrella-frameworks.m
+++ clang/test/Modules/crash-vfs-umbrella-frameworks.m
@@ -14,14 +14,12 @@
 // RUN:     -F %/t/i/Frameworks -fmodules \
 // RUN:     -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN:         %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "B.framework/Headers/B.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml" \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKYAML:      'type': 'directory',
 // CHECKYAML:      'name': "/[[PATH:.*]]/i/Frameworks/A.framework/Frameworks/B.framework/Headers",
@@ -39,6 +37,8 @@
 // CHECKYAML-NEXT:          'name': "B.h",
 // CHECKYAML-NEXT:          'external-contents': "/[[PATH]]/i/Frameworks/B.framework/Headers/B.h"
 
+// CHECKTAR: B.framework/Headers/B.h
+
 @import I;
 
 // Run the reproducer script - regular exit code is enough to test it works. The
@@ -51,5 +51,6 @@
 // RUN: cd %t
 // RUN: rm -rf i
 // RUN: rm -rf crash-vfs-umbrella-*.cache/modules/*
-// RUN: chmod 755 crash-vfs-*.sh
-// RUN: ./crash-vfs-*.sh
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh" > repro.sh
+// RUN: chmod 755 repro.sh
+// RUN: ./repro.sh
Index: clang/test/Modules/crash-vfs-relative-overlay.m
===================================================================
--- clang/test/Modules/crash-vfs-relative-overlay.m
+++ clang/test/Modules/crash-vfs-relative-overlay.m
@@ -11,18 +11,18 @@
 // RUN:     -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/ \
 // RUN:     -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-vfs-*.m"      \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"               \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml"       \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 #include <stdio.h>
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKSRC: #pragma clang module import cstd.stdio
 
@@ -49,6 +49,8 @@
 // CHECKYAML-NEXT:     'external-contents': "/[[PATH]]/Inputs/crash-recovery/usr/include/module.map"
 // CHECKYAML-NEXT:   },
 
+// CHECKTAR: Inputs/crash-recovery/usr/include/stdio.h
+
 // Test that reading the YAML file will yield the correct path after
 // the overlay dir is prefixed to access headers in .cache/vfs directory.
 
Index: clang/test/Modules/crash-vfs-path-traversal.m
===================================================================
--- clang/test/Modules/crash-vfs-path-traversal.m
+++ clang/test/Modules/crash-vfs-path-traversal.m
@@ -13,18 +13,18 @@
 // RUN: not %clang -fsyntax-only %s -I %S/Inputs/crash-recovery -isysroot %/t/i/ \
 // RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-vfs-*.m" \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"          \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml" \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 #include "usr/././//////include/../include/./././../include/stdio.h"
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKSRC: #pragma clang module import cstd.stdio
 
@@ -50,6 +50,8 @@
 // CHECKYAML-NEXT:     'external-contents': "/[[PATH]]/Inputs/crash-recovery/usr/include/module.map"
 // CHECKYAML-NEXT:   },
 
+// CHECKTAR: Inputs/crash-recovery/usr/include/stdio.h
+
 // Replace the paths in the YAML files with relative ".." traversals
 // and fed into clang to test whether we're correctly representing them
 // in the VFS overlay.
Index: clang/test/Modules/crash-vfs-path-symlink-topheader.m
===================================================================
--- clang/test/Modules/crash-vfs-path-symlink-topheader.m
+++ clang/test/Modules/crash-vfs-path-symlink-topheader.m
@@ -16,18 +16,18 @@
 // RUN: not %clang -fsyntax-only %s -I %/t/i -isysroot %/t/sysroot/ \
 // RUN:     -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "usr/include/pthread_impl.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-vfs-*.m" \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"          \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml" \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 #include "usr/include/stdio.h"
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKSRC: #pragma clang module import cstd.stdio
 
@@ -49,3 +49,5 @@
 // CHECKYAML-NEXT:     'name': "pthread_impl.h",
 // CHECKYAML-NEXT:     'external-contents': "/{{.*}}/i/usr/include/pthread_impl.h"
 // CHECKYAML-NEXT:   },
+
+// CHECKTAR: usr/include/pthread_impl.h
Index: clang/test/Modules/crash-vfs-path-symlink-component.m
===================================================================
--- clang/test/Modules/crash-vfs-path-symlink-component.m
+++ clang/test/Modules/crash-vfs-path-symlink-component.m
@@ -15,18 +15,18 @@
 // RUN: not %clang -fsyntax-only %s -I %/t/i -isysroot %/t/sysroot/ \
 // RUN:     -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "usr/include/stdio.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-vfs-*.m" \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"          \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml" \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 #include "usr/x/../stdio.h"
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKSRC: #pragma clang module import cstd.stdio
 
@@ -53,6 +53,8 @@
 // CHECKYAML-NEXT:     'external-contents': "/[[PATH]]/i/usr/include/module.map"
 // CHECKYAML-NEXT:   },
 
+// CHECKTAR: usr/include/stdio.h
+
 // Test that by using the previous generated YAML file clang is able to find the
 // right files inside the overlay and map the virtual request for a path that
 // previously contained a symlink to work. To make sure of this, wipe out the
Index: clang/test/Modules/crash-vfs-path-emptydir-entries.m
===================================================================
--- clang/test/Modules/crash-vfs-path-emptydir-entries.m
+++ clang/test/Modules/crash-vfs-path-emptydir-entries.m
@@ -14,18 +14,18 @@
 // RUN: not %clang -fsyntax-only %s -I %/t/i -isysroot %/t/sysroot/ \
 // RUN:     -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "usr/include/stdio.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-vfs-*.m" \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"          \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml"  \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 #include "usr/include/stdio.h"
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKSRC: #pragma clang module import cstd.stdio
 
@@ -47,3 +47,5 @@
 // CHECKYAML-NEXT:     'name': "pthread_impl.h",
 // CHECKYAML-NEXT:     'external-contents': "/{{.*}}/i/usr/include/pthread_impl.h"
 // CHECKYAML-NEXT:   },
+
+// CHECKTAR: usr/include/stdio.h
Index: clang/test/Index/create-libclang-parsing-reproducer.c
===================================================================
--- clang/test/Index/create-libclang-parsing-reproducer.c
+++ clang/test/Index/create-libclang-parsing-reproducer.c
@@ -17,5 +17,5 @@
 
 // CHECK: REPRODUCER:
 // CHECK-NEXT: {
-// CHECK-NEXT: "files":["{{.*}}.c","{{.*}}.sh"]
+// CHECK-NEXT: "files":["{{.*}}.tar"]
 // CHECK-NEXT: }
Index: clang/test/Index/create-libclang-completion-reproducer.c
===================================================================
--- clang/test/Index/create-libclang-completion-reproducer.c
+++ clang/test/Index/create-libclang-completion-reproducer.c
@@ -10,5 +10,5 @@
 
 // CHECK: REPRODUCER:
 // CHECK-NEXT: {
-// CHECK-NEXT: "files":["{{.*}}.c","{{.*}}.sh"]
+// CHECK-NEXT: "files":["{{.*}}.tar"]
 // CHECK-NEXT: }
Index: clang/test/Driver/rewrite-map-in-diagnostics.c
===================================================================
--- clang/test/Driver/rewrite-map-in-diagnostics.c
+++ clang/test/Driver/rewrite-map-in-diagnostics.c
@@ -3,9 +3,15 @@
 // RUN: env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTION=1 \
 // RUN:     not %clang -fsyntax-only -frewrite-map-file=%p/Inputs/rewrite.map %s 2>&1 \
 // RUN:   | FileCheck %s
+// RUN: tar tf %t/*.tar | sort | FileCheck --check-prefix=CHECKTAR %s
 
 #pragma clang __debug parser_crash
 
-// CHECK: note: diagnostic msg: {{.*}}rewrite.map
+// CHECK: note: diagnostic msg: {{.*}}.tar
+
+// CHECKTAR: {{.*}}/input/rewrite-map-in-diagnostics.c
+// CHECKTAR-NEXT: {{.*}}/input/rewrite.map
+// CHECKTAR-NEXT: {{.*}}/repro.sh
+// CHECKTAR-NEXT: {{.*}}/tmp/rewrite-map-in-diagnostics-{{.*}}.c
 
 // REQUIRES: crash-recovery
Index: clang/test/Driver/crash-report.cpp
===================================================================
--- clang/test/Driver/crash-report.cpp
+++ clang/test/Driver/crash-report.cpp
@@ -12,20 +12,30 @@
 // RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1                  \
 // RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1                         \
 // RUN:  not %clang %s @%t.rsp -DPARSER 2>&1 | FileCheck %s
-// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
-// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-report-*.cpp"          \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"                        \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+
+// RUN: rm -f %t/*.tar
 
 // RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1                  \
 // RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1                         \
 // RUN:  not %clang %s @%t.rsp -DCRASH 2>&1 | FileCheck %s
-// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
-// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-report-*.cpp"          \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"                        \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+
+// RUN: rm -f %t/*.tar
 
 // RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1                  \
 // RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1                         \
 // RUN:  not %clang %s @%t.rsp -DFATAL 2>&1 | FileCheck %s
-// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
-// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-report-*.cpp"          \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"                        \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
 
 // REQUIRES: crash-recovery
 
@@ -38,7 +48,7 @@
 #endif
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-{{.*}}.cpp
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // __has_feature(cxx_exceptions) is default-on in the gcc-compatible driver.
 FOO
Index: clang/test/Driver/crash-report-with-asserts.c
===================================================================
--- clang/test/Driver/crash-report-with-asserts.c
+++ clang/test/Driver/crash-report-with-asserts.c
@@ -12,14 +12,20 @@
 // RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1                  \
 // RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1                         \
 // RUN:  not %clang %s @%t.rsp -DASSERT 2>&1 | FileCheck %s
-// RUN: cat %t/crash-report-*.c | FileCheck --check-prefix=CHECKSRC %s
-// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-report-*.c"            \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"                        \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+
+// RUN: rm -f %t/*.tar
 
 // RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1                  \
 // RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1                         \
 // RUN:  not %clang %s @%t.rsp -DUNREACHABLE 2>&1 | FileCheck %s
-// RUN: cat %t/crash-report-with-asserts-*.c | FileCheck --check-prefix=CHECKSRC %s
-// RUN: cat %t/crash-report-with-asserts-*.sh | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-report-*.c"            \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"                        \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
 
 // REQUIRES: crash-recovery, asserts
 
@@ -30,7 +36,7 @@
 #endif
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-with-asserts-{{.*}}.c
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 FOO
 // CHECKSRC: FOO
 // CHECKSH: # Crash reproducer
Index: clang/test/Driver/crash-report-spaces.c
===================================================================
--- clang/test/Driver/crash-report-spaces.c
+++ clang/test/Driver/crash-report-spaces.c
@@ -2,13 +2,13 @@
 // RUN: mkdir "%t"
 // RUN: cp "%s" "%t/crash report spaces.c"
 // RUN: env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTIONS=1 not %clang -fsyntax-only "%t/crash report spaces.c" 2>&1 | FileCheck "%s"
-// RUN: cat "%t/crash report spaces"-*.c | FileCheck --check-prefix=CHECKSRC "%s"
-// RUN: cat "%t/crash report spaces"-*.sh | FileCheck --check-prefix=CHECKSH "%s"
+// RUN: tar xOf %t/*.tar --wildcards "*/crash report spaces-*.c" | FileCheck --check-prefix=CHECKSRC "%s"
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh" | FileCheck --check-prefix=CHECKSH "%s"
 // REQUIRES: crash-recovery
 
 #pragma clang __debug parser_crash
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.c
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 FOO
 // CHECKSRC: FOO
 // CHECKSH: "-cc1"
Index: clang/test/Driver/crash-report-modules.m
===================================================================
--- clang/test/Driver/crash-report-modules.m
+++ clang/test/Driver/crash-report-modules.m
@@ -8,8 +8,12 @@
 // RUN: not %clang -fsyntax-only %s -I %S/Inputs/module -isysroot %/t/i/                 \
 // RUN: -fmodules -fmodules-cache-path=%T/crmdir/m/ -DFOO=BAR 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %T/crmdir/crash-report-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %T/crmdir/crash-report-*.sh
+// RUN: tar tf %T/crmdir/*.tar | sort | FileCheck %s --check-prefix=CHECKTAR
+
+// RUN: tar xOf %T/crmdir/*.tar --wildcards "*/tmp/crash-report-modules-*.m" \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %T/crmdir/*.tar --wildcards "*/repro.sh" \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
 // REQUIRES: crash-recovery
 
 // FIXME: This test creates excessively deep directory hierarchies that cause
@@ -21,8 +25,15 @@
 
 // CHECK: PLEASE submit a bug report to {{.*}} and include the crash backtrace, preprocessed source, and associated run script.
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
+
+// CHECKTAR: {{.*}}/repro.sh
+// CHECKTAR-NEXT: {{.*}}/tmp/crash-report-modules-{{.*}}.m
+// CHECKTAR-NEXT: {{.*}}/tmp/modules/{{.*}}/modules.idx
+// CHECKTAR-NEXT: {{.*}}/tmp/modules/{{.*}}/simple-{{.*}}.pcm
+// CHECKTAR-NEXT: {{.*}}/tmp/vfs/{{.*}}/module/module.modulemap
+// CHECKTAR-NEXT: {{.*}}/tmp/vfs/{{.*}}/module/simple.h
+// CHECKTAR-NEXT: {{.*}}/tmp/vfs/vfs.yaml
 
 // CHECKSRC: @import simple;
 // CHECKSRC: const int x = 10;
Index: clang/test/Driver/crash-report-header.h
===================================================================
--- clang/test/Driver/crash-report-header.h
+++ clang/test/Driver/crash-report-header.h
@@ -1,13 +1,13 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTIONS=1 not %clang -fsyntax-only %s 2>&1 | FileCheck %s
-// RUN: cat %t/crash-report-header-*.h | FileCheck --check-prefix=CHECKSRC "%s"
-// RUN: cat %t/crash-report-header-*.sh | FileCheck --check-prefix=CHECKSH "%s"
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-report-header-*.h" | FileCheck --check-prefix=CHECKSRC "%s"
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh" | FileCheck --check-prefix=CHECKSH "%s"
 // REQUIRES: crash-recovery
 
 #pragma clang __debug parser_crash
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.h
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 FOO
 // CHECKSRC: FOO
 // CHECKSH: "-cc1"
Index: clang/test/Driver/crash-report-clang-cl.cpp
===================================================================
--- clang/test/Driver/crash-report-clang-cl.cpp
+++ clang/test/Driver/crash-report-clang-cl.cpp
@@ -3,8 +3,12 @@
 
 // RUN: not %clang_cl -fsyntax-only /Brepro /source-charset:utf-8 \
 // RUN:     -fcrash-diagnostics-dir=%t -- %s 2>&1 | FileCheck %s
-// RUN: cat %t/crash-report-clang-cl-*.cpp | FileCheck --check-prefix=CHECKSRC %s
-// RUN: cat %t/crash-report-clang-cl-*.sh | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-report-clang-cl-*.cpp" \
+// RUN:     | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh" \
+// RUN:     | FileCheck --check-prefix=CHECKSH %s
+// RN: cat %t/crash-report-clang-cl-*.cpp | FileCheck --check-prefix=CHECKSRC %s
+// RN: cat %t/crash-report-clang-cl-*.sh | FileCheck --check-prefix=CHECKSH %s
 
 // REQUIRES: crash-recovery
 
@@ -32,7 +36,7 @@
 // CHECKSRC-NEXT: {{^}}int a = 0;
 // CHECKSRC-NEXT: {{^}}#endif
 
-// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-clang-cl-{{.*}}.cpp
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 // CHECKSH: # Crash reproducer
 // CHECKSH-NEXT: # Driver args: {{.*}}"-fsyntax-only"
 // CHECKSH-SAME: /Brepro
Index: clang/test/Driver/crash-diagnostics-dir.c
===================================================================
--- clang/test/Driver/crash-diagnostics-dir.c
+++ clang/test/Driver/crash-diagnostics-dir.c
@@ -2,4 +2,4 @@
 // RUN: not %clang -fcrash-diagnostics-dir=%t -c %s -o - 2>&1 | FileCheck %s
 #pragma clang __debug parser_crash
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK: diagnostic msg: {{.*}}{{/|\\}}crash-diagnostics-dir.c.tmp{{(/|\\).*}}.c
+// CHECK: diagnostic msg: {{.*}}{{/|\\}}crash-diagnostics-dir.c.tmp{{(/|\\).*}}.tar
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -90,8 +90,10 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TarWriter.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
+#include <functional>
 #include <map>
 #include <memory>
 #include <utility>
@@ -1390,6 +1392,34 @@
   return false;
 }
 
+static std::pair<std::unique_ptr<llvm::TarWriter>, std::string>
+openReproTarFile(Driver &D, Compilation &C) {
+  SmallString<64> TmpName;
+  if (Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_dir))
+    TmpName = A->getValue();
+  else
+    llvm::sys::path::system_temp_directory(/*ErasedOnReboot*/ true, TmpName);
+
+  if (!D.getVFS().exists(TmpName))
+    llvm::sys::fs::create_directories(TmpName);
+
+  llvm::sys::path::append(TmpName, "%%%%%%.tar");
+  std::error_code EC = llvm::sys::fs::createUniqueFile(TmpName, TmpName);
+  if (EC) {
+    D.Diag(clang::diag::err_unable_to_make_temp) << EC.message();
+    return {};
+  }
+
+  auto TarWriterOrErr =
+      llvm::TarWriter::create(TmpName, llvm::sys::path::stem(TmpName));
+  if (!TarWriterOrErr) {
+    D.Diag(clang::diag::err_unable_to_make_temp) << TmpName;
+    return {};
+  }
+
+  return {std::move(*TarWriterOrErr), TmpName.c_str()};
+}
+
 // When clang crashes, produce diagnostic information including the fully
 // preprocessed source file(s).  Request that the developer attach the
 // diagnostic information to a bug report.
@@ -1504,17 +1534,46 @@
     return;
   }
 
-  Diag(clang::diag::note_drv_command_failed_diag_msg)
-      << "\n********************\n\n"
-         "PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n"
-         "Preprocessed source(s) and associated run script(s) are located at:";
+  std::unique_ptr<llvm::TarWriter> TarWriter;
+  std::string ReproFileName;
+  std::tie(TarWriter, ReproFileName) = openReproTarFile(*this, C);
+  if (!TarWriter) {
+    Diag(clang::diag::note_drv_command_failed_diag_msg)
+        << "Error generating preprocessed source(s). - cannot open tar file";
+    return;
+  }
+
+  std::function<void(StringRef, std::string)> WriteFileToTar =
+      [&WriteFileToTar, &TarWriter](StringRef FSPath, std::string TarPath) {
+        if (llvm::sys::fs::is_directory(FSPath)) {
+          using llvm::sys::fs::recursive_directory_iterator;
+          std::error_code EC;
+          for (recursive_directory_iterator I{FSPath, EC}, E; I != E && !EC;
+               I.increment(EC)) {
+            // Skip over the base path of the dir. i.e., if
+            // WriteFileToTar("a/b/dir", "tmp/"), where dir has "c" and "d"
+            // "a/b/dir/c" -> "dir/", so this will be put into the tar file at
+            // "tmp/dir/c" and "tmp/dir/d".
+            std::string Path = I->path();
+            Path = Path.data() + FSPath.size() + 1;
+            llvm::SmallString<32> Prefix{Path.begin(), Path.end()};
+            llvm::sys::path::remove_filename(Prefix);
+            if (I->type() == llvm::sys::fs::file_type::regular_file)
+              WriteFileToTar(I->path(), (TarPath + Prefix + "/").str());
+          }
+        }
+        auto MBOrErr = llvm::MemoryBuffer::getFile(FSPath);
+        if (!MBOrErr)
+          return;
+
+        TarPath += llvm::sys::path::filename(FSPath);
+        TarWriter->append(TarPath, MBOrErr->get()->getBuffer());
+      };
 
   SmallString<128> VFS;
   SmallString<128> ReproCrashFilename;
   for (const char *TempFile : TempFiles) {
-    Diag(clang::diag::note_drv_command_failed_diag_msg) << TempFile;
-    if (Report)
-      Report->TemporaryFiles.push_back(TempFile);
+    WriteFileToTar(TempFile, "tmp/");
     if (ReproCrashFilename.empty()) {
       ReproCrashFilename = TempFile;
       llvm::sys::path::replace_extension(ReproCrashFilename, ".crash");
@@ -1527,39 +1586,40 @@
     }
   }
 
+  for (const auto &A : C.getArgs().filtered(options::OPT_frewrite_map_file_EQ,
+                                            options::OPT_INPUT))
+    WriteFileToTar(A->getValue(), "input/");
+
   // Assume associated files are based off of the first temporary file.
   CrashReportInfo CrashInfo(TempFiles[0], VFS);
 
   llvm::SmallString<128> Script(CrashInfo.Filename);
-  llvm::sys::path::replace_extension(Script, "sh");
-  std::error_code EC;
-  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew,
-                                llvm::sys::fs::FA_Write,
-                                llvm::sys::fs::OF_Text);
-  if (EC) {
-    Diag(clang::diag::note_drv_command_failed_diag_msg)
-        << "Error generating run script: " << Script << " " << EC.message();
-  } else {
-    ScriptOS << "# Crash reproducer for " << getClangFullVersion() << "\n"
-             << "# Driver args: ";
-    printArgList(ScriptOS, C.getInputArgs());
-    ScriptOS << "# Original command: ";
-    Cmd.Print(ScriptOS, "\n", /*Quote=*/true);
-    Cmd.Print(ScriptOS, "\n", /*Quote=*/true, &CrashInfo);
-    if (!AdditionalInformation.empty())
-      ScriptOS << "\n# Additional information: " << AdditionalInformation
-               << "\n";
-    if (Report)
-      Report->TemporaryFiles.push_back(std::string(Script.str()));
-    Diag(clang::diag::note_drv_command_failed_diag_msg) << Script;
-  }
+  std::string Storage;
+  llvm::raw_string_ostream ScriptOS{Storage};
+  ScriptOS << "# Crash reproducer for " << getClangFullVersion() << "\n"
+           << "# Driver args: ";
+  printArgList(ScriptOS, C.getInputArgs());
+  ScriptOS << "# Original command: ";
+  Cmd.Print(ScriptOS, "\n", /*Quote=*/true);
+  Cmd.Print(ScriptOS, "\n", /*Quote=*/true, &CrashInfo);
+  if (!AdditionalInformation.empty())
+    ScriptOS << "\n# Additional information: " << AdditionalInformation << "\n";
+  TarWriter->append("repro.sh", Storage);
+
+  Diag(clang::diag::note_drv_command_failed_diag_msg)
+      << "\n********************\n\n"
+         "PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n"
+         "Preprocessed source(s) and associated run script(s) are located at:";
+
+  Diag(clang::diag::note_drv_command_failed_diag_msg) << ReproFileName;
+  if (Report)
+    Report->TemporaryFiles.push_back(ReproFileName);
 
   // On darwin, provide information about the .crash diagnostic report.
   if (llvm::Triple(llvm::sys::getProcessTriple()).isOSDarwin()) {
     SmallString<128> CrashDiagDir;
     if (getCrashDiagnosticFile(ReproCrashFilename, CrashDiagDir)) {
-      Diag(clang::diag::note_drv_command_failed_diag_msg)
-          << ReproCrashFilename.str();
+      WriteFileToTar(ReproCrashFilename.str(), "");
     } else { // Suggest a directory for the user to look for .crash files.
       llvm::sys::path::append(CrashDiagDir, Name);
       CrashDiagDir += "_<YYYY-MM-DD-HHMMSS>_<hostname>.crash";
@@ -1572,9 +1632,6 @@
     }
   }
 
-  for (const auto &A : C.getArgs().filtered(options::OPT_frewrite_map_file_EQ))
-    Diag(clang::diag::note_drv_command_failed_diag_msg) << A->getValue();
-
   Diag(clang::diag::note_drv_command_failed_diag_msg)
       << "\n\n********************";
 }
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -72,6 +72,10 @@
   constants that are not representable in a casted value. For example,
   ``(float) f == 0.1`` is always false.
 
+- Crash diagnostics are now aggregated into a single tar file instead of
+  being split across many temp files. Moreover, input files are written into
+  the output tar file as well.
+
 Non-comprehensive list of changes in this release
 -------------------------------------------------
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to