diff options
-rw-r--r-- | clang/include/clang/Basic/VirtualFileSystem.h | 4 | ||||
-rw-r--r-- | clang/lib/Basic/VirtualFileSystem.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Frontend/ModuleDependencyCollector.cpp | 4 | ||||
-rw-r--r-- | clang/test/Modules/crash-vfs-path-symlink-component.m | 5 | ||||
-rw-r--r-- | clang/test/Modules/crash-vfs-path-traversal.m | 5 | ||||
-rw-r--r-- | clang/test/Modules/crash-vfs-relative-overlay.m | 3 |
6 files changed, 27 insertions, 7 deletions
diff --git a/clang/include/clang/Basic/VirtualFileSystem.h b/clang/include/clang/Basic/VirtualFileSystem.h index cc13d72a5b4..9b95158987e 100644 --- a/clang/include/clang/Basic/VirtualFileSystem.h +++ b/clang/include/clang/Basic/VirtualFileSystem.h @@ -325,6 +325,7 @@ class YAMLVFSWriter { std::vector<YAMLVFSEntry> Mappings; Optional<bool> IsCaseSensitive; Optional<bool> IsOverlayRelative; + Optional<bool> 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/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index dd41ed2651e..be7a637a73e 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -1504,8 +1504,9 @@ class JSONWriter { public: JSONWriter(llvm::raw_ostream &OS) : OS(OS) {} - void write(ArrayRef<YAMLVFSEntry> Entries, Optional<bool> IsCaseSensitive, - Optional<bool> IsOverlayRelative, StringRef OverlayDir); + void write(ArrayRef<YAMLVFSEntry> Entries, Optional<bool> UseExternalNames, + Optional<bool> IsCaseSensitive, Optional<bool> IsOverlayRelative, + StringRef OverlayDir); }; } @@ -1558,6 +1559,7 @@ void JSONWriter::writeEntry(StringRef VPath, StringRef RPath) { } void JSONWriter::write(ArrayRef<YAMLVFSEntry> Entries, + Optional<bool> UseExternalNames, Optional<bool> IsCaseSensitive, Optional<bool> IsOverlayRelative, StringRef OverlayDir) { @@ -1568,6 +1570,9 @@ void JSONWriter::write(ArrayRef<YAMLVFSEntry> 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/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp index 3e6c0d24750..02d3c515ef0 100644 --- a/clang/lib/Frontend/ModuleDependencyCollector.cpp +++ b/clang/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/clang/test/Modules/crash-vfs-path-symlink-component.m b/clang/test/Modules/crash-vfs-path-symlink-component.m index 674f80ea7f1..04c56ac5f4a 100644 --- a/clang/test/Modules/crash-vfs-path-symlink-component.m +++ b/clang/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/clang/test/Modules/crash-vfs-path-traversal.m b/clang/test/Modules/crash-vfs-path-traversal.m index 822a0dc2068..3377de47d0b 100644 --- a/clang/test/Modules/crash-vfs-path-traversal.m +++ b/clang/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/clang/test/Modules/crash-vfs-relative-overlay.m b/clang/test/Modules/crash-vfs-relative-overlay.m index d785d09bd82..870987c58ab 100644 --- a/clang/test/Modules/crash-vfs-relative-overlay.m +++ b/clang/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" */ |