Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VFS] Add property 'fallthrough' that controls fallback to real file …
…system. Default property value 'true' preserves current behavior. Value 'false' can be used to create VFS "root", file system that gives better control over which files compiler can use during compilation as there are no unpredictable accesses to real file system. Non-fallthrough use case changes how we treat multiple VFS overlay files. Instead of all of them being at the same level just above a real file system, now they are nested and subsequent overlays can refer to files in previous overlays. Change is done both in LLVM and Clang, corresponding LLVM commit is r345431. rdar://problem/39465552 Reviewers: bruno, benlangmuir Reviewed By: bruno Subscribers: dexonsmith, cfe-commits, hiraditya Differential Revision: https://reviews.llvm.org/D50539 llvm-svn: 345432
- Loading branch information
Showing
8 changed files
with
114 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Error.h | ||
|
||
#error Should not include this header in a module |
6 changes: 6 additions & 0 deletions
6
clang/test/VFS/Inputs/Broken.framework/Modules/module.modulemap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
framework module Broken [extern_c] { | ||
umbrella "Headers" | ||
export * | ||
module * { export * } | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// A.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
'version': 0, | ||
'use-external-names': false, | ||
'fallthrough': false, | ||
'roots': [ | ||
{ 'name': '/tests', 'type': 'directory', | ||
'contents': [ | ||
{ 'name': 'vfsroot-include.c', 'type': 'file', | ||
'external-contents': 'TEST_DIR/vfsroot-include.c' | ||
}, | ||
{ 'name': 'vfsroot-with-overlay.c', 'type': 'file', | ||
'external-contents': 'TEST_DIR/vfsroot-with-overlay.c' | ||
}, | ||
{ 'name': 'vfsroot-module.m', 'type': 'file', | ||
'external-contents': 'TEST_DIR/vfsroot-module.m' | ||
} | ||
] | ||
}, | ||
{ 'name': '/direct-vfs-root-files', 'type': 'directory', | ||
'contents': [ | ||
{ 'name': 'not_real.h', 'type': 'file', | ||
'external-contents': 'TEST_DIR/Inputs/actual_header.h' | ||
}, | ||
{ 'name': 'vfsoverlay.yaml', 'type': 'file', | ||
'external-contents': 'OUT_DIR/vfsoverlay.yaml' | ||
} | ||
] | ||
}, | ||
{ 'name': '/indirect-vfs-root-files', 'type': 'directory', | ||
'contents': [ | ||
{ 'name': 'actual_header.h', 'type': 'file', | ||
'external-contents': 'TEST_DIR/Inputs/actual_header.h' | ||
} | ||
] | ||
}, | ||
{ 'name': 'TEST_DIR/Inputs/Broken.framework', 'type': 'directory', | ||
'contents': [ | ||
{ 'name': 'Headers/A.h', 'type': 'file', | ||
'external-contents': 'TEST_DIR/Inputs/Broken.framework/VFSHeaders/A.h' | ||
}, | ||
{ 'name': 'Modules/module.modulemap', 'type': 'file', | ||
'external-contents': 'TEST_DIR/Inputs/Broken.framework/Modules/module.modulemap' | ||
} | ||
] | ||
}, | ||
# Locations for modules. | ||
{ 'name': 'OUT_DIR/cache', 'type': 'directory', | ||
'contents': [ | ||
{ 'name': 'Broken.pcm', 'type': 'file', | ||
'external-contents': 'OUT_DIR/cache/Broken.pcm' | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// REQUIRES: shell | ||
// RUN: rm -rf %t | ||
// RUN: mkdir -p %t | ||
// RUN: sed -e "s:TEST_DIR:%S:g" -e "s:OUT_DIR:%t:g" %S/Inputs/vfsroot.yaml > %t.yaml | ||
// RUN: not %clang_cc1 -Werror -ivfsoverlay %t.yaml -I %S/Inputs -I /direct-vfs-root-files -fsyntax-only /tests/vfsroot-include.c 2>&1 | FileCheck %s | ||
// The line above tests that the compiler input file is looked up through VFS. | ||
|
||
// Test successful include through the VFS. | ||
#include "not_real.h" | ||
|
||
// Test that a file missing from the VFS root is not found, even if it is | ||
// discoverable through the real file system. Fatal error should be the last | ||
// in the file as it hides other errors. | ||
#include "actual_header.h" | ||
// CHECK: fatal error: 'actual_header.h' file not found | ||
// CHECK: 1 error generated. | ||
// CHECK-NOT: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// REQUIRES: shell | ||
// RUN: rm -rf %t | ||
// RUN: mkdir -p %t | ||
// RUN: sed -e "s:TEST_DIR:%S:g" -e "s:OUT_DIR:%t:g" %S/Inputs/vfsroot.yaml > %t.yaml | ||
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/cache -ivfsoverlay %t.yaml -F %S/Inputs -fsyntax-only /tests/vfsroot-module.m | ||
|
||
// Test that a file missing from the VFS root is not found, even if it is | ||
// discoverable through the real file system at location that is a part of | ||
// the framework. | ||
@import Broken; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// REQUIRES: shell | ||
// RUN: rm -rf %t | ||
// RUN: mkdir -p %t | ||
// RUN: sed -e "s:TEST_DIR:%S:g" -e "s:OUT_DIR:%t:g" %S/Inputs/vfsroot.yaml > %t.yaml | ||
// RUN: sed -e "s:INPUT_DIR:/indirect-vfs-root-files:g" -e "s:OUT_DIR:/overlay-dir:g" %S/Inputs/vfsoverlay.yaml > %t/vfsoverlay.yaml | ||
// RUN: %clang_cc1 -Werror -ivfsoverlay %t.yaml -ivfsoverlay /direct-vfs-root-files/vfsoverlay.yaml -I /overlay-dir -fsyntax-only /tests/vfsroot-with-overlay.c | ||
|
||
#include "not_real.h" | ||
|
||
void foo() { | ||
bar(); | ||
} |