1// REQUIRES: crash-recovery, shell 2// UNSUPPORTED: ms-sdk, ps4 3 4// FIXME: Canonicalizing paths to remove relative traversal components 5// currenty fails a unittest on windows and is disable by default. 6// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it? 7// XFAIL: windows-gnu 8 9// RUN: rm -rf %t 10// RUN: mkdir -p %t/i %t/m %t 11 12// RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \ 13// RUN: not %clang -fsyntax-only %s -I %S/Inputs/crash-recovery -isysroot %/t/i/ \ 14// RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s 15 16// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m 17// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh 18// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \ 19// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml 20// RUN: find %t/crash-vfs-*.cache/vfs | \ 21// RUN: grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1 22 23#include "usr/././//////include/../include/./././../include/stdio.h" 24 25// CHECK: Preprocessed source(s) and associated run script(s) are located at: 26// CHECK-NEXT: note: diagnostic msg: {{.*}}.m 27// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache 28 29// CHECKSRC: #pragma clang module import cstd.stdio 30 31// CHECKSH: # Crash reproducer 32// CHECKSH-NEXT: # Driver args: "-fsyntax-only" 33// CHECKSH-NEXT: # Original command: {{.*$}} 34// CHECKSH-NEXT: "-cc1" 35// CHECKSH: "-isysroot" "{{[^"]*}}/i/" 36// CHECKSH-NOT: "-fmodules-cache-path=" 37// CHECKSH: "crash-vfs-{{[^ ]*}}.m" 38// CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" 39// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules" 40 41// CHECKYAML: 'case-sensitive': 42// CHECKYAML-NEXT: 'use-external-names': 'false', 43// CHECKYAML-NEXT: 'overlay-relative': 'true', 44// CHECKYAML: 'type': 'directory' 45// CHECKYAML: 'name': "/[[PATH:.*]]/Inputs/crash-recovery/usr/include", 46// CHECKYAML-NEXT: 'contents': [ 47// CHECKYAML-NEXT: { 48// CHECKYAML-NEXT: 'type': 'file', 49// CHECKYAML-NEXT: 'name': "module.map", 50// CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/Inputs/crash-recovery/usr/include/module.map" 51// CHECKYAML-NEXT: }, 52 53// Replace the paths in the YAML files with relative ".." traversals 54// and fed into clang to test whether we're correctly representing them 55// in the VFS overlay. 56 57// RUN: sed -e "s@usr/include@usr/include/../include@g" \ 58// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml > %t/vfs.yaml 59// RUN: cp %t/vfs.yaml %t/crash-vfs-*.cache/vfs/vfs.yaml 60// RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH 61// RUN: %clang -E %s -I %S/Inputs/crash-recovery -isysroot %/t/i/ \ 62// RUN: -ivfsoverlay %t/crash-vfs-*.cache/vfs/vfs.yaml -fmodules \ 63// RUN: -fmodules-cache-path=%t/m/ 2>&1 \ 64// RUN: | FileCheck %s --check-prefix=CHECKOVERLAY 65 66// CHECKOVERLAY: #pragma clang module import cstd.stdio /* clang -E: implicit import 67