r261552 - [VFS] Add 'overlay-relative' field to YAML files
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 23 09:12:05 PST 2016
Looks like r261551's fault. Reverted in r261654.
On Mon, Feb 22, 2016 at 11:12 PM, Bruno Cardoso Lopes
<bruno.cardoso at gmail.com> wrote:
> Reverted r261552 & r261556 in r261613. Waiting for next win bot
> results to see if it's necessary to revert r261551 as well.
>
> On Mon, Feb 22, 2016 at 7:16 PM, Bruno Cardoso Lopes
> <bruno.cardoso at gmail.com> wrote:
>> Yes, but because of a related but different issue. The same as here:
>> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10026
>>
>> I've been trying to figure it out but it's been hard without a Unix
>> system available. I'll keep investigating and revert later tonight in
>> case I can't guess it.
>>
>> On Mon, Feb 22, 2016 at 7:08 PM, Sean Silva <chisophugis at gmail.com> wrote:
>>> The bot is still red:
>>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast
>>>
>>> On Mon, Feb 22, 2016 at 6:48 PM, Bruno Cardoso Lopes
>>> <bruno.cardoso at gmail.com> wrote:
>>>>
>>>> Hi Sean,
>>>>
>>>> This is hopefully fixed in r261556.
>>>>
>>>> On Mon, Feb 22, 2016 at 5:45 PM, Sean Silva <chisophugis at gmail.com> wrote:
>>>> > This or r261551 seem to be causing a build failure:
>>>> >
>>>> > http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/527
>>>> >
>>>> > -- Sean SIlva
>>>> >
>>>> > On Mon, Feb 22, 2016 at 10:41 AM, Bruno Cardoso Lopes via cfe-commits
>>>> > <cfe-commits at lists.llvm.org> wrote:
>>>> >>
>>>> >> Author: bruno
>>>> >> Date: Mon Feb 22 12:41:09 2016
>>>> >> New Revision: 261552
>>>> >>
>>>> >> URL: http://llvm.org/viewvc/llvm-project?rev=261552&view=rev
>>>> >> Log:
>>>> >> [VFS] Add 'overlay-relative' field to YAML files
>>>> >>
>>>> >> The VFS overlay mapping between virtual paths and real paths is done
>>>> >> through
>>>> >> the 'external-contents' entries in YAML files, which contains hardcoded
>>>> >> paths
>>>> >> to the real files.
>>>> >>
>>>> >> When a module compilation crashes, headers are dumped into
>>>> >> <name>.cache/vfs
>>>> >> directory and are mapped via the <name>.cache/vfs/vfs.yaml. The script
>>>> >> generated for reproduction uses -ivfsoverlay pointing to file to gather
>>>> >> the
>>>> >> mapping between virtual paths and files inside <name>.cache/vfs.
>>>> >> Currently, we
>>>> >> are only capable of reproducing such crashes in the same machine as
>>>> >> they
>>>> >> happen, because of the hardcoded paths in 'external-contents'.
>>>> >>
>>>> >> To be able to reproduce a crash in another machine, this patch
>>>> >> introduces
>>>> >> a new
>>>> >> option in the VFS yaml file called 'overlay-relative'. When it's equal
>>>> >> to
>>>> >> 'true' it means that the provided path to the YAML file through the
>>>> >> -ivfsoverlay option should also be used to prefix the final path for
>>>> >> every
>>>> >> 'external-contents'.
>>>> >>
>>>> >> Example, given the invocation snippet "... -ivfsoverlay
>>>> >> <name>.cache/vfs/vfs.yaml" and the following entry in the yaml file:
>>>> >>
>>>> >> "overlay-relative": "true",
>>>> >> "roots": [
>>>> >> ...
>>>> >> "type": "directory",
>>>> >> "name": "/usr/include",
>>>> >> "contents": [
>>>> >> {
>>>> >> "type": "file",
>>>> >> "name": "stdio.h",
>>>> >> "external-contents": "/usr/include/stdio.h"
>>>> >> },
>>>> >> ...
>>>> >>
>>>> >> Here, a file manager request for virtual "/usr/include/stdio.h", that
>>>> >> will
>>>> >> map
>>>> >> into real path
>>>> >> "/<absolute_path_to>/<name>.cache/vfs/usr/include/stdio.h.
>>>> >>
>>>> >> This is a useful feature for debugging module crashes in machines other
>>>> >> than
>>>> >> the one where the error happened.
>>>> >>
>>>> >> Differential Revision: http://reviews.llvm.org/D17457
>>>> >>
>>>> >> rdar://problem/24499339
>>>> >>
>>>> >> Added:
>>>> >> cfe/trunk/test/Modules/crash-vfs-relative-overlay.m
>>>> >> - copied, changed from r261551,
>>>> >> cfe/trunk/test/Modules/crash-vfs-path-traversal.m
>>>> >> Modified:
>>>> >> cfe/trunk/include/clang/Basic/VirtualFileSystem.h
>>>> >> cfe/trunk/lib/Basic/VirtualFileSystem.cpp
>>>> >> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>>>> >> cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
>>>> >> cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
>>>> >> cfe/trunk/test/Modules/crash-vfs-path-traversal.m
>>>> >>
>>>> >> Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
>>>> >> URL:
>>>> >>
>>>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=261552&r1=261551&r2=261552&view=diff
>>>> >>
>>>> >>
>>>> >> ==============================================================================
>>>> >> --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
>>>> >> +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Mon Feb 22
>>>> >> 12:41:09
>>>> >> 2016
>>>> >> @@ -310,6 +310,7 @@ llvm::sys::fs::UniqueID getNextVirtualUn
>>>> >> IntrusiveRefCntPtr<FileSystem>
>>>> >> getVFSFromYAML(std::unique_ptr<llvm::MemoryBuffer> Buffer,
>>>> >> llvm::SourceMgr::DiagHandlerTy DiagHandler,
>>>> >> + StringRef YAMLFilePath,
>>>> >> void *DiagContext = nullptr,
>>>> >> IntrusiveRefCntPtr<FileSystem> ExternalFS =
>>>> >> getRealFileSystem());
>>>> >>
>>>> >> @@ -323,6 +324,8 @@ struct YAMLVFSEntry {
>>>> >> class YAMLVFSWriter {
>>>> >> std::vector<YAMLVFSEntry> Mappings;
>>>> >> Optional<bool> IsCaseSensitive;
>>>> >> + Optional<bool> IsOverlayRelative;
>>>> >> + std::string OverlayDir;
>>>> >>
>>>> >> public:
>>>> >> YAMLVFSWriter() {}
>>>> >> @@ -330,6 +333,11 @@ public:
>>>> >> void setCaseSensitivity(bool CaseSensitive) {
>>>> >> IsCaseSensitive = CaseSensitive;
>>>> >> }
>>>> >> + void setOverlayDir(StringRef OverlayDirectory) {
>>>> >> + IsOverlayRelative = true;
>>>> >> + OverlayDir.assign(OverlayDirectory.str());
>>>> >> + }
>>>> >> +
>>>> >> void write(llvm::raw_ostream &OS);
>>>> >> };
>>>> >>
>>>> >>
>>>> >> Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
>>>> >> URL:
>>>> >>
>>>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=261552&r1=261551&r2=261552&view=diff
>>>> >>
>>>> >>
>>>> >> ==============================================================================
>>>> >> --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
>>>> >> +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Feb 22 12:41:09 2016
>>>> >> @@ -790,6 +790,7 @@ public:
>>>> >> /// All configuration options are optional.
>>>> >> /// 'case-sensitive': <boolean, default=true>
>>>> >> /// 'use-external-names': <boolean, default=true>
>>>> >> +/// 'overlay-relative': <boolean, default=false>
>>>> >> ///
>>>> >> /// Virtual directories are represented as
>>>> >> /// \verbatim
>>>> >> @@ -832,6 +833,10 @@ class RedirectingFileSystem : public vfs
>>>> >> std::vector<std::unique_ptr<Entry>> Roots;
>>>> >> /// \brief The file system to use for external references.
>>>> >> IntrusiveRefCntPtr<FileSystem> ExternalFS;
>>>> >> + /// If IsRelativeOverlay is set, this represents the directory
>>>> >> + /// path that should be prefixed to each 'external-contents' entry
>>>> >> + /// when reading from YAML files.
>>>> >> + std::string ExternalContentsPrefixDir;
>>>> >>
>>>> >> /// @name Configuration
>>>> >> /// @{
>>>> >> @@ -841,6 +846,10 @@ class RedirectingFileSystem : public vfs
>>>> >> /// Currently, case-insensitive matching only works correctly with
>>>> >> ASCII.
>>>> >> bool CaseSensitive;
>>>> >>
>>>> >> + /// IsRelativeOverlay marks whether a IsExternalContentsPrefixDir
>>>> >> path
>>>> >> must
>>>> >> + /// be prefixed in every 'external-contents' when reading from YAML
>>>> >> files.
>>>> >> + bool IsRelativeOverlay = false;
>>>> >> +
>>>> >> /// \brief Whether to use to use the value of 'external-contents'
>>>> >> for
>>>> >> the
>>>> >> /// names of files. This global value is overridable on a per-file
>>>> >> basis.
>>>> >> bool UseExternalNames;
>>>> >> @@ -868,8 +877,8 @@ public:
>>>> >> /// returns a virtual file system representing its contents.
>>>> >> static RedirectingFileSystem *
>>>> >> create(std::unique_ptr<MemoryBuffer> Buffer,
>>>> >> - SourceMgr::DiagHandlerTy DiagHandler, void *DiagContext,
>>>> >> - IntrusiveRefCntPtr<FileSystem> ExternalFS);
>>>> >> + SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath,
>>>> >> + void *DiagContext, IntrusiveRefCntPtr<FileSystem>
>>>> >> ExternalFS);
>>>> >>
>>>> >> ErrorOr<Status> status(const Twine &Path) override;
>>>> >> ErrorOr<std::unique_ptr<File>> openFileForRead(const Twine &Path)
>>>> >> override;
>>>> >> @@ -902,6 +911,15 @@ public:
>>>> >> return
>>>> >> directory_iterator(std::make_shared<VFSFromYamlDirIterImpl>(Dir,
>>>> >> *this, D->contents_begin(), D->contents_end(), EC));
>>>> >> }
>>>> >> +
>>>> >> + void setExternalContentsPrefixDir(StringRef PrefixDir) {
>>>> >> + ExternalContentsPrefixDir = PrefixDir.str();
>>>> >> + }
>>>> >> +
>>>> >> + StringRef getExternalContentsPrefixDir() const {
>>>> >> + return ExternalContentsPrefixDir;
>>>> >> + }
>>>> >> +
>>>> >> };
>>>> >>
>>>> >> /// \brief A helper class to hold the common YAML parsing state.
>>>> >> @@ -981,7 +999,7 @@ class RedirectingFileSystemParser {
>>>> >> return true;
>>>> >> }
>>>> >>
>>>> >> - std::unique_ptr<Entry> parseEntry(yaml::Node *N) {
>>>> >> + std::unique_ptr<Entry> parseEntry(yaml::Node *N,
>>>> >> RedirectingFileSystem
>>>> >> *FS) {
>>>> >> yaml::MappingNode *M = dyn_cast<yaml::MappingNode>(N);
>>>> >> if (!M) {
>>>> >> error(N, "expected mapping node for file or directory entry");
>>>> >> @@ -1057,7 +1075,7 @@ class RedirectingFileSystemParser {
>>>> >> for (yaml::SequenceNode::iterator I = Contents->begin(),
>>>> >> E = Contents->end();
>>>> >> I != E; ++I) {
>>>> >> - if (std::unique_ptr<Entry> E = parseEntry(&*I))
>>>> >> + if (std::unique_ptr<Entry> E = parseEntry(&*I, FS))
>>>> >> EntryArrayContents.push_back(std::move(E));
>>>> >> else
>>>> >> return nullptr;
>>>> >> @@ -1071,12 +1089,22 @@ class RedirectingFileSystemParser {
>>>> >> HasContents = true;
>>>> >> if (!parseScalarString(I->getValue(), Value, Buffer))
>>>> >> return nullptr;
>>>> >> - SmallString<256> Path(Value);
>>>> >> +
>>>> >> + SmallString<128> FullPath;
>>>> >> + if (FS->IsRelativeOverlay) {
>>>> >> + FullPath = FS->getExternalContentsPrefixDir();
>>>> >> + assert(!FullPath.empty() &&
>>>> >> + "External contents prefix directory must exist");
>>>> >> + llvm::sys::path::append(FullPath, Value);
>>>> >> + } else {
>>>> >> + FullPath = Value;
>>>> >> + }
>>>> >> +
>>>> >> // Guarantee that old YAML files containing paths with ".."
>>>> >> and
>>>> >> "." are
>>>> >> // properly canonicalized before read into the VFS.
>>>> >> - Path = sys::path::remove_leading_dotslash(Path);
>>>> >> - sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
>>>> >> - ExternalContentsPath = Path.str();
>>>> >> + FullPath = sys::path::remove_leading_dotslash(FullPath);
>>>> >> + sys::path::remove_dots(FullPath, /*remove_dot_dot=*/true);
>>>> >> + ExternalContentsPath = FullPath.str();
>>>> >> } else if (Key == "use-external-name") {
>>>> >> bool Val;
>>>> >> if (!parseScalarBool(I->getValue(), Val))
>>>> >> @@ -1162,6 +1190,7 @@ public:
>>>> >> KeyStatusPair("version", true),
>>>> >> KeyStatusPair("case-sensitive", false),
>>>> >> KeyStatusPair("use-external-names", false),
>>>> >> + KeyStatusPair("overlay-relative", false),
>>>> >> KeyStatusPair("roots", true),
>>>> >> };
>>>> >>
>>>> >> @@ -1187,7 +1216,7 @@ public:
>>>> >>
>>>> >> for (yaml::SequenceNode::iterator I = Roots->begin(), E =
>>>> >> Roots->end();
>>>> >> I != E; ++I) {
>>>> >> - if (std::unique_ptr<Entry> E = parseEntry(&*I))
>>>> >> + if (std::unique_ptr<Entry> E = parseEntry(&*I, FS))
>>>> >> FS->Roots.push_back(std::move(E));
>>>> >> else
>>>> >> return false;
>>>> >> @@ -1213,6 +1242,9 @@ public:
>>>> >> } else if (Key == "case-sensitive") {
>>>> >> if (!parseScalarBool(I->getValue(), FS->CaseSensitive))
>>>> >> return false;
>>>> >> + } else if (Key == "overlay-relative") {
>>>> >> + if (!parseScalarBool(I->getValue(), FS->IsRelativeOverlay))
>>>> >> + return false;
>>>> >> } else if (Key == "use-external-names") {
>>>> >> if (!parseScalarBool(I->getValue(), FS->UseExternalNames))
>>>> >> return false;
>>>> >> @@ -1233,9 +1265,11 @@ public:
>>>> >>
>>>> >> Entry::~Entry() = default;
>>>> >>
>>>> >> -RedirectingFileSystem *RedirectingFileSystem::create(
>>>> >> - std::unique_ptr<MemoryBuffer> Buffer, SourceMgr::DiagHandlerTy
>>>> >> DiagHandler,
>>>> >> - void *DiagContext, IntrusiveRefCntPtr<FileSystem> ExternalFS) {
>>>> >> +RedirectingFileSystem *
>>>> >> +RedirectingFileSystem::create(std::unique_ptr<MemoryBuffer> Buffer,
>>>> >> + SourceMgr::DiagHandlerTy DiagHandler,
>>>> >> + StringRef YAMLFilePath, void
>>>> >> *DiagContext,
>>>> >> + IntrusiveRefCntPtr<FileSystem>
>>>> >> ExternalFS)
>>>> >> {
>>>> >>
>>>> >> SourceMgr SM;
>>>> >> yaml::Stream Stream(Buffer->getMemBufferRef(), SM);
>>>> >> @@ -1252,6 +1286,23 @@ RedirectingFileSystem *RedirectingFileSy
>>>> >>
>>>> >> std::unique_ptr<RedirectingFileSystem> FS(
>>>> >> new RedirectingFileSystem(ExternalFS));
>>>> >> +
>>>> >> + if (!YAMLFilePath.empty()) {
>>>> >> + // Use the YAML path from -ivfsoverlay to compute the dir to be
>>>> >> prefixed
>>>> >> + // to each 'external-contents' path.
>>>> >> + //
>>>> >> + // Example:
>>>> >> + // -ivfsoverlay dummy.cache/vfs/vfs.yaml
>>>> >> + // yields:
>>>> >> + // FS->ExternalContentsPrefixDir =>
>>>> >> /<absolute_path_to>/dummy.cache/vfs
>>>> >> + //
>>>> >> + SmallString<256> OverlayAbsDir =
>>>> >> sys::path::parent_path(YAMLFilePath);
>>>> >> + std::error_code EC = llvm::sys::fs::make_absolute(OverlayAbsDir);
>>>> >> + assert(!EC && "Overlay dir final path must be absolute");
>>>> >> + (void)EC;
>>>> >> + FS->setExternalContentsPrefixDir(OverlayAbsDir);
>>>> >> + }
>>>> >> +
>>>> >> if (!P.parse(Root, FS.get()))
>>>> >> return nullptr;
>>>> >>
>>>> >> @@ -1396,10 +1447,12 @@ RedirectingFileSystem::openFileForRead(c
>>>> >>
>>>> >> IntrusiveRefCntPtr<FileSystem>
>>>> >> vfs::getVFSFromYAML(std::unique_ptr<MemoryBuffer> Buffer,
>>>> >> - SourceMgr::DiagHandlerTy DiagHandler, void
>>>> >> *DiagContext,
>>>> >> + SourceMgr::DiagHandlerTy DiagHandler,
>>>> >> + StringRef YAMLFilePath,
>>>> >> + void *DiagContext,
>>>> >> IntrusiveRefCntPtr<FileSystem> ExternalFS) {
>>>> >> return RedirectingFileSystem::create(std::move(Buffer), DiagHandler,
>>>> >> - DiagContext, ExternalFS);
>>>> >> + YAMLFilePath, DiagContext,
>>>> >> ExternalFS);
>>>> >> }
>>>> >>
>>>> >> UniqueID vfs::getNextVirtualUniqueID() {
>>>> >> @@ -1431,7 +1484,8 @@ class JSONWriter {
>>>> >>
>>>> >> public:
>>>> >> JSONWriter(llvm::raw_ostream &OS) : OS(OS) {}
>>>> >> - void write(ArrayRef<YAMLVFSEntry> Entries, Optional<bool>
>>>> >> IsCaseSensitive);
>>>> >> + void write(ArrayRef<YAMLVFSEntry> Entries, Optional<bool>
>>>> >> IsCaseSensitive,
>>>> >> + Optional<bool> IsOverlayRelative, StringRef OverlayDir);
>>>> >> };
>>>> >> }
>>>> >>
>>>> >> @@ -1484,7 +1538,9 @@ void JSONWriter::writeEntry(StringRef VP
>>>> >> }
>>>> >>
>>>> >> void JSONWriter::write(ArrayRef<YAMLVFSEntry> Entries,
>>>> >> - Optional<bool> IsCaseSensitive) {
>>>> >> + Optional<bool> IsCaseSensitive,
>>>> >> + Optional<bool> IsOverlayRelative,
>>>> >> + StringRef OverlayDir) {
>>>> >> using namespace llvm::sys;
>>>> >>
>>>> >> OS << "{\n"
>>>> >> @@ -1492,12 +1548,27 @@ void JSONWriter::write(ArrayRef<YAMLVFSE
>>>> >> if (IsCaseSensitive.hasValue())
>>>> >> OS << " 'case-sensitive': '"
>>>> >> << (IsCaseSensitive.getValue() ? "true" : "false") << "',\n";
>>>> >> + bool UseOverlayRelative = false;
>>>> >> + if (IsOverlayRelative.hasValue()) {
>>>> >> + UseOverlayRelative = IsOverlayRelative.getValue();
>>>> >> + OS << " 'overlay-relative': '"
>>>> >> + << (UseOverlayRelative ? "true" : "false") << "',\n";
>>>> >> + }
>>>> >> OS << " 'roots': [\n";
>>>> >>
>>>> >> if (!Entries.empty()) {
>>>> >> const YAMLVFSEntry &Entry = Entries.front();
>>>> >> startDirectory(path::parent_path(Entry.VPath));
>>>> >> - writeEntry(path::filename(Entry.VPath), Entry.RPath);
>>>> >> +
>>>> >> + StringRef RPath = Entry.RPath;
>>>> >> + if (UseOverlayRelative) {
>>>> >> + unsigned OverlayDirLen = OverlayDir.size();
>>>> >> + assert(RPath.substr(0, OverlayDirLen) == OverlayDir &&
>>>> >> + "Overlay dir must be contained in RPath");
>>>> >> + RPath = RPath.slice(OverlayDirLen, RPath.size());
>>>> >> + }
>>>> >> +
>>>> >> + writeEntry(path::filename(Entry.VPath), RPath);
>>>> >>
>>>> >> for (const auto &Entry : Entries.slice(1)) {
>>>> >> StringRef Dir = path::parent_path(Entry.VPath);
>>>> >> @@ -1511,7 +1582,14 @@ void JSONWriter::write(ArrayRef<YAMLVFSE
>>>> >> OS << ",\n";
>>>> >> startDirectory(Dir);
>>>> >> }
>>>> >> - writeEntry(path::filename(Entry.VPath), Entry.RPath);
>>>> >> + StringRef RPath = Entry.RPath;
>>>> >> + if (UseOverlayRelative) {
>>>> >> + unsigned OverlayDirLen = OverlayDir.size();
>>>> >> + assert(RPath.substr(0, OverlayDirLen) == OverlayDir &&
>>>> >> + "Overlay dir must be contained in RPath");
>>>> >> + RPath = RPath.slice(OverlayDirLen, RPath.size());
>>>> >> + }
>>>> >> + writeEntry(path::filename(Entry.VPath), RPath);
>>>> >> }
>>>> >>
>>>> >> while (!DirStack.empty()) {
>>>> >> @@ -1531,7 +1609,8 @@ void YAMLVFSWriter::write(llvm::raw_ostr
>>>> >> return LHS.VPath < RHS.VPath;
>>>> >> });
>>>> >>
>>>> >> - JSONWriter(OS).write(Mappings, IsCaseSensitive);
>>>> >> + JSONWriter(OS).write(Mappings, IsCaseSensitive, IsOverlayRelative,
>>>> >> + OverlayDir);
>>>> >> }
>>>> >>
>>>> >> VFSFromYamlDirIterImpl::VFSFromYamlDirIterImpl(
>>>> >>
>>>> >> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>>>> >> URL:
>>>> >>
>>>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=261552&r1=261551&r2=261552&view=diff
>>>> >>
>>>> >>
>>>> >> ==============================================================================
>>>> >> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
>>>> >> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Feb 22 12:41:09
>>>> >> 2016
>>>> >> @@ -2344,8 +2344,8 @@ createVFSFromCompilerInvocation(const Co
>>>> >> return IntrusiveRefCntPtr<vfs::FileSystem>();
>>>> >> }
>>>> >>
>>>> >> - IntrusiveRefCntPtr<vfs::FileSystem> FS =
>>>> >> - vfs::getVFSFromYAML(std::move(Buffer.get()), /*DiagHandler*/
>>>> >> nullptr);
>>>> >> + IntrusiveRefCntPtr<vfs::FileSystem> FS = vfs::getVFSFromYAML(
>>>> >> + std::move(Buffer.get()), /*DiagHandler*/ nullptr, File);
>>>> >> if (!FS.get()) {
>>>> >> Diags.Report(diag::err_invalid_vfs_overlay) << File;
>>>> >> return IntrusiveRefCntPtr<vfs::FileSystem>();
>>>> >>
>>>> >> Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
>>>> >> URL:
>>>> >>
>>>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=261552&r1=261551&r2=261552&view=diff
>>>> >>
>>>> >>
>>>> >> ==============================================================================
>>>> >> --- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
>>>> >> +++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Mon Feb 22
>>>> >> 12:41:09 2016
>>>> >> @@ -51,6 +51,10 @@ void ModuleDependencyCollector::writeFil
>>>> >> SmallString<256> Dest = getDest();
>>>> >> llvm::sys::path::append(Dest, "vfs.yaml");
>>>> >>
>>>> >> + // Default to use relative overlay directories in the VFS yaml file.
>>>> >> This
>>>> >> + // allows crash reproducer scripts to work across machines.
>>>> >> + VFSWriter.setOverlayDir(getDest());
>>>> >> +
>>>> >> std::error_code EC;
>>>> >> llvm::raw_fd_ostream OS(Dest, EC, llvm::sys::fs::F_Text);
>>>> >> if (EC) {
>>>> >>
>>>> >> Modified: cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
>>>> >> URL:
>>>> >>
>>>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m?rev=261552&r1=261551&r2=261552&view=diff
>>>> >>
>>>> >>
>>>> >> ==============================================================================
>>>> >> --- cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
>>>> >> (original)
>>>> >> +++ cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m Mon Feb
>>>> >> 22
>>>> >> 12:41:09 2016
>>>> >> @@ -40,21 +40,21 @@
>>>> >> // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
>>>> >>
>>>> >> // CHECKYAML: 'type': 'directory'
>>>> >> -// CHECKYAML: 'name': "{{[^ ]*}}/i/usr/include",
>>>> >> +// CHECKYAML: 'name': "/[[PATH:.*]]/i/usr/include",
>>>> >> // CHECKYAML-NEXT: 'contents': [
>>>> >> // CHECKYAML-NEXT: {
>>>> >> // CHECKYAML-NEXT: 'type': 'file',
>>>> >> // CHECKYAML-NEXT: 'name': "module.map",
>>>> >> -// CHECKYAML-NEXT: 'external-contents': "{{[^ ]*}}.cache/vfs/{{[^
>>>> >> ]*}}/i/usr/include/module.map"
>>>> >> +// CHECKYAML-NEXT: 'external-contents':
>>>> >> "/[[PATH]]/i/usr/include/module.map"
>>>> >> // CHECKYAML-NEXT: },
>>>> >>
>>>> >> // CHECKYAML: 'type': 'directory'
>>>> >> -// CHECKYAML: 'name': "{{[^ ]*}}/i/usr",
>>>> >> +// CHECKYAML: 'name': "/[[PATH]]/i/usr",
>>>> >> // CHECKYAML-NEXT: 'contents': [
>>>> >> // CHECKYAML-NEXT: {
>>>> >> // CHECKYAML-NEXT: 'type': 'file',
>>>> >> // CHECKYAML-NEXT: 'name': "module.map",
>>>> >> -// CHECKYAML-NEXT: 'external-contents': "{{[^ ]*}}.cache/vfs/{{[^
>>>> >> ]*}}/i/usr/include/module.map"
>>>> >> +// CHECKYAML-NEXT: 'external-contents':
>>>> >> "/[[PATH]]/i/usr/include/module.map"
>>>> >> // CHECKYAML-NEXT: },
>>>> >>
>>>> >> // Test that by using the previous generated YAML file clang is able
>>>> >> to
>>>> >> find the
>>>> >>
>>>> >> Modified: cfe/trunk/test/Modules/crash-vfs-path-traversal.m
>>>> >> URL:
>>>> >>
>>>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-traversal.m?rev=261552&r1=261551&r2=261552&view=diff
>>>> >>
>>>> >>
>>>> >> ==============================================================================
>>>> >> --- cfe/trunk/test/Modules/crash-vfs-path-traversal.m (original)
>>>> >> +++ cfe/trunk/test/Modules/crash-vfs-path-traversal.m Mon Feb 22
>>>> >> 12:41:09
>>>> >> 2016
>>>> >> @@ -35,12 +35,12 @@
>>>> >> // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
>>>> >>
>>>> >> // CHECKYAML: 'type': 'directory'
>>>> >> -// CHECKYAML: 'name': "{{[^ ]*}}/Inputs/System/usr/include",
>>>> >> +// CHECKYAML: 'name': "/[[PATH:.*]]/Inputs/System/usr/include",
>>>> >> // CHECKYAML-NEXT: 'contents': [
>>>> >> // CHECKYAML-NEXT: {
>>>> >> // CHECKYAML-NEXT: 'type': 'file',
>>>> >> // CHECKYAML-NEXT: 'name': "module.map",
>>>> >> -// CHECKYAML-NEXT: 'external-contents': "{{[^
>>>> >> ]*}}/Inputs/System/usr/include/module.map"
>>>> >> +// CHECKYAML-NEXT: 'external-contents':
>>>> >> "/[[PATH]]/Inputs/System/usr/include/module.map"
>>>> >> // CHECKYAML-NEXT: },
>>>> >>
>>>> >> // Replace the paths in the YAML files with relative ".." traversals
>>>> >> @@ -49,9 +49,10 @@
>>>> >>
>>>> >> // RUN: sed -e "s at usr/include at usr/include/../include at g" \
>>>> >> // RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml > %t/vfs.yaml
>>>> >> +// RUN: cp %t/vfs.yaml %t/crash-vfs-*.cache/vfs/vfs.yaml
>>>> >> // RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH
>>>> >> // RUN: %clang -E %s -I %S/Inputs/System -isysroot %/t/i/ \
>>>> >> -// RUN: -ivfsoverlay %t/vfs.yaml -fmodules \
>>>> >> +// RUN: -ivfsoverlay %t/crash-vfs-*.cache/vfs/vfs.yaml -fmodules \
>>>> >> // RUN: -fmodules-cache-path=%t/m/ 2>&1 \
>>>> >> // RUN: | FileCheck %s --check-prefix=CHECKOVERLAY
>>>> >>
>>>> >>
>>>> >> Copied: cfe/trunk/test/Modules/crash-vfs-relative-overlay.m (from
>>>> >> r261551,
>>>> >> cfe/trunk/test/Modules/crash-vfs-path-traversal.m)
>>>> >> URL:
>>>> >>
>>>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-relative-overlay.m?p2=cfe/trunk/test/Modules/crash-vfs-relative-overlay.m&p1=cfe/trunk/test/Modules/crash-vfs-path-traversal.m&r1=261551&r2=261552&rev=261552&view=diff
>>>> >>
>>>> >>
>>>> >> ==============================================================================
>>>> >> --- cfe/trunk/test/Modules/crash-vfs-path-traversal.m (original)
>>>> >> +++ cfe/trunk/test/Modules/crash-vfs-relative-overlay.m Mon Feb 22
>>>> >> 12:41:09 2016
>>>> >> @@ -17,7 +17,7 @@
>>>> >> // RUN: find %t/crash-vfs-*.cache/vfs | \
>>>> >> // RUN: grep "Inputs/System/usr/include/stdio.h" | count 1
>>>> >>
>>>> >> -#include "usr/././//////include/../include/./././../include/stdio.h"
>>>> >> +#include "usr/include/stdio.h"
>>>> >>
>>>> >> // CHECK: Preprocessed source(s) and associated run script(s) are
>>>> >> located
>>>> >> at:
>>>> >> // CHECK-NEXT: note: diagnostic msg: {{.*}}.m
>>>> >> @@ -35,23 +35,21 @@
>>>> >> // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
>>>> >>
>>>> >> // CHECKYAML: 'type': 'directory'
>>>> >> -// CHECKYAML: 'name': "{{[^ ]*}}/Inputs/System/usr/include",
>>>> >> +// CHECKYAML: 'name': "/[[PATH:.*]]/Inputs/System/usr/include",
>>>> >> // CHECKYAML-NEXT: 'contents': [
>>>> >> // CHECKYAML-NEXT: {
>>>> >> // CHECKYAML-NEXT: 'type': 'file',
>>>> >> // CHECKYAML-NEXT: 'name': "module.map",
>>>> >> -// CHECKYAML-NEXT: 'external-contents': "{{[^
>>>> >> ]*}}/Inputs/System/usr/include/module.map"
>>>> >> +// CHECKYAML-NOT: 'external-contents': "{{[^ ]*}}.cache
>>>> >> +// CHECKYAML-NEXT: 'external-contents':
>>>> >> "/[[PATH]]/Inputs/System/usr/include/module.map"
>>>> >> // CHECKYAML-NEXT: },
>>>> >>
>>>> >> -// Replace the paths in the YAML files with relative ".." traversals
>>>> >> -// and fed into clang to test whether we're correctly representing
>>>> >> them
>>>> >> -// in the VFS overlay.
>>>> >> +// Test that reading the YAML file will yield the correct path after
>>>> >> +// the overlay dir is prefixed to access headers in .cache/vfs
>>>> >> directory.
>>>> >>
>>>> >> -// RUN: sed -e "s at usr/include at usr/include/../include at g" \
>>>> >> -// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml > %t/vfs.yaml
>>>> >> // RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH
>>>> >> // RUN: %clang -E %s -I %S/Inputs/System -isysroot %/t/i/ \
>>>> >> -// RUN: -ivfsoverlay %t/vfs.yaml -fmodules \
>>>> >> +// RUN: -ivfsoverlay %t/crash-vfs-*.cache/vfs/vfs.yaml -fmodules \
>>>> >> // RUN: -fmodules-cache-path=%t/m/ 2>&1 \
>>>> >> // RUN: | FileCheck %s --check-prefix=CHECKOVERLAY
>>>> >>
>>>> >>
>>>> >>
>>>> >> _______________________________________________
>>>> >> cfe-commits mailing list
>>>> >> cfe-commits at lists.llvm.org
>>>> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>> >
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Bruno Cardoso Lopes
>>>> http://www.brunocardoso.cc
>>>
>>>
>>
>>
>>
>> --
>> Bruno Cardoso Lopes
>> http://www.brunocardoso.cc
>
>
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc
--
Bruno Cardoso Lopes
http://www.brunocardoso.cc
More information about the cfe-commits
mailing list