<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 16, 2016 at 7:20 PM, Bruno Cardoso Lopes via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: bruno<br>
Date: Wed Mar 16 21:20:43 2016<br>
New Revision: 263686<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=263686&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=263686&view=rev</a><br>
Log:<br>
Reapply [2]: [VFS] Add support for handling path traversals<br>
<br>
This was applied twice r261551 and 263617 and later reverted because:<br>
<br>
(1) Windows bot failing on unittests. Change the current behavior to do<br>
not handle path traversals on windows.<br>
<br>
(2) Windows bot failed to include llvm/Config/config.h in order to use<br>
HAVE_REALPATH. Use LLVM_ON_UNIX instead, as done in lib/Basic/FileManager.cpp.<br>
<br>
Handle ".", ".." and "./" with trailing slashes while collecting files<br>
to be dumped into the vfs overlay directory.<br>
<br>
Include the support for symlinks into components. Given the path:<br>
<br>
/install-dir/bin/../lib/clang/3.8.0/include/altivec.h, if "bin"<br>
component is a symlink, it's not safe to use `path::remove_dots` here,<br>
and `realpath` is used to get the right answer. Since `realpath`<br>
is expensive, we only do it at collecting time (which only happens<br>
during the crash reproducer) and cache the base directory for fast lookups.<br>
<br>
Overall, this makes the input to the VFS YAML file to be canonicalized<br>
to never contain traversal components.<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D17104" rel="noreferrer" target="_blank">http://reviews.llvm.org/D17104</a><br>
<br>
rdar://problem/24499339<br>
<br>
Added:<br>
cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m<br>
cfe/trunk/test/Modules/crash-vfs-path-traversal.m<br>
Modified:<br>
cfe/trunk/lib/Basic/VirtualFileSystem.cpp<br>
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp<br>
<br>
Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=263686&r1=263685&r2=263686&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=263686&r1=263685&r2=263686&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)<br>
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Wed Mar 16 21:20:43 2016<br>
@@ -112,6 +112,20 @@ bool FileSystem::exists(const Twine &Pat<br>
return Status && Status->exists();<br>
}<br>
<br>
+#ifndef NDEBUG<br>
+static bool isTraversalComponent(StringRef Component) {<br>
+ return Component.equals("..") || Component.equals(".");<br>
+}<br>
+<br>
+static bool pathHasTraversal(StringRef Path) {<br>
+ using namespace llvm::sys;<br>
+ for (StringRef Comp : llvm::make_range(path::begin(Path), path::end(Path)))<br>
+ if (isTraversalComponent(Comp))<br>
+ return true;<br>
+ return false;<br>
+}<br>
+#endif<br>
+<br>
//===-----------------------------------------------------------------------===/<br>
// RealFileSystem implementation<br>
//===-----------------------------------------------------------------------===/<br>
@@ -819,6 +833,16 @@ class RedirectingFileSystem : public vfs<br>
bool UseExternalNames;<br>
/// @}<br>
<br>
+ /// Virtual file paths and external files could be canonicalized without "..",<br>
+ /// "." and "./" in their paths. FIXME: some unittests currently fail on<br>
+ /// win32 when using remove_dots and remove_leading_dotslash on paths.<br>
+ bool UseCanonicalizedPaths =<br>
+#ifdef LLVM_ON_WIN32<br>
+ false;<br>
+#else<br>
+ true;<br>
+#endif<br>
+<br>
friend class RedirectingFileSystemParser;<br>
<br>
private:<br>
@@ -954,7 +978,7 @@ class RedirectingFileSystemParser {<br>
return true;<br>
}<br>
<br>
- std::unique_ptr<Entry> parseEntry(yaml::Node *N) {<br>
+ std::unique_ptr<Entry> parseEntry(yaml::Node *N, RedirectingFileSystem *FS) {<br>
yaml::MappingNode *M = dyn_cast<yaml::MappingNode>(N);<br>
if (!M) {<br>
error(N, "expected mapping node for file or directory entry");<br>
@@ -994,7 +1018,17 @@ class RedirectingFileSystemParser {<br>
if (Key == "name") {<br>
if (!parseScalarString(I->getValue(), Value, Buffer))<br>
return nullptr;<br>
- Name = Value;<br>
+<br>
+ if (FS->UseCanonicalizedPaths) {<br>
+ SmallString<256> Path(Value);<br>
+ // Guarantee that old YAML files containing paths with ".." and "."<br>
+ // are properly canonicalized before read into the VFS.<br>
+ Path = sys::path::remove_leading_dotslash(Path);<br>
+ sys::path::remove_dots(Path, /*remove_dot_dot=*/true);<br>
+ Name = Path.str();<br>
+ } else {<br>
+ Name = Value;<br>
+ }<br>
} else if (Key == "type") {<br>
if (!parseScalarString(I->getValue(), Value, Buffer))<br>
return nullptr;<br>
@@ -1024,7 +1058,7 @@ class RedirectingFileSystemParser {<br>
for (yaml::SequenceNode::iterator I = Contents->begin(),<br>
E = Contents->end();<br>
I != E; ++I) {<br>
- if (std::unique_ptr<Entry> E = parseEntry(&*I))<br>
+ if (std::unique_ptr<Entry> E = parseEntry(&*I, FS))<br>
EntryArrayContents.push_back(std::move(E));<br>
else<br>
return nullptr;<br>
@@ -1038,7 +1072,16 @@ class RedirectingFileSystemParser {<br>
HasContents = true;<br>
if (!parseScalarString(I->getValue(), Value, Buffer))<br>
return nullptr;<br>
- ExternalContentsPath = Value;<br>
+ if (FS->UseCanonicalizedPaths) {<br>
+ SmallString<256> Path(Value);<br>
+ // Guarantee that old YAML files containing paths with ".." and "."<br>
+ // are properly canonicalized before read into the VFS.<br>
+ Path = sys::path::remove_leading_dotslash(Path);<br>
+ sys::path::remove_dots(Path, /*remove_dot_dot=*/true);<br>
+ ExternalContentsPath = Path.str();<br>
+ } else {<br>
+ ExternalContentsPath = Value;<br>
+ }<br>
} else if (Key == "use-external-name") {<br>
bool Val;<br>
if (!parseScalarBool(I->getValue(), Val))<br>
@@ -1149,7 +1192,7 @@ public:<br>
<br>
for (yaml::SequenceNode::iterator I = Roots->begin(), E = Roots->end();<br>
I != E; ++I) {<br>
- if (std::unique_ptr<Entry> E = parseEntry(&*I))<br>
+ if (std::unique_ptr<Entry> E = parseEntry(&*I, FS))<br>
FS->Roots.push_back(std::move(E));<br>
else<br>
return false;<br>
@@ -1228,6 +1271,14 @@ ErrorOr<Entry *> RedirectingFileSystem::<br>
if (std::error_code EC = makeAbsolute(Path))<br>
return EC;<br>
<br>
+ // Canonicalize path by removing ".", "..", "./", etc components. This is<br>
+ // a VFS request, do bot bother about symlinks in the path components<br>
+ // but canonicalize in order to perform the correct entry search.<br>
+ if (UseCanonicalizedPaths) {<br>
+ Path = sys::path::remove_leading_dotslash(Path);<br>
+ sys::path::remove_dots(Path, /*remove_dot_dot=*/true);<br>
+ }<br>
+<br>
if (Path.empty())<br>
return make_error_code(llvm::errc::invalid_argument);<br>
<br>
@@ -1244,10 +1295,17 @@ ErrorOr<Entry *> RedirectingFileSystem::<br>
ErrorOr<Entry *><br>
RedirectingFileSystem::lookupPath(sys::path::const_iterator Start,<br>
sys::path::const_iterator End, Entry *From) {<br>
+#ifndef LLVM_ON_WIN32<br>
+ assert(!isTraversalComponent(*Start) &&<br>
+ !isTraversalComponent(From->getName()) &&<br>
+ "Paths should not contain traversal components");<br>
+#else<br>
+ // FIXME: this is here to support windows, remove it once canonicalized<br>
+ // paths become globally default.<br>
if (Start->equals("."))<br>
++Start;<br>
+#endif<br>
<br>
- // FIXME: handle ..<br>
if (CaseSensitive ? !Start->equals(From->getName())<br>
: !Start->equals_lower(From->getName()))<br>
// failure to match<br>
@@ -1366,16 +1424,6 @@ UniqueID vfs::getNextVirtualUniqueID() {<br>
return UniqueID(std::numeric_limits<uint64_t>::max(), ID);<br>
}<br>
<br>
-#ifndef NDEBUG<br>
-static bool pathHasTraversal(StringRef Path) {<br>
- using namespace llvm::sys;<br>
- for (StringRef Comp : llvm::make_range(path::begin(Path), path::end(Path)))<br>
- if (Comp == "." || Comp == "..")<br>
- return true;<br>
- return false;<br>
-}<br>
-#endif<br>
-<br>
void YAMLVFSWriter::addFileMapping(StringRef VirtualPath, StringRef RealPath) {<br>
assert(sys::path::is_absolute(VirtualPath) && "virtual path not absolute");<br>
assert(sys::path::is_absolute(RealPath) && "real path not absolute");<br>
<br>
Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=263686&r1=263685&r2=263686&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=263686&r1=263685&r2=263686&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Wed Mar 16 21:20:43 2016<br>
@@ -13,8 +13,9 @@<br>
<br>
#include "clang/Frontend/Utils.h"<br>
#include "clang/Serialization/ASTReader.h"<br>
-#include "llvm/ADT/StringSet.h"<br>
+#include "llvm/ADT/StringMap.h"<br>
#include "llvm/ADT/iterator_range.h"<br>
+#include "llvm/Config/config.h"<br>
#include "llvm/Support/FileSystem.h"<br>
#include "llvm/Support/Path.h"<br>
#include "llvm/Support/raw_ostream.h"<br>
@@ -25,7 +26,9 @@ namespace {<br>
/// Private implementation for ModuleDependencyCollector<br>
class ModuleDependencyListener : public ASTReaderListener {<br>
ModuleDependencyCollector &Collector;<br>
+ llvm::StringMap<std::string> SymLinkMap;<br>
<br>
+ bool getRealPath(StringRef SrcPath, SmallVectorImpl<char> &Result);<br>
std::error_code copyToRoot(StringRef Src);<br>
public:<br>
ModuleDependencyListener(ModuleDependencyCollector &Collector)<br>
@@ -57,6 +60,48 @@ void ModuleDependencyCollector::writeFil<br>
VFSWriter.write(OS);<br>
}<br>
<br>
+// TODO: move this to Support/Path.h and check for HAVE_REALPATH?<br>
+static bool real_path(StringRef SrcPath, SmallVectorImpl<char> &RealPath) {<br>
+#ifdef LLVM_ON_UNIX<br>
+ char CanonicalPath[PATH_MAX];<br>
+<br>
+ // TODO: emit a warning in case this fails...?<br>
+ if (!realpath(SrcPath.str().c_str(), CanonicalPath))<br>
+ return false;<br>
+<br>
+ SmallString<256> RPath(CanonicalPath);<br>
+ RealPath.swap(RPath);<br>
+ return true;<br>
+#else<br>
+ // FIXME: Add support for systems without realpath.<br>
+ return false;<br>
+#endif<br>
+}<br></blockquote><div><br></div><div>We already have a similar call to realpath in lib/Basic/FileManager.cpp (ugly #ifdef and all)</div><div><br></div><div>Could you avoid duplicating it?</div><div><br></div><div>-- Sean Silva</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+<br>
+bool ModuleDependencyListener::getRealPath(StringRef SrcPath,<br>
+ SmallVectorImpl<char> &Result) {<br>
+ using namespace llvm::sys;<br>
+ SmallString<256> RealPath;<br>
+ StringRef FileName = path::filename(SrcPath);<br>
+ std::string Dir = path::parent_path(SrcPath).str();<br>
+ auto DirWithSymLink = SymLinkMap.find(Dir);<br>
+<br>
+ // Use real_path to fix any symbolic link component present in a path.<br>
+ // Computing the real path is expensive, cache the search through the<br>
+ // parent path directory.<br>
+ if (DirWithSymLink == SymLinkMap.end()) {<br>
+ if (!real_path(Dir, RealPath))<br>
+ return false;<br>
+ SymLinkMap[Dir] = RealPath.str();<br>
+ } else {<br>
+ RealPath = DirWithSymLink->second;<br>
+ }<br>
+<br>
+ path::append(RealPath, FileName);<br>
+ Result.swap(RealPath);<br>
+ return true;<br>
+}<br>
+<br>
std::error_code ModuleDependencyListener::copyToRoot(StringRef Src) {<br>
using namespace llvm::sys;<br>
<br>
@@ -65,22 +110,42 @@ std::error_code ModuleDependencyListener<br>
fs::make_absolute(AbsoluteSrc);<br>
// Canonicalize to a native path to avoid mixed separator styles.<br>
path::native(AbsoluteSrc);<br>
- // TODO: We probably need to handle .. as well as . in order to have valid<br>
- // input to the YAMLVFSWriter.<br>
- path::remove_dots(AbsoluteSrc);<br>
+ // Remove redundant leading "./" pieces and consecutive separators.<br>
+ AbsoluteSrc = path::remove_leading_dotslash(AbsoluteSrc);<br>
+<br>
+ // Canonicalize path by removing "..", "." components.<br>
+ SmallString<256> CanonicalPath = AbsoluteSrc;<br>
+ path::remove_dots(CanonicalPath, /*remove_dot_dot=*/true);<br>
+<br>
+ // If a ".." component is present after a symlink component, remove_dots may<br>
+ // lead to the wrong real destination path. Let the source be canonicalized<br>
+ // like that but make sure the destination uses the real path.<br>
+ bool HasDotDotInPath =<br>
+ std::count(path::begin(AbsoluteSrc), path::end(AbsoluteSrc), "..") > 0;<br>
+ SmallString<256> RealPath;<br>
+ bool HasRemovedSymlinkComponent = HasDotDotInPath &&<br>
+ getRealPath(AbsoluteSrc, RealPath) &&<br>
+ !StringRef(CanonicalPath).equals(RealPath);<br>
<br>
// Build the destination path.<br>
SmallString<256> Dest = Collector.getDest();<br>
- path::append(Dest, path::relative_path(AbsoluteSrc));<br>
+ path::append(Dest, path::relative_path(HasRemovedSymlinkComponent ? RealPath<br>
+ : CanonicalPath));<br>
<br>
// Copy the file into place.<br>
if (std::error_code EC = fs::create_directories(path::parent_path(Dest),<br>
/*IgnoreExisting=*/true))<br>
return EC;<br>
- if (std::error_code EC = fs::copy_file(AbsoluteSrc, Dest))<br>
+ if (std::error_code EC = fs::copy_file(<br>
+ HasRemovedSymlinkComponent ? RealPath : CanonicalPath, Dest))<br>
return EC;<br>
- // Use the absolute path under the root for the file mapping.<br>
- Collector.addFileMapping(AbsoluteSrc, Dest);<br>
+<br>
+ // Use the canonical path under the root for the file mapping. Also create<br>
+ // an additional entry for the real path.<br>
+ Collector.addFileMapping(CanonicalPath, Dest);<br>
+ if (HasRemovedSymlinkComponent)<br>
+ Collector.addFileMapping(RealPath, Dest);<br>
+<br>
return std::error_code();<br>
}<br>
<br>
<br>
Added: cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m?rev=263686&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m?rev=263686&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m (added)<br>
+++ cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m Wed Mar 16 21:20:43 2016<br>
@@ -0,0 +1,72 @@<br>
+// REQUIRES: crash-recovery, shell<br>
+<br>
+// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it?<br>
+// XFAIL: mingw32<br>
+<br>
+// Test that clang is capable of collecting the right header files in the<br>
+// crash reproducer if there's a symbolic link component in the path.<br>
+<br>
+// RUN: rm -rf %t<br>
+// RUN: mkdir -p %t/i %t/m %t %t/sysroot<br>
+// RUN: cp -a %S/Inputs/System/usr %t/i/<br>
+// RUN: ln -s include/tcl-private %t/i/usr/x<br>
+<br>
+// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \<br>
+// RUN: %clang -fsyntax-only %s -I %/t/i -isysroot %/t/sysroot/ \<br>
+// RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s<br>
+<br>
+// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m<br>
+// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh<br>
+// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \<br>
+// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml<br>
+// RUN: find %t/crash-vfs-*.cache/vfs | \<br>
+// RUN: grep "usr/include/stdio.h" | count 1<br>
+<br>
+#include "usr/x/../stdio.h"<br>
+<br>
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:<br>
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.m<br>
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache<br>
+<br>
+// CHECKSRC: @import cstd.stdio;<br>
+<br>
+// CHECKSH: # Crash reproducer<br>
+// CHECKSH-NEXT: # Driver args: "-fsyntax-only"<br>
+// CHECKSH-NEXT: # Original command: {{.*$}}<br>
+// CHECKSH-NEXT: "-cc1"<br>
+// CHECKSH: "-isysroot" "{{[^"]*}}/sysroot/"<br>
+// CHECKSH-NOT: "-fmodules-cache-path="<br>
+// CHECKSH: "crash-vfs-{{[^ ]*}}.m"<br>
+// CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"<br>
+<br>
+// CHECKYAML: 'type': 'directory'<br>
+// CHECKYAML: 'name': "{{[^ ]*}}/i/usr/include",<br>
+// CHECKYAML-NEXT: 'contents': [<br>
+// CHECKYAML-NEXT: {<br>
+// CHECKYAML-NEXT: 'type': 'file',<br>
+// CHECKYAML-NEXT: 'name': "module.map",<br>
+// CHECKYAML-NEXT: 'external-contents': "{{[^ ]*}}.cache/vfs/{{[^ ]*}}/i/usr/include/module.map"<br>
+// CHECKYAML-NEXT: },<br>
+<br>
+// CHECKYAML: 'type': 'directory'<br>
+// CHECKYAML: 'name': "{{[^ ]*}}/i/usr",<br>
+// CHECKYAML-NEXT: 'contents': [<br>
+// CHECKYAML-NEXT: {<br>
+// CHECKYAML-NEXT: 'type': 'file',<br>
+// CHECKYAML-NEXT: 'name': "module.map",<br>
+// CHECKYAML-NEXT: 'external-contents': "{{[^ ]*}}.cache/vfs/{{[^ ]*}}/i/usr/include/module.map"<br>
+// CHECKYAML-NEXT: },<br>
+<br>
+// Test that by using the previous generated YAML file clang is able to find the<br>
+// right files inside the overlay and map the virtual request for a path that<br>
+// previously contained a symlink to work. To make sure of this, wipe out the<br>
+// %/t/i directory containing the symlink component.<br>
+<br>
+// RUN: rm -rf %/t/i<br>
+// RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH<br>
+// RUN: %clang -E %s -I %/t/i -isysroot %/t/sysroot/ \<br>
+// RUN: -ivfsoverlay %t/crash-vfs-*.cache/vfs/vfs.yaml -fmodules \<br>
+// RUN: -fmodules-cache-path=%t/m/ 2>&1 \<br>
+// RUN: | FileCheck %s --check-prefix=CHECKOVERLAY<br>
+<br>
+// CHECKOVERLAY: @import cstd.stdio; /* clang -E: implicit import for "{{[^ ]*}}.cache/vfs/{{[^ ]*}}/i/usr/include/stdio.h"<br>
<br>
Added: cfe/trunk/test/Modules/crash-vfs-path-traversal.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-traversal.m?rev=263686&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-traversal.m?rev=263686&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/crash-vfs-path-traversal.m (added)<br>
+++ cfe/trunk/test/Modules/crash-vfs-path-traversal.m Wed Mar 16 21:20:43 2016<br>
@@ -0,0 +1,60 @@<br>
+// REQUIRES: crash-recovery, shell, non-ms-sdk, non-ps4-sdk<br>
+<br>
+// FIXME: Canonicalizing paths to remove relative traversal components<br>
+// currenty fails a unittest on windows and is disable by default.<br>
+// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it?<br>
+// XFAIL: mingw32<br>
+<br>
+// RUN: rm -rf %t<br>
+// RUN: mkdir -p %t/i %t/m %t<br>
+<br>
+// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \<br>
+// RUN: %clang -fsyntax-only %s -I %S/Inputs/System -isysroot %/t/i/ \<br>
+// RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s<br>
+<br>
+// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m<br>
+// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh<br>
+// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \<br>
+// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml<br>
+// RUN: find %t/crash-vfs-*.cache/vfs | \<br>
+// RUN: grep "Inputs/System/usr/include/stdio.h" | count 1<br>
+<br>
+#include "usr/././//////include/../include/./././../include/stdio.h"<br>
+<br>
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:<br>
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.m<br>
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache<br>
+<br>
+// CHECKSRC: @import cstd.stdio;<br>
+<br>
+// CHECKSH: # Crash reproducer<br>
+// CHECKSH-NEXT: # Driver args: "-fsyntax-only"<br>
+// CHECKSH-NEXT: # Original command: {{.*$}}<br>
+// CHECKSH-NEXT: "-cc1"<br>
+// CHECKSH: "-isysroot" "{{[^"]*}}/i/"<br>
+// CHECKSH-NOT: "-fmodules-cache-path="<br>
+// CHECKSH: "crash-vfs-{{[^ ]*}}.m"<br>
+// CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"<br>
+<br>
+// CHECKYAML: 'type': 'directory'<br>
+// CHECKYAML: 'name': "{{[^ ]*}}/Inputs/System/usr/include",<br>
+// CHECKYAML-NEXT: 'contents': [<br>
+// CHECKYAML-NEXT: {<br>
+// CHECKYAML-NEXT: 'type': 'file',<br>
+// CHECKYAML-NEXT: 'name': "module.map",<br>
+// CHECKYAML-NEXT: 'external-contents': "{{[^ ]*}}/Inputs/System/usr/include/module.map"<br>
+// CHECKYAML-NEXT: },<br>
+<br>
+// Replace the paths in the YAML files with relative ".." traversals<br>
+// and fed into clang to test whether we're correctly representing them<br>
+// in the VFS overlay.<br>
+<br>
+// RUN: sed -e "s@usr/include@usr/include/../include@g" \<br>
+// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml > %t/vfs.yaml<br>
+// RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH<br>
+// RUN: %clang -E %s -I %S/Inputs/System -isysroot %/t/i/ \<br>
+// RUN: -ivfsoverlay %t/vfs.yaml -fmodules \<br>
+// RUN: -fmodules-cache-path=%t/m/ 2>&1 \<br>
+// RUN: | FileCheck %s --check-prefix=CHECKOVERLAY<br>
+<br>
+// CHECKOVERLAY: @import cstd.stdio; /* clang -E: implicit import for "{{[^ ]*}}.cache/vfs/{{[^ ]*}}/usr/include/stdio.h"<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>