Skip to content

Commit 9dd73ba

Browse files
authored
Merge pull request #2895 from apple/eng/fix-06f8907fe715
[clang] Don't crash when loading invalid VFS for the module dep colle…
2 parents 18a8f4b + 06f8907 commit 9dd73ba

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: not %clang_cc1 -module-dependency-dir %t -ivfsoverlay %S/Inputs/invalid-yaml.yaml %s 2>&1 | FileCheck %s
4+
5+
// CHECK: error: Unexpected token
6+
// CHECK: error: Unexpected token
7+
// CHECK: 1 error generated

llvm/lib/Support/VirtualFileSystem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,6 +2127,8 @@ void vfs::collectVFSFromYAML(std::unique_ptr<MemoryBuffer> Buffer,
21272127
std::unique_ptr<RedirectingFileSystem> VFS = RedirectingFileSystem::create(
21282128
std::move(Buffer), DiagHandler, YAMLFilePath, DiagContext,
21292129
std::move(ExternalFS));
2130+
if (!VFS)
2131+
return;
21302132
ErrorOr<RedirectingFileSystem::LookupResult> RootResult =
21312133
VFS->lookupPath("/");
21322134
if (!RootResult)

0 commit comments

Comments
 (0)