From: Bruno Cardoso Lopes Date: Wed, 13 Apr 2016 19:28:21 +0000 (+0000) Subject: [CrashReproducer] Setup 'use-external-names' in YAML files. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=acc90c3a8e86a9b1454ec76a86888171ba5d8bf4;p=clang [CrashReproducer] Setup 'use-external-names' in YAML files. Hide the real paths when rebuilding from VFS by setting up the crash reproducer to use 'use-external-names' = false. This way we avoid module redifinition errors and consistently use the same paths against all modules. With this change on Darwin we are able to simulate a crash for a simple application using "Foundation/Foundation.h" (which relies on a bunch of different frameworks and headers) and successfully rebuild all the modules by relying solely at the VFS overlay. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@266234 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/VirtualFileSystem.h b/include/clang/Basic/VirtualFileSystem.h index cc13d72a5b..9b95158987 100644 --- a/include/clang/Basic/VirtualFileSystem.h +++ b/include/clang/Basic/VirtualFileSystem.h @@ -325,6 +325,7 @@ class YAMLVFSWriter { std::vector Mappings; Optional IsCaseSensitive; Optional IsOverlayRelative; + Optional UseExternalNames; std::string OverlayDir; public: @@ -333,6 +334,9 @@ public: void setCaseSensitivity(bool CaseSensitive) { IsCaseSensitive = CaseSensitive; } + void setUseExternalNames(bool UseExtNames) { + UseExternalNames = UseExtNames; + } void setOverlayDir(StringRef OverlayDirectory) { IsOverlayRelative = true; OverlayDir.assign(OverlayDirectory.str()); diff --git a/lib/Basic/VirtualFileSystem.cpp b/lib/Basic/VirtualFileSystem.cpp index dd41ed2651..be7a637a73 100644 --- a/lib/Basic/VirtualFileSystem.cpp +++ b/lib/Basic/VirtualFileSystem.cpp @@ -1504,8 +1504,9 @@ class JSONWriter { public: JSONWriter(llvm::raw_ostream &OS) : OS(OS) {} - void write(ArrayRef Entries, Optional IsCaseSensitive, - Optional IsOverlayRelative, StringRef OverlayDir); + void write(ArrayRef Entries, Optional UseExternalNames, + Optional IsCaseSensitive, Optional IsOverlayRelative, + StringRef OverlayDir); }; } @@ -1558,6 +1559,7 @@ void JSONWriter::writeEntry(StringRef VPath, StringRef RPath) { } void JSONWriter::write(ArrayRef Entries, + Optional UseExternalNames, Optional IsCaseSensitive, Optional IsOverlayRelative, StringRef OverlayDir) { @@ -1568,6 +1570,9 @@ void JSONWriter::write(ArrayRef Entries, if (IsCaseSensitive.hasValue()) OS << " 'case-sensitive': '" << (IsCaseSensitive.getValue() ? "true" : "false") << "',\n"; + if (UseExternalNames.hasValue()) + OS << " 'use-external-names': '" + << (UseExternalNames.getValue() ? "true" : "false") << "',\n"; bool UseOverlayRelative = false; if (IsOverlayRelative.hasValue()) { UseOverlayRelative = IsOverlayRelative.getValue(); @@ -1629,8 +1634,8 @@ void YAMLVFSWriter::write(llvm::raw_ostream &OS) { return LHS.VPath < RHS.VPath; }); - JSONWriter(OS).write(Mappings, IsCaseSensitive, IsOverlayRelative, - OverlayDir); + JSONWriter(OS).write(Mappings, UseExternalNames, IsCaseSensitive, + IsOverlayRelative, OverlayDir); } VFSFromYamlDirIterImpl::VFSFromYamlDirIterImpl( diff --git a/lib/Frontend/ModuleDependencyCollector.cpp b/lib/Frontend/ModuleDependencyCollector.cpp index 3e6c0d2475..02d3c515ef 100644 --- a/lib/Frontend/ModuleDependencyCollector.cpp +++ b/lib/Frontend/ModuleDependencyCollector.cpp @@ -112,6 +112,10 @@ void ModuleDependencyCollector::writeFileMap() { // the sensitivity at the path where the headers all collected to. VFSWriter.setCaseSensitivity(isCaseSensitivePath(VFSDir)); + // Do not rely on real path names when executing the crash reproducer scripts + // since we only want to actually use the files we have on the VFS cache. + VFSWriter.setUseExternalNames(false); + std::error_code EC; SmallString<256> YAMLPath = VFSDir; llvm::sys::path::append(YAMLPath, "vfs.yaml"); diff --git a/test/Modules/crash-vfs-path-symlink-component.m b/test/Modules/crash-vfs-path-symlink-component.m index 674f80ea7f..04c56ac5f4 100644 --- a/test/Modules/crash-vfs-path-symlink-component.m +++ b/test/Modules/crash-vfs-path-symlink-component.m @@ -40,6 +40,9 @@ // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" // CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules" +// CHECKYAML: 'case-sensitive': +// CHECKYAML-NEXT: 'use-external-names': 'false', +// CHECKYAML-NEXT: 'overlay-relative': 'true', // CHECKYAML: 'type': 'directory' // CHECKYAML: 'name': "/[[PATH:.*]]/i/usr/include", // CHECKYAML-NEXT: 'contents': [ @@ -70,4 +73,4 @@ // RUN: -fmodules-cache-path=%t/m/ 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECKOVERLAY -// CHECKOVERLAY: @import cstd.stdio; /* clang -E: implicit import for "{{[^ ]*}}.cache/vfs/{{[^ ]*}}/i/usr/include/stdio.h" +// CHECKOVERLAY: @import cstd.stdio; /* clang -E: implicit import for "/{{[^ ].*}}/i/usr/x/../stdio.h" */ diff --git a/test/Modules/crash-vfs-path-traversal.m b/test/Modules/crash-vfs-path-traversal.m index 822a0dc206..3377de47d0 100644 --- a/test/Modules/crash-vfs-path-traversal.m +++ b/test/Modules/crash-vfs-path-traversal.m @@ -37,6 +37,9 @@ // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml" // CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules" +// CHECKYAML: 'case-sensitive': +// CHECKYAML-NEXT: 'use-external-names': 'false', +// CHECKYAML-NEXT: 'overlay-relative': 'true', // CHECKYAML: 'type': 'directory' // CHECKYAML: 'name': "/[[PATH:.*]]/Inputs/crash-recovery/usr/include", // CHECKYAML-NEXT: 'contents': [ @@ -59,4 +62,4 @@ // RUN: -fmodules-cache-path=%t/m/ 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECKOVERLAY -// CHECKOVERLAY: @import cstd.stdio; /* clang -E: implicit import for "{{[^ ]*}}.cache/vfs/{{[^ ]*}}/usr/include/stdio.h" +// CHECKOVERLAY: @import cstd.stdio; /* clang -E: implicit import for "/{{[^ ].*}}/usr/././//////include/../include/./././../include/stdio.h" */ diff --git a/test/Modules/crash-vfs-relative-overlay.m b/test/Modules/crash-vfs-relative-overlay.m index d785d09bd8..870987c58a 100644 --- a/test/Modules/crash-vfs-relative-overlay.m +++ b/test/Modules/crash-vfs-relative-overlay.m @@ -37,6 +37,7 @@ // CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules" // CHECKYAML: 'case-sensitive': +// CHECKYAML-NEXT: 'use-external-names': 'false', // CHECKYAML-NEXT: 'overlay-relative': 'true', // CHECKYAML: 'type': 'directory' // CHECKYAML: 'name': "/[[PATH:.*]]/Inputs/crash-recovery/usr/include", @@ -57,4 +58,4 @@ // RUN: -fmodules-cache-path=%t/m/ 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECKOVERLAY -// CHECKOVERLAY: @import cstd.stdio; /* clang -E: implicit import for "{{[^ ]*}}.cache/vfs/{{[^ ]*}}/usr/include/stdio.h" +// CHECKOVERLAY: @import cstd.stdio; /* clang -E: implicit import for "/{{[^ ].*}}/usr/include/stdio.h" */