LLVM  15.0.0git
VirtualFileSystem.h
Go to the documentation of this file.
1 //===- VirtualFileSystem.h - Virtual File System Layer ----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// Defines the virtual file system interface vfs::FileSystem.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_SUPPORT_VIRTUALFILESYSTEM_H
15 #define LLVM_SUPPORT_VIRTUALFILESYSTEM_H
16 
18 #include "llvm/ADT/None.h"
19 #include "llvm/ADT/Optional.h"
20 #include "llvm/ADT/SmallVector.h"
21 #include "llvm/ADT/StringRef.h"
23 #include "llvm/Support/Chrono.h"
24 #include "llvm/Support/ErrorOr.h"
25 #include "llvm/Support/Errc.h"
27 #include "llvm/Support/Path.h"
28 #include "llvm/Support/SourceMgr.h"
29 #include <cassert>
30 #include <cstdint>
31 #include <ctime>
32 #include <memory>
33 #include <stack>
34 #include <string>
35 #include <system_error>
36 #include <utility>
37 #include <vector>
38 
39 namespace llvm {
40 
41 class MemoryBuffer;
42 class MemoryBufferRef;
43 class Twine;
44 
45 namespace vfs {
46 
47 /// The result of a \p status operation.
48 class Status {
49  std::string Name;
52  uint32_t User;
53  uint32_t Group;
54  uint64_t Size;
57 
58 public:
59  // FIXME: remove when files support multiple names
60  bool IsVFSMapped = false;
61 
62  /// Whether this entity has an external path different from the virtual path,
63  /// and the external path is exposed by leaking it through the abstraction.
64  /// For example, a RedirectingFileSystem will set this for paths where
65  /// UseExternalName is true.
66  ///
67  /// FIXME: Currently the external path is exposed by replacing the virtual
68  /// path in this Status object. Instead, we should leave the path in the
69  /// Status intact (matching the requested virtual path) - see
70  /// FileManager::getFileRef for how how we plan to fix this.
71  bool ExposesExternalVFSPath = false;
72 
73  Status() = default;
75  Status(const Twine &Name, llvm::sys::fs::UniqueID UID,
78  llvm::sys::fs::perms Perms);
79 
80  /// Get a copy of a Status with a different size.
81  static Status copyWithNewSize(const Status &In, uint64_t NewSize);
82  /// Get a copy of a Status with a different name.
83  static Status copyWithNewName(const Status &In, const Twine &NewName);
85  const Twine &NewName);
86 
87  /// Returns the name that should be used for this file or directory.
88  StringRef getName() const { return Name; }
89 
90  /// @name Status interface from llvm::sys::fs
91  /// @{
93  llvm::sys::fs::perms getPermissions() const { return Perms; }
95  llvm::sys::fs::UniqueID getUniqueID() const { return UID; }
96  uint32_t getUser() const { return User; }
97  uint32_t getGroup() const { return Group; }
98  uint64_t getSize() const { return Size; }
99  /// @}
100  /// @name Status queries
101  /// These are static queries in llvm::sys::fs.
102  /// @{
103  bool equivalent(const Status &Other) const;
104  bool isDirectory() const;
105  bool isRegularFile() const;
106  bool isOther() const;
107  bool isSymlink() const;
108  bool isStatusKnown() const;
109  bool exists() const;
110  /// @}
111 };
112 
113 /// Represents an open file.
114 class File {
115 public:
116  /// Destroy the file after closing it (if open).
117  /// Sub-classes should generally call close() inside their destructors. We
118  /// cannot do that from the base class, since close is virtual.
119  virtual ~File();
120 
121  /// Get the status of the file.
122  virtual llvm::ErrorOr<Status> status() = 0;
123 
124  /// Get the name of the file
126  if (auto Status = status())
127  return Status->getName().str();
128  else
129  return Status.getError();
130  }
131 
132  /// Get the contents of the file as a \p MemoryBuffer.
134  getBuffer(const Twine &Name, int64_t FileSize = -1,
135  bool RequiresNullTerminator = true, bool IsVolatile = false) = 0;
136 
137  /// Closes the file.
138  virtual std::error_code close() = 0;
139 
140  // Get the same file with a different path.
142  getWithPath(ErrorOr<std::unique_ptr<File>> Result, const Twine &P);
143 
144 protected:
145  // Set the file's underlying path.
146  virtual void setPath(const Twine &Path) {}
147 };
148 
149 /// A member of a directory, yielded by a directory_iterator.
150 /// Only information available on most platforms is included.
152  std::string Path;
154 
155 public:
156  directory_entry() = default;
158  : Path(std::move(Path)), Type(Type) {}
159 
160  llvm::StringRef path() const { return Path; }
161  llvm::sys::fs::file_type type() const { return Type; }
162 };
163 
164 namespace detail {
165 
166 /// An interface for virtual file systems to provide an iterator over the
167 /// (non-recursive) contents of a directory.
168 struct DirIterImpl {
169  virtual ~DirIterImpl();
170 
171  /// Sets \c CurrentEntry to the next entry in the directory on success,
172  /// to directory_entry() at end, or returns a system-defined \c error_code.
173  virtual std::error_code increment() = 0;
174 
176 };
177 
178 } // namespace detail
179 
180 /// An input iterator over the entries in a virtual path, similar to
181 /// llvm::sys::fs::directory_iterator.
183  std::shared_ptr<detail::DirIterImpl> Impl; // Input iterator semantics on copy
184 
185 public:
186  directory_iterator(std::shared_ptr<detail::DirIterImpl> I)
187  : Impl(std::move(I)) {
188  assert(Impl.get() != nullptr && "requires non-null implementation");
189  if (Impl->CurrentEntry.path().empty())
190  Impl.reset(); // Normalize the end iterator to Impl == nullptr.
191  }
192 
193  /// Construct an 'end' iterator.
194  directory_iterator() = default;
195 
196  /// Equivalent to operator++, with an error code.
197  directory_iterator &increment(std::error_code &EC) {
198  assert(Impl && "attempting to increment past end");
199  EC = Impl->increment();
200  if (Impl->CurrentEntry.path().empty())
201  Impl.reset(); // Normalize the end iterator to Impl == nullptr.
202  return *this;
203  }
204 
205  const directory_entry &operator*() const { return Impl->CurrentEntry; }
206  const directory_entry *operator->() const { return &Impl->CurrentEntry; }
207 
208  bool operator==(const directory_iterator &RHS) const {
209  if (Impl && RHS.Impl)
210  return Impl->CurrentEntry.path() == RHS.Impl->CurrentEntry.path();
211  return !Impl && !RHS.Impl;
212  }
213  bool operator!=(const directory_iterator &RHS) const {
214  return !(*this == RHS);
215  }
216 };
217 
218 class FileSystem;
219 
220 namespace detail {
221 
222 /// Keeps state for the recursive_directory_iterator.
224  std::stack<directory_iterator, std::vector<directory_iterator>> Stack;
225  bool HasNoPushRequest = false;
226 };
227 
228 } // end namespace detail
229 
230 /// An input iterator over the recursive contents of a virtual path,
231 /// similar to llvm::sys::fs::recursive_directory_iterator.
233  FileSystem *FS;
234  std::shared_ptr<detail::RecDirIterState>
235  State; // Input iterator semantics on copy.
236 
237 public:
239  std::error_code &EC);
240 
241  /// Construct an 'end' iterator.
242  recursive_directory_iterator() = default;
243 
244  /// Equivalent to operator++, with an error code.
245  recursive_directory_iterator &increment(std::error_code &EC);
246 
247  const directory_entry &operator*() const { return *State->Stack.top(); }
248  const directory_entry *operator->() const { return &*State->Stack.top(); }
249 
250  bool operator==(const recursive_directory_iterator &Other) const {
251  return State == Other.State; // identity
252  }
254  return !(*this == RHS);
255  }
256 
257  /// Gets the current level. Starting path is at level 0.
258  int level() const {
259  assert(!State->Stack.empty() &&
260  "Cannot get level without any iteration state");
261  return State->Stack.size() - 1;
262  }
263 
264  void no_push() { State->HasNoPushRequest = true; }
265 };
266 
267 /// The virtual file system interface.
268 class FileSystem : public llvm::ThreadSafeRefCountedBase<FileSystem> {
269 public:
270  virtual ~FileSystem();
271 
272  /// Get the status of the entry at \p Path, if one exists.
273  virtual llvm::ErrorOr<Status> status(const Twine &Path) = 0;
274 
275  /// Get a \p File object for the file at \p Path, if one exists.
277  openFileForRead(const Twine &Path) = 0;
278 
279  /// This is a convenience method that opens a file, gets its content and then
280  /// closes the file.
282  getBufferForFile(const Twine &Name, int64_t FileSize = -1,
283  bool RequiresNullTerminator = true, bool IsVolatile = false);
284 
285  /// Get a directory_iterator for \p Dir.
286  /// \note The 'end' iterator is directory_iterator().
287  virtual directory_iterator dir_begin(const Twine &Dir,
288  std::error_code &EC) = 0;
289 
290  /// Set the working directory. This will affect all following operations on
291  /// this file system and may propagate down for nested file systems.
292  virtual std::error_code setCurrentWorkingDirectory(const Twine &Path) = 0;
293 
294  /// Get the working directory of this file system.
296 
297  /// Gets real path of \p Path e.g. collapse all . and .. patterns, resolve
298  /// symlinks. For real file system, this uses `llvm::sys::fs::real_path`.
299  /// This returns errc::operation_not_permitted if not implemented by subclass.
300  virtual std::error_code getRealPath(const Twine &Path,
301  SmallVectorImpl<char> &Output) const;
302 
303  /// Check whether a file exists. Provided for convenience.
304  bool exists(const Twine &Path);
305 
306  /// Is the file mounted on a local filesystem?
307  virtual std::error_code isLocal(const Twine &Path, bool &Result);
308 
309  /// Make \a Path an absolute path.
310  ///
311  /// Makes \a Path absolute using the current directory if it is not already.
312  /// An empty \a Path will result in the current directory.
313  ///
314  /// /absolute/path => /absolute/path
315  /// relative/../path => <current-directory>/relative/../path
316  ///
317  /// \param Path A path that is modified to be an absolute path.
318  /// \returns success if \a path has been made absolute, otherwise a
319  /// platform-specific error_code.
320  virtual std::error_code makeAbsolute(SmallVectorImpl<char> &Path) const;
321 
324  unsigned IndentLevel = 0) const {
325  printImpl(OS, Type, IndentLevel);
326  }
327 
328 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
329  LLVM_DUMP_METHOD void dump() const;
330 #endif
331 
332 protected:
333  virtual void printImpl(raw_ostream &OS, PrintType Type,
334  unsigned IndentLevel) const {
335  printIndent(OS, IndentLevel);
336  OS << "FileSystem\n";
337  }
338 
339  void printIndent(raw_ostream &OS, unsigned IndentLevel) const {
340  for (unsigned i = 0; i < IndentLevel; ++i)
341  OS << " ";
342  }
343 };
344 
345 /// Gets an \p vfs::FileSystem for the 'real' file system, as seen by
346 /// the operating system.
347 /// The working directory is linked to the process's working directory.
348 /// (This is usually thread-hostile).
350 
351 /// Create an \p vfs::FileSystem for the 'real' file system, as seen by
352 /// the operating system.
353 /// It has its own working directory, independent of (but initially equal to)
354 /// that of the process.
355 std::unique_ptr<FileSystem> createPhysicalFileSystem();
356 
357 /// A file system that allows overlaying one \p AbstractFileSystem on top
358 /// of another.
359 ///
360 /// Consists of a stack of >=1 \p FileSystem objects, which are treated as being
361 /// one merged file system. When there is a directory that exists in more than
362 /// one file system, the \p OverlayFileSystem contains a directory containing
363 /// the union of their contents. The attributes (permissions, etc.) of the
364 /// top-most (most recently added) directory are used. When there is a file
365 /// that exists in more than one file system, the file in the top-most file
366 /// system overrides the other(s).
369 
370  /// The stack of file systems, implemented as a list in order of
371  /// their addition.
372  FileSystemList FSList;
373 
374 public:
376 
377  /// Pushes a file system on top of the stack.
379 
380  llvm::ErrorOr<Status> status(const Twine &Path) override;
382  openFileForRead(const Twine &Path) override;
383  directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
385  std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
386  std::error_code isLocal(const Twine &Path, bool &Result) override;
387  std::error_code getRealPath(const Twine &Path,
388  SmallVectorImpl<char> &Output) const override;
389 
390  using iterator = FileSystemList::reverse_iterator;
391  using const_iterator = FileSystemList::const_reverse_iterator;
396 
397  /// Get an iterator pointing to the most recently added file system.
398  iterator overlays_begin() { return FSList.rbegin(); }
399  const_iterator overlays_begin() const { return FSList.rbegin(); }
400 
401  /// Get an iterator pointing one-past the least recently added file system.
402  iterator overlays_end() { return FSList.rend(); }
403  const_iterator overlays_end() const { return FSList.rend(); }
404 
405  /// Get an iterator pointing to the least recently added file system.
406  reverse_iterator overlays_rbegin() { return FSList.begin(); }
407  const_reverse_iterator overlays_rbegin() const { return FSList.begin(); }
408 
409  /// Get an iterator pointing one-past the most recently added file system.
410  reverse_iterator overlays_rend() { return FSList.end(); }
411  const_reverse_iterator overlays_rend() const { return FSList.end(); }
412 
413  range overlays_range() { return llvm::reverse(FSList); }
414  const_range overlays_range() const { return llvm::reverse(FSList); }
415 
416 protected:
418  unsigned IndentLevel) const override;
419 };
420 
421 /// By default, this delegates all calls to the underlying file system. This
422 /// is useful when derived file systems want to override some calls and still
423 /// proxy other calls.
424 class ProxyFileSystem : public FileSystem {
425 public:
427  : FS(std::move(FS)) {}
428 
429  llvm::ErrorOr<Status> status(const Twine &Path) override {
430  return FS->status(Path);
431  }
433  openFileForRead(const Twine &Path) override {
434  return FS->openFileForRead(Path);
435  }
436  directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override {
437  return FS->dir_begin(Dir, EC);
438  }
440  return FS->getCurrentWorkingDirectory();
441  }
442  std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
443  return FS->setCurrentWorkingDirectory(Path);
444  }
445  std::error_code getRealPath(const Twine &Path,
446  SmallVectorImpl<char> &Output) const override {
447  return FS->getRealPath(Path, Output);
448  }
449  std::error_code isLocal(const Twine &Path, bool &Result) override {
450  return FS->isLocal(Path, Result);
451  }
452 
453 protected:
454  FileSystem &getUnderlyingFS() { return *FS; }
455 
456 private:
458 
459  virtual void anchor();
460 };
461 
462 namespace detail {
463 
464 class InMemoryDirectory;
465 class InMemoryFile;
466 class InMemoryNode;
467 
473  std::unique_ptr<llvm::MemoryBuffer> Buffer;
478 
479  Status makeStatus() const;
480 };
481 
484  Value;
485 
486 public:
488  const detail::InMemoryNode *Node)
489  : Value(std::make_pair(Name, Node)) {}
490  NamedNodeOrError(std::error_code EC) : Value(EC) {}
492 
493  StringRef getName() const { return (*Value).first; }
494  explicit operator bool() const { return static_cast<bool>(Value); }
495  operator std::error_code() const { return Value.getError(); }
496  std::error_code getError() const { return Value.getError(); }
497  const detail::InMemoryNode *operator*() const { return (*Value).second; }
498 };
499 
500 } // namespace detail
501 
502 /// An in-memory file system.
504  std::unique_ptr<detail::InMemoryDirectory> Root;
505  std::string WorkingDirectory;
506  bool UseNormalizedPaths = true;
507 
510 
511  /// Create node with \p MakeNode and add it into this filesystem at \p Path.
512  bool addFile(const Twine &Path, time_t ModificationTime,
513  std::unique_ptr<llvm::MemoryBuffer> Buffer,
517 
518  /// Looks up the in-memory node for the path \param P.
519  /// If \param FollowFinalSymlink is true, the returned node is guaranteed to
520  /// not be a symlink and its path may differ from \param P.
521  detail::NamedNodeOrError lookupNode(const Twine &P, bool FollowFinalSymlink,
522  size_t SymlinkDepth = 0) const;
523 
524  class DirIterator;
525 
526 public:
527  explicit InMemoryFileSystem(bool UseNormalizedPaths = true);
528  ~InMemoryFileSystem() override;
529 
530  /// Add a file containing a buffer or a directory to the VFS with a
531  /// path. The VFS owns the buffer. If present, User, Group, Type
532  /// and Perms apply to the newly-created file or directory.
533  /// \return true if the file or directory was successfully added,
534  /// false if the file or directory already exists in the file system with
535  /// different contents.
536  bool addFile(const Twine &Path, time_t ModificationTime,
537  std::unique_ptr<llvm::MemoryBuffer> Buffer,
541 
542  /// Add a hard link to a file.
543  ///
544  /// Here hard links are not intended to be fully equivalent to the classical
545  /// filesystem. Both the hard link and the file share the same buffer and
546  /// status (and thus have the same UniqueID). Because of this there is no way
547  /// to distinguish between the link and the file after the link has been
548  /// added.
549  ///
550  /// The \param Target path must be an existing file or a hardlink. The
551  /// \param NewLink file must not have been added before. The \param Target
552  /// path must not be a directory. The \param NewLink node is added as a hard
553  /// link which points to the resolved file of \param Target node.
554  /// \return true if the above condition is satisfied and hardlink was
555  /// successfully created, false otherwise.
556  bool addHardLink(const Twine &NewLink, const Twine &Target);
557 
558  /// Arbitrary max depth to search through symlinks. We can get into problems
559  /// if a link links to a link that links back to the link, for example.
560  static constexpr size_t MaxSymlinkDepth = 16;
561 
562  /// Add a symbolic link. Unlike a HardLink, because \param Target doesn't need
563  /// to refer to a file (or refer to anything, as it happens). Also, an
564  /// in-memory directory for \param Target isn't automatically created.
565  bool addSymbolicLink(const Twine &NewLink, const Twine &Target,
566  time_t ModificationTime, Optional<uint32_t> User = None,
567  Optional<uint32_t> Group = None,
569 
570  /// Add a buffer to the VFS with a path. The VFS does not own the buffer.
571  /// If present, User, Group, Type and Perms apply to the newly-created file
572  /// or directory.
573  /// \return true if the file or directory was successfully added,
574  /// false if the file or directory already exists in the file system with
575  /// different contents.
576  bool addFileNoOwn(const Twine &Path, time_t ModificationTime,
577  const llvm::MemoryBufferRef &Buffer,
579  Optional<uint32_t> Group = None,
582 
583  std::string toString() const;
584 
585  /// Return true if this file system normalizes . and .. in paths.
586  bool useNormalizedPaths() const { return UseNormalizedPaths; }
587 
588  llvm::ErrorOr<Status> status(const Twine &Path) override;
590  openFileForRead(const Twine &Path) override;
591  directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
592 
594  return WorkingDirectory;
595  }
596  /// Canonicalizes \p Path by combining with the current working
597  /// directory and normalizing the path (e.g. remove dots). If the current
598  /// working directory is not set, this returns errc::operation_not_permitted.
599  ///
600  /// This doesn't resolve symlinks as they are not supported in in-memory file
601  /// system.
602  std::error_code getRealPath(const Twine &Path,
603  SmallVectorImpl<char> &Output) const override;
604  std::error_code isLocal(const Twine &Path, bool &Result) override;
605  std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
606 
607 protected:
609  unsigned IndentLevel) const override;
610 };
611 
612 /// Get a globally unique ID for a virtual file or directory.
614 
615 /// Gets a \p FileSystem for a virtual file system described in YAML
616 /// format.
617 std::unique_ptr<FileSystem>
618 getVFSFromYAML(std::unique_ptr<llvm::MemoryBuffer> Buffer,
620  StringRef YAMLFilePath, void *DiagContext = nullptr,
622 
623 struct YAMLVFSEntry {
624  template <typename T1, typename T2>
625  YAMLVFSEntry(T1 &&VPath, T2 &&RPath, bool IsDirectory = false)
626  : VPath(std::forward<T1>(VPath)), RPath(std::forward<T2>(RPath)),
628  std::string VPath;
629  std::string RPath;
630  bool IsDirectory = false;
631 };
632 
635 
636 /// A virtual file system parsed from a YAML file.
637 ///
638 /// Currently, this class allows creating virtual files and directories. Virtual
639 /// files map to existing external files in \c ExternalFS, and virtual
640 /// directories may either map to existing directories in \c ExternalFS or list
641 /// their contents in the form of other virtual directories and/or files.
642 ///
643 /// The basic structure of the parsed file is:
644 /// \verbatim
645 /// {
646 /// 'version': <version number>,
647 /// <optional configuration>
648 /// 'roots': [
649 /// <directory entries>
650 /// ]
651 /// }
652 /// \endverbatim
653 ///
654 /// The roots may be absolute or relative. If relative they will be made
655 /// absolute against the current working directory.
656 ///
657 /// All configuration options are optional.
658 /// 'case-sensitive': <boolean, default=(true for Posix, false for Windows)>
659 /// 'use-external-names': <boolean, default=true>
660 /// 'overlay-relative': <boolean, default=false>
661 /// 'fallthrough': <boolean, default=true, deprecated - use 'redirecting-with'
662 /// instead>
663 /// 'redirecting-with': <string, one of 'fallthrough', 'fallback', or
664 /// 'redirect-only', default='fallthrough'>
665 ///
666 /// Virtual directories that list their contents are represented as
667 /// \verbatim
668 /// {
669 /// 'type': 'directory',
670 /// 'name': <string>,
671 /// 'contents': [ <file or directory entries> ]
672 /// }
673 /// \endverbatim
674 ///
675 /// The default attributes for such virtual directories are:
676 /// \verbatim
677 /// MTime = now() when created
678 /// Perms = 0777
679 /// User = Group = 0
680 /// Size = 0
681 /// UniqueID = unspecified unique value
682 /// \endverbatim
683 ///
684 /// When a path prefix matches such a directory, the next component in the path
685 /// is matched against the entries in the 'contents' array.
686 ///
687 /// Re-mapped directories, on the other hand, are represented as
688 /// /// \verbatim
689 /// {
690 /// 'type': 'directory-remap',
691 /// 'name': <string>,
692 /// 'use-external-name': <boolean>, # Optional
693 /// 'external-contents': <path to external directory>
694 /// }
695 /// \endverbatim
696 ///
697 /// and inherit their attributes from the external directory. When a path
698 /// prefix matches such an entry, the unmatched components are appended to the
699 /// 'external-contents' path, and the resulting path is looked up in the
700 /// external file system instead.
701 ///
702 /// Re-mapped files are represented as
703 /// \verbatim
704 /// {
705 /// 'type': 'file',
706 /// 'name': <string>,
707 /// 'use-external-name': <boolean>, # Optional
708 /// 'external-contents': <path to external file>
709 /// }
710 /// \endverbatim
711 ///
712 /// Their attributes and file contents are determined by looking up the file at
713 /// their 'external-contents' path in the external file system.
714 ///
715 /// For 'file', 'directory' and 'directory-remap' entries the 'name' field may
716 /// contain multiple path components (e.g. /path/to/file). However, any
717 /// directory in such a path that contains more than one child must be uniquely
718 /// represented by a 'directory' entry.
719 ///
720 /// When the 'use-external-name' field is set, calls to \a vfs::File::status()
721 /// give the external (remapped) filesystem name instead of the name the file
722 /// was accessed by. This is an intentional leak through the \a
723 /// RedirectingFileSystem abstraction layer. It enables clients to discover
724 /// (and use) the external file location when communicating with users or tools
725 /// that don't use the same VFS overlay.
726 ///
727 /// FIXME: 'use-external-name' causes behaviour that's inconsistent with how
728 /// "real" filesystems behave. Maybe there should be a separate channel for
729 /// this information.
731 public:
734 
735  /// The type of redirection to perform.
736  enum class RedirectKind {
737  /// Lookup the redirected path first (ie. the one specified in
738  /// 'external-contents') and if that fails "fallthrough" to a lookup of the
739  /// originally provided path.
740  Fallthrough,
741  /// Lookup the provided path first and if that fails, "fallback" to a
742  /// lookup of the redirected path.
743  Fallback,
744  /// Only lookup the redirected path, do not lookup the originally provided
745  /// path.
747  };
748 
749  /// A single file or directory in the VFS.
750  class Entry {
751  EntryKind Kind;
752  std::string Name;
753 
754  public:
755  Entry(EntryKind K, StringRef Name) : Kind(K), Name(Name) {}
756  virtual ~Entry() = default;
757 
758  StringRef getName() const { return Name; }
759  EntryKind getKind() const { return Kind; }
760  };
761 
762  /// A directory in the vfs with explicitly specified contents.
763  class DirectoryEntry : public Entry {
764  std::vector<std::unique_ptr<Entry>> Contents;
765  Status S;
766 
767  public:
768  /// Constructs a directory entry with explicitly specified contents.
769  DirectoryEntry(StringRef Name, std::vector<std::unique_ptr<Entry>> Contents,
770  Status S)
771  : Entry(EK_Directory, Name), Contents(std::move(Contents)),
772  S(std::move(S)) {}
773 
774  /// Constructs an empty directory entry.
776  : Entry(EK_Directory, Name), S(std::move(S)) {}
777 
778  Status getStatus() { return S; }
779 
780  void addContent(std::unique_ptr<Entry> Content) {
781  Contents.push_back(std::move(Content));
782  }
783 
784  Entry *getLastContent() const { return Contents.back().get(); }
785 
786  using iterator = decltype(Contents)::iterator;
787 
788  iterator contents_begin() { return Contents.begin(); }
789  iterator contents_end() { return Contents.end(); }
790 
791  static bool classof(const Entry *E) { return E->getKind() == EK_Directory; }
792  };
793 
794  /// A file or directory in the vfs that is mapped to a file or directory in
795  /// the external filesystem.
796  class RemapEntry : public Entry {
797  std::string ExternalContentsPath;
798  NameKind UseName;
799 
800  protected:
801  RemapEntry(EntryKind K, StringRef Name, StringRef ExternalContentsPath,
802  NameKind UseName)
803  : Entry(K, Name), ExternalContentsPath(ExternalContentsPath),
804  UseName(UseName) {}
805 
806  public:
807  StringRef getExternalContentsPath() const { return ExternalContentsPath; }
808 
809  /// Whether to use the external path as the name for this file or directory.
810  bool useExternalName(bool GlobalUseExternalName) const {
811  return UseName == NK_NotSet ? GlobalUseExternalName
812  : (UseName == NK_External);
813  }
814 
815  NameKind getUseName() const { return UseName; }
816 
817  static bool classof(const Entry *E) {
818  switch (E->getKind()) {
819  case EK_DirectoryRemap:
821  case EK_File:
822  return true;
823  case EK_Directory:
824  return false;
825  }
826  llvm_unreachable("invalid entry kind");
827  }
828  };
829 
830  /// A directory in the vfs that maps to a directory in the external file
831  /// system.
833  public:
834  DirectoryRemapEntry(StringRef Name, StringRef ExternalContentsPath,
835  NameKind UseName)
836  : RemapEntry(EK_DirectoryRemap, Name, ExternalContentsPath, UseName) {}
837 
838  static bool classof(const Entry *E) {
839  return E->getKind() == EK_DirectoryRemap;
840  }
841  };
842 
843  /// A file in the vfs that maps to a file in the external file system.
844  class FileEntry : public RemapEntry {
845  public:
846  FileEntry(StringRef Name, StringRef ExternalContentsPath, NameKind UseName)
847  : RemapEntry(EK_File, Name, ExternalContentsPath, UseName) {}
848 
849  static bool classof(const Entry *E) { return E->getKind() == EK_File; }
850  };
851 
852  /// Represents the result of a path lookup into the RedirectingFileSystem.
853  struct LookupResult {
854  /// The entry the looked-up path corresponds to.
856 
857  private:
858  /// When the found Entry is a DirectoryRemapEntry, stores the path in the
859  /// external file system that the looked-up path in the virtual file system
860  // corresponds to.
861  Optional<std::string> ExternalRedirect;
862 
863  public:
866 
867  /// If the found Entry maps the the input path to a path in the external
868  /// file system (i.e. it is a FileEntry or DirectoryRemapEntry), returns
869  /// that path.
871  if (isa<DirectoryRemapEntry>(E))
872  return StringRef(*ExternalRedirect);
873  if (auto *FE = dyn_cast<FileEntry>(E))
874  return FE->getExternalContentsPath();
875  return None;
876  }
877  };
878 
879 private:
882 
883  /// Canonicalize path by removing ".", "..", "./", components. This is
884  /// a VFS request, do not bother about symlinks in the path components
885  /// but canonicalize in order to perform the correct entry search.
886  std::error_code makeCanonical(SmallVectorImpl<char> &Path) const;
887 
888  /// Get the File status, or error, from the underlying external file system.
889  /// This returns the status with the originally requested name, while looking
890  /// up the entry using the canonical path.
891  ErrorOr<Status> getExternalStatus(const Twine &CanonicalPath,
892  const Twine &OriginalPath) const;
893 
894  // In a RedirectingFileSystem, keys can be specified in Posix or Windows
895  // style (or even a mixture of both), so this comparison helper allows
896  // slashes (representing a root) to match backslashes (and vice versa). Note
897  // that, other than the root, path components should not contain slashes or
898  // backslashes.
899  bool pathComponentMatches(llvm::StringRef lhs, llvm::StringRef rhs) const {
900  if ((CaseSensitive ? lhs.equals(rhs) : lhs.equals_insensitive(rhs)))
901  return true;
902  return (lhs == "/" && rhs == "\\") || (lhs == "\\" && rhs == "/");
903  }
904 
905  /// The root(s) of the virtual file system.
906  std::vector<std::unique_ptr<Entry>> Roots;
907 
908  /// The current working directory of the file system.
909  std::string WorkingDirectory;
910 
911  /// The file system to use for external references.
913 
914  /// If IsRelativeOverlay is set, this represents the directory
915  /// path that should be prefixed to each 'external-contents' entry
916  /// when reading from YAML files.
917  std::string ExternalContentsPrefixDir;
918 
919  /// @name Configuration
920  /// @{
921 
922  /// Whether to perform case-sensitive comparisons.
923  ///
924  /// Currently, case-insensitive matching only works correctly with ASCII.
925  bool CaseSensitive = is_style_posix(sys::path::Style::native);
926 
927  /// IsRelativeOverlay marks whether a ExternalContentsPrefixDir path must
928  /// be prefixed in every 'external-contents' when reading from YAML files.
929  bool IsRelativeOverlay = false;
930 
931  /// Whether to use to use the value of 'external-contents' for the
932  /// names of files. This global value is overridable on a per-file basis.
933  bool UseExternalNames = true;
934 
935  /// Determines the lookups to perform, as well as their order. See
936  /// \c RedirectKind for details.
938  /// @}
939 
941 
942  /// Looks up the path <tt>[Start, End)</tt> in \p From, possibly recursing
943  /// into the contents of \p From if it is a directory. Returns a LookupResult
944  /// giving the matched entry and, if that entry is a FileEntry or
945  /// DirectoryRemapEntry, the path it redirects to in the external file system.
948  Entry *From) const;
949 
950  /// Get the status for a path with the provided \c LookupResult.
951  ErrorOr<Status> status(const Twine &CanonicalPath, const Twine &OriginalPath,
952  const LookupResult &Result);
953 
954 public:
955  /// Looks up \p Path in \c Roots and returns a LookupResult giving the
956  /// matched entry and, if the entry was a FileEntry or DirectoryRemapEntry,
957  /// the path it redirects to in the external file system.
959 
960  /// Parses \p Buffer, which is expected to be in YAML format and
961  /// returns a virtual file system representing its contents.
962  static std::unique_ptr<RedirectingFileSystem>
963  create(std::unique_ptr<MemoryBuffer> Buffer,
965  void *DiagContext, IntrusiveRefCntPtr<FileSystem> ExternalFS);
966 
967  /// Redirect each of the remapped files from first to second.
968  static std::unique_ptr<RedirectingFileSystem>
969  create(ArrayRef<std::pair<std::string, std::string>> RemappedFiles,
970  bool UseExternalNames, FileSystem &ExternalFS);
971 
972  ErrorOr<Status> status(const Twine &Path) override;
973  ErrorOr<std::unique_ptr<File>> openFileForRead(const Twine &Path) override;
974 
975  std::error_code getRealPath(const Twine &Path,
976  SmallVectorImpl<char> &Output) const override;
977 
979 
980  std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
981 
982  std::error_code isLocal(const Twine &Path, bool &Result) override;
983 
984  std::error_code makeAbsolute(SmallVectorImpl<char> &Path) const override;
985 
986  directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
987 
988  void setExternalContentsPrefixDir(StringRef PrefixDir);
989 
991 
992  /// Sets the redirection kind to \c Fallthrough if true or \c RedirectOnly
993  /// otherwise. Will removed in the future, use \c setRedirection instead.
994  void setFallthrough(bool Fallthrough);
995 
997 
998  std::vector<llvm::StringRef> getRoots() const;
999 
1000  void printEntry(raw_ostream &OS, Entry *E, unsigned IndentLevel = 0) const;
1001 
1002 protected:
1003  void printImpl(raw_ostream &OS, PrintType Type,
1004  unsigned IndentLevel) const override;
1005 };
1006 
1007 /// Collect all pairs of <virtual path, real path> entries from the
1008 /// \p YAMLFilePath. This is used by the module dependency collector to forward
1009 /// the entries into the reproducer output VFS YAML file.
1010 void collectVFSFromYAML(
1011  std::unique_ptr<llvm::MemoryBuffer> Buffer,
1013  SmallVectorImpl<YAMLVFSEntry> &CollectedEntries,
1014  void *DiagContext = nullptr,
1016 
1018  std::vector<YAMLVFSEntry> Mappings;
1019  Optional<bool> IsCaseSensitive;
1020  Optional<bool> IsOverlayRelative;
1021  Optional<bool> UseExternalNames;
1022  std::string OverlayDir;
1023 
1024  void addEntry(StringRef VirtualPath, StringRef RealPath, bool IsDirectory);
1025 
1026 public:
1027  YAMLVFSWriter() = default;
1028 
1029  void addFileMapping(StringRef VirtualPath, StringRef RealPath);
1030  void addDirectoryMapping(StringRef VirtualPath, StringRef RealPath);
1031 
1032  void setCaseSensitivity(bool CaseSensitive) {
1033  IsCaseSensitive = CaseSensitive;
1034  }
1035 
1036  void setUseExternalNames(bool UseExtNames) { UseExternalNames = UseExtNames; }
1037 
1038  void setOverlayDir(StringRef OverlayDirectory) {
1039  IsOverlayRelative = true;
1040  OverlayDir.assign(OverlayDirectory.str());
1041  }
1042 
1043  const std::vector<YAMLVFSEntry> &getMappings() const { return Mappings; }
1044 
1045  void write(llvm::raw_ostream &OS);
1046 };
1047 
1048 } // namespace vfs
1049 } // namespace llvm
1050 
1051 #endif // LLVM_SUPPORT_VIRTUALFILESYSTEM_H
i
i
Definition: README.txt:29
llvm::vfs::File::getBuffer
virtual llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBuffer(const Twine &Name, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false)=0
Get the contents of the file as a MemoryBuffer.
llvm::vfs::RedirectingFileSystem::EK_File
@ EK_File
Definition: VirtualFileSystem.h:732
llvm::vfs::RedirectingFSDirIterImpl
Directory iterator implementation for RedirectingFileSystem's directory entries.
Definition: VirtualFileSystem.cpp:1234
llvm::vfs::InMemoryFileSystem::setCurrentWorkingDirectory
std::error_code setCurrentWorkingDirectory(const Twine &Path) override
Set the working directory.
Definition: VirtualFileSystem.cpp:1138
llvm::vfs::FileSystem::dir_begin
virtual directory_iterator dir_begin(const Twine &Dir, std::error_code &EC)=0
Get a directory_iterator for Dir.
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:494
llvm::vfs::Status::isRegularFile
bool isRegularFile() const
Definition: VirtualFileSystem.cpp:100
llvm::vfs::RedirectingFileSystem::setCurrentWorkingDirectory
std::error_code setCurrentWorkingDirectory(const Twine &Path) override
Set the working directory.
Definition: VirtualFileSystem.cpp:1324
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::vfs::RedirectingFileSystem::DirectoryEntry::getLastContent
Entry * getLastContent() const
Definition: VirtualFileSystem.h:784
llvm::vfs::RedirectingFileSystem::getCurrentWorkingDirectory
llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const override
Get the working directory of this file system.
Definition: VirtualFileSystem.cpp:1319
llvm::vfs::RedirectingFileSystem::RemapEntry::getUseName
NameKind getUseName() const
Definition: VirtualFileSystem.h:815
Optional.h
llvm::vfs::YAMLVFSWriter::YAMLVFSWriter
YAMLVFSWriter()=default
llvm::vfs::FileSystem::PrintType::RecursiveContents
@ RecursiveContents
llvm::vfs::detail::DirIterImpl::CurrentEntry
directory_entry CurrentEntry
Definition: VirtualFileSystem.h:175
FileSystem.h
llvm::vfs::RedirectingFileSystem::RemapEntry::useExternalName
bool useExternalName(bool GlobalUseExternalName) const
Whether to use the external path as the name for this file or directory.
Definition: VirtualFileSystem.h:810
llvm::vfs::RedirectingFileSystem::DirectoryRemapEntry::classof
static bool classof(const Entry *E)
Definition: VirtualFileSystem.h:838
llvm::vfs::detail::NewInMemoryNodeInfo::Name
StringRef Name
Definition: VirtualFileSystem.h:471
llvm::vfs::ProxyFileSystem::dir_begin
directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override
Get a directory_iterator for Dir.
Definition: VirtualFileSystem.h:436
llvm::vfs::createPhysicalFileSystem
std::unique_ptr< FileSystem > createPhysicalFileSystem()
Create an vfs::FileSystem for the 'real' file system, as seen by the operating system.
Definition: VirtualFileSystem.cpp:381
llvm::vfs::InMemoryFileSystem::getCurrentWorkingDirectory
llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const override
Get the working directory of this file system.
Definition: VirtualFileSystem.h:593
llvm::vfs::RedirectingFileSystem::LookupResult::E
Entry * E
The entry the looked-up path corresponds to.
Definition: VirtualFileSystem.h:855
llvm::vfs::RedirectingFileSystem::FileEntry::FileEntry
FileEntry(StringRef Name, StringRef ExternalContentsPath, NameKind UseName)
Definition: VirtualFileSystem.h:846
llvm::vfs::InMemoryFileSystem::dir_begin
directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override
Get a directory_iterator for Dir.
Definition: VirtualFileSystem.cpp:1122
llvm::vfs::OverlayFileSystem::overlays_range
const_range overlays_range() const
Definition: VirtualFileSystem.h:414
StringRef.h
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::vfs::recursive_directory_iterator::recursive_directory_iterator
recursive_directory_iterator()=default
Construct an 'end' iterator.
llvm::vfs::RedirectingFileSystem::DirectoryEntry::contents_begin
iterator contents_begin()
Definition: VirtualFileSystem.h:788
llvm::vfs::RedirectingFileSystem::setFallthrough
void setFallthrough(bool Fallthrough)
Sets the redirection kind to Fallthrough if true or RedirectOnly otherwise.
Definition: VirtualFileSystem.cpp:1493
llvm::vfs::FileSystem::printImpl
virtual void printImpl(raw_ostream &OS, PrintType Type, unsigned IndentLevel) const
Definition: VirtualFileSystem.h:333
llvm::vfs::ProxyFileSystem::getUnderlyingFS
FileSystem & getUnderlyingFS()
Definition: VirtualFileSystem.h:454
llvm::vfs::RedirectingFileSystem::DirectoryRemapEntry
A directory in the vfs that maps to a directory in the external file system.
Definition: VirtualFileSystem.h:832
llvm::vfs::directory_iterator::operator!=
bool operator!=(const directory_iterator &RHS) const
Definition: VirtualFileSystem.h:213
llvm::vfs::ProxyFileSystem::getRealPath
std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output) const override
Gets real path of Path e.g.
Definition: VirtualFileSystem.h:445
llvm::vfs::RedirectingFileSystem::create
static std::unique_ptr< RedirectingFileSystem > create(std::unique_ptr< MemoryBuffer > Buffer, SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath, void *DiagContext, IntrusiveRefCntPtr< FileSystem > ExternalFS)
Parses Buffer, which is expected to be in YAML format and returns a virtual file system representing ...
Definition: VirtualFileSystem.cpp:2076
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:145
llvm::SmallVector< IntrusiveRefCntPtr< FileSystem >, 1 >
llvm::vfs::Status::IsVFSMapped
bool IsVFSMapped
Definition: VirtualFileSystem.h:60
Path.h
llvm::vfs::InMemoryFileSystem::useNormalizedPaths
bool useNormalizedPaths() const
Return true if this file system normalizes . and .. in paths.
Definition: VirtualFileSystem.h:586
llvm::vfs::RedirectingFileSystem::NK_External
@ NK_External
Definition: VirtualFileSystem.h:733
llvm::vfs::InMemoryFileSystem::InMemoryFileSystem
InMemoryFileSystem(bool UseNormalizedPaths=true)
Definition: VirtualFileSystem.cpp:801
Content
T Content
Definition: ELFObjHandler.cpp:88
llvm::vfs::detail::DirIterImpl
An interface for virtual file systems to provide an iterator over the (non-recursive) contents of a d...
Definition: VirtualFileSystem.h:168
llvm::vfs::YAMLVFSEntry::VPath
std::string VPath
Definition: VirtualFileSystem.h:628
llvm::vfs::detail::DirIterImpl::~DirIterImpl
virtual ~DirIterImpl()
llvm::vfs::InMemoryFileSystem::getRealPath
std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output) const override
Canonicalizes Path by combining with the current working directory and normalizing the path (e....
Definition: VirtualFileSystem.cpp:1156
llvm::vfs::detail::NewInMemoryNodeInfo
Definition: VirtualFileSystem.h:468
Errc.h
llvm::vfs::RedirectingFileSystem::Entry::getName
StringRef getName() const
Definition: VirtualFileSystem.h:758
llvm::vfs::FileSystem::status
virtual llvm::ErrorOr< Status > status(const Twine &Path)=0
Get the status of the entry at Path, if one exists.
llvm::vfs::FileSystem::setCurrentWorkingDirectory
virtual std::error_code setCurrentWorkingDirectory(const Twine &Path)=0
Set the working directory.
llvm::vfs::RedirectingFileSystem::FileEntry
A file in the vfs that maps to a file in the external file system.
Definition: VirtualFileSystem.h:844
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::vfs::OverlayFileSystem::overlays_rend
reverse_iterator overlays_rend()
Get an iterator pointing one-past the most recently added file system.
Definition: VirtualFileSystem.h:410
llvm::vfs::directory_iterator
An input iterator over the entries in a virtual path, similar to llvm::sys::fs::directory_iterator.
Definition: VirtualFileSystem.h:182
llvm::reverse
auto reverse(ContainerTy &&C, std::enable_if_t< has_rbegin< ContainerTy >::value > *=nullptr)
Definition: STLExtras.h:380
llvm::vfs::OverlayFileSystem::getCurrentWorkingDirectory
llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const override
Get the working directory of this file system.
Definition: VirtualFileSystem.cpp:452
T1
#define T1
Definition: Mips16ISelLowering.cpp:340
llvm::vfs::OverlayFileSystem::overlays_rbegin
const_reverse_iterator overlays_rbegin() const
Definition: VirtualFileSystem.h:407
llvm::vfs::ProxyFileSystem::isLocal
std::error_code isLocal(const Twine &Path, bool &Result) override
Is the file mounted on a local filesystem?
Definition: VirtualFileSystem.h:449
llvm::vfs::detail::NamedNodeOrError::NamedNodeOrError
NamedNodeOrError(llvm::SmallString< 128 > Name, const detail::InMemoryNode *Node)
Definition: VirtualFileSystem.h:487
llvm::Optional< uint32_t >
llvm::vfs::Status::getSize
uint64_t getSize() const
Definition: VirtualFileSystem.h:98
llvm::vfs::recursive_directory_iterator::level
int level() const
Gets the current level. Starting path is at level 0.
Definition: VirtualFileSystem.h:258
llvm::vfs::detail::NewInMemoryNodeInfo::Perms
llvm::sys::fs::perms Perms
Definition: VirtualFileSystem.h:477
llvm::vfs::RedirectingFileSystem::EK_Directory
@ EK_Directory
Definition: VirtualFileSystem.h:732
llvm::vfs::FileSystem::PrintType::Contents
@ Contents
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::vfs::Status
The result of a status operation.
Definition: VirtualFileSystem.h:48
IntrusiveRefCntPtr.h
llvm::vfs::detail::NamedNodeOrError::NamedNodeOrError
NamedNodeOrError(llvm::errc EC)
Definition: VirtualFileSystem.h:491
llvm::vfs::detail::NewInMemoryNodeInfo::DirUID
llvm::sys::fs::UniqueID DirUID
Definition: VirtualFileSystem.h:469
llvm::vfs::RedirectingFileSystem::openFileForRead
ErrorOr< std::unique_ptr< File > > openFileForRead(const Twine &Path) override
Get a File object for the file at Path, if one exists.
Definition: VirtualFileSystem.cpp:2384
llvm::vfs::detail::NamedNodeOrError::NamedNodeOrError
NamedNodeOrError(std::error_code EC)
Definition: VirtualFileSystem.h:490
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::vfs::OverlayFileSystem::getRealPath
std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output) const override
Gets real path of Path e.g.
Definition: VirtualFileSystem.cpp:473
llvm::vfs::detail::NewInMemoryNodeInfo::User
uint32_t User
Definition: VirtualFileSystem.h:474
llvm::vfs::RedirectingFileSystem
A virtual file system parsed from a YAML file.
Definition: VirtualFileSystem.h:730
llvm::vfs::RedirectingFileSystem::Entry::Entry
Entry(EntryKind K, StringRef Name)
Definition: VirtualFileSystem.h:755
llvm::vfs::RedirectingFileSystem::isLocal
std::error_code isLocal(const Twine &Path, bool &Result) override
Is the file mounted on a local filesystem?
Definition: VirtualFileSystem.cpp:1337
llvm::vfs::FileSystem::isLocal
virtual std::error_code isLocal(const Twine &Path, bool &Result)
Is the file mounted on a local filesystem?
Definition: VirtualFileSystem.cpp:145
llvm::sys::TimePoint
std::chrono::time_point< std::chrono::system_clock, D > TimePoint
A time point on the system clock.
Definition: Chrono.h:34
llvm::vfs::OverlayFileSystem::overlays_end
iterator overlays_end()
Get an iterator pointing one-past the least recently added file system.
Definition: VirtualFileSystem.h:402
Chrono.h
llvm::vfs::OverlayFileSystem::iterator
FileSystemList::reverse_iterator iterator
Definition: VirtualFileSystem.h:390
llvm::vfs::OverlayFileSystem::printImpl
void printImpl(raw_ostream &OS, PrintType Type, unsigned IndentLevel) const override
Definition: VirtualFileSystem.cpp:481
Mappings
Inject TLI Mappings
Definition: InjectTLIMappings.cpp:171
llvm::vfs::directory_entry::directory_entry
directory_entry(std::string Path, llvm::sys::fs::file_type Type)
Definition: VirtualFileSystem.h:157
llvm::vfs::FileSystem::dump
LLVM_DUMP_METHOD void dump() const
Definition: VirtualFileSystem.cpp:155
llvm::vfs::Status::getPermissions
llvm::sys::fs::perms getPermissions() const
Definition: VirtualFileSystem.h:93
llvm::vfs::OverlayFileSystem::status
llvm::ErrorOr< Status > status(const Twine &Path) override
Get the status of the entry at Path, if one exists.
Definition: VirtualFileSystem.cpp:430
llvm::vfs::RedirectingFileSystem::getRealPath
std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output) const override
Gets real path of Path e.g.
Definition: VirtualFileSystem.cpp:2449
llvm::orc::tpctypes::LookupResult
std::vector< JITTargetAddress > LookupResult
Definition: TargetProcessControlTypes.h:119
llvm::vfs::Status::copyWithNewName
static Status copyWithNewName(const Status &In, const Twine &NewName)
Get a copy of a Status with a different name.
Definition: VirtualFileSystem.cpp:81
llvm::vfs::recursive_directory_iterator::operator==
bool operator==(const recursive_directory_iterator &Other) const
Definition: VirtualFileSystem.h:250
llvm::vfs::detail::RecDirIterState::HasNoPushRequest
bool HasNoPushRequest
Definition: VirtualFileSystem.h:225
llvm::vfs::YAMLVFSWriter
Definition: VirtualFileSystem.h:1017
llvm::vfs::RedirectingFileSystem::RemapEntry::getExternalContentsPath
StringRef getExternalContentsPath() const
Definition: VirtualFileSystem.h:807
llvm::vfs::RedirectingFileSystem::DirectoryEntry::DirectoryEntry
DirectoryEntry(StringRef Name, std::vector< std::unique_ptr< Entry >> Contents, Status S)
Constructs a directory entry with explicitly specified contents.
Definition: VirtualFileSystem.h:769
llvm::vfs::FileSystem::getBufferForFile
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(const Twine &Name, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false)
This is a convenience method that opens a file, gets its content and then closes the file.
Definition: VirtualFileSystem.cpp:119
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::vfs::detail::NamedNodeOrError::operator*
const detail::InMemoryNode * operator*() const
Definition: VirtualFileSystem.h:497
llvm::User
Definition: User.h:44
llvm::vfs::collectVFSFromYAML
void collectVFSFromYAML(std::unique_ptr< llvm::MemoryBuffer > Buffer, llvm::SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath, SmallVectorImpl< YAMLVFSEntry > &CollectedEntries, void *DiagContext=nullptr, IntrusiveRefCntPtr< FileSystem > ExternalFS=getRealFileSystem())
Collect all pairs of <virtual path, real path> entries from the YAMLFilePath.
llvm::vfs::detail::NewInMemoryNodeInfo::Buffer
std::unique_ptr< llvm::MemoryBuffer > Buffer
Definition: VirtualFileSystem.h:473
llvm::vfs::directory_iterator::increment
directory_iterator & increment(std::error_code &EC)
Equivalent to operator++, with an error code.
Definition: VirtualFileSystem.h:197
llvm::sys::fs::file_type::status_error
@ status_error
llvm::vfs::OverlayFileSystem::overlays_begin
iterator overlays_begin()
Get an iterator pointing to the most recently added file system.
Definition: VirtualFileSystem.h:398
llvm::vfs::FileSystem::openFileForRead
virtual llvm::ErrorOr< std::unique_ptr< File > > openFileForRead(const Twine &Path)=0
Get a File object for the file at Path, if one exists.
llvm::vfs::detail::DirIterImpl::increment
virtual std::error_code increment()=0
Sets CurrentEntry to the next entry in the directory on success, to directory_entry() at end,...
llvm::vfs::detail::NamedNodeOrError::getError
std::error_code getError() const
Definition: VirtualFileSystem.h:496
llvm::vfs::RedirectingFileSystem::LookupResult::getExternalRedirect
Optional< StringRef > getExternalRedirect() const
If the found Entry maps the the input path to a path in the external file system (i....
Definition: VirtualFileSystem.h:870
llvm::vfs::ProxyFileSystem::setCurrentWorkingDirectory
std::error_code setCurrentWorkingDirectory(const Twine &Path) override
Set the working directory.
Definition: VirtualFileSystem.h:442
llvm::vfs::InMemoryFileSystem::~InMemoryFileSystem
~InMemoryFileSystem() override
llvm::vfs::OverlayFileSystem::overlays_rend
const_reverse_iterator overlays_rend() const
Definition: VirtualFileSystem.h:411
llvm::ThreadSafeRefCountedBase
A thread-safe version of RefCountedBase.
Definition: IntrusiveRefCntPtr.h:106
llvm::vfs::RedirectingFileSystem::DirectoryEntry::addContent
void addContent(std::unique_ptr< Entry > Content)
Definition: VirtualFileSystem.h:780
llvm::vfs::directory_entry::path
llvm::StringRef path() const
Definition: VirtualFileSystem.h:160
llvm::vfs::RedirectingFileSystem::Entry::getKind
EntryKind getKind() const
Definition: VirtualFileSystem.h:759
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::vfs::OverlayFileSystem::overlays_rbegin
reverse_iterator overlays_rbegin()
Get an iterator pointing to the least recently added file system.
Definition: VirtualFileSystem.h:406
llvm::vfs::RedirectingFileSystem::RemapEntry::RemapEntry
RemapEntry(EntryKind K, StringRef Name, StringRef ExternalContentsPath, NameKind UseName)
Definition: VirtualFileSystem.h:801
llvm::vfs::FileSystem::exists
bool exists(const Twine &Path)
Check whether a file exists. Provided for convenience.
Definition: VirtualFileSystem.cpp:149
STLFunctionalExtras.h
DebugLocVerifyLevel::None
@ None
llvm::vfs::getVFSFromYAML
std::unique_ptr< FileSystem > getVFSFromYAML(std::unique_ptr< llvm::MemoryBuffer > Buffer, llvm::SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath, void *DiagContext=nullptr, IntrusiveRefCntPtr< FileSystem > ExternalFS=getRealFileSystem())
Gets a FileSystem for a virtual file system described in YAML format.
llvm::sys::fs::file_type
file_type
An enumeration for the file system's view of the type.
Definition: FileSystem.h:66
llvm::vfs::RedirectingFileSystem::DirectoryEntry::iterator
decltype(Contents)::iterator iterator
Definition: VirtualFileSystem.h:786
llvm::vfs::directory_entry
A member of a directory, yielded by a directory_iterator.
Definition: VirtualFileSystem.h:151
llvm::StringRef::str
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:249
llvm::None
const NoneType None
Definition: None.h:24
llvm::vfs::RedirectingFileSystem::RemapEntry::classof
static bool classof(const Entry *E)
Definition: VirtualFileSystem.h:817
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
SourceMgr.h
llvm::vfs::FileSystem::PrintType::Summary
@ Summary
llvm::vfs::detail::InMemoryNode
The in memory file system is a tree of Nodes.
Definition: VirtualFileSystem.cpp:602
llvm::StringRef::equals
LLVM_NODISCARD bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
Definition: StringRef.h:187
llvm::vfs::recursive_directory_iterator::no_push
void no_push()
Definition: VirtualFileSystem.h:264
llvm::vfs::InMemoryFileSystem::MaxSymlinkDepth
static constexpr size_t MaxSymlinkDepth
Arbitrary max depth to search through symlinks.
Definition: VirtualFileSystem.h:560
llvm::SmallString< 128 >
llvm::vfs::RedirectingFileSystem::getExternalContentsPrefixDir
StringRef getExternalContentsPrefixDir() const
Definition: VirtualFileSystem.cpp:1489
llvm::vfs::File::getName
virtual llvm::ErrorOr< std::string > getName()
Get the name of the file.
Definition: VirtualFileSystem.h:125
llvm::vfs::YAMLVFSEntry::IsDirectory
bool IsDirectory
Definition: VirtualFileSystem.h:630
llvm::sys::path::is_style_posix
constexpr bool is_style_posix(Style S)
Check if S uses POSIX path rules.
Definition: Path.h:36
llvm::vfs::Status::isOther
bool isOther() const
Definition: VirtualFileSystem.cpp:102
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::tgtok::In
@ In
Definition: TGLexer.h:51
llvm::sys::fs::file_type::type_unknown
@ type_unknown
llvm::vfs::RedirectingFileSystem::EntryKind
EntryKind
Definition: VirtualFileSystem.h:732
llvm::sys::fs::UniqueID
Definition: UniqueID.h:26
llvm::sys::fs::file_status
Represents the result of a call to sys::fs::status().
Definition: FileSystem.h:226
llvm::vfs::Status::getName
StringRef getName() const
Returns the name that should be used for this file or directory.
Definition: VirtualFileSystem.h:88
llvm::vfs::getRealFileSystem
IntrusiveRefCntPtr< FileSystem > getRealFileSystem()
Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.
Definition: VirtualFileSystem.cpp:376
llvm::vfs::FileSystem::getCurrentWorkingDirectory
virtual llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const =0
Get the working directory of this file system.
llvm::vfs::FileSystem::printIndent
void printIndent(raw_ostream &OS, unsigned IndentLevel) const
Definition: VirtualFileSystem.h:339
llvm::vfs::Status::getUser
uint32_t getUser() const
Definition: VirtualFileSystem.h:96
llvm::StringRef::equals_insensitive
LLVM_NODISCARD bool equals_insensitive(StringRef RHS) const
Check for string equality, ignoring case.
Definition: StringRef.h:194
llvm::vfs::YAMLVFSEntry
Definition: VirtualFileSystem.h:623
llvm::vfs::ProxyFileSystem::status
llvm::ErrorOr< Status > status(const Twine &Path) override
Get the status of the entry at Path, if one exists.
Definition: VirtualFileSystem.h:429
llvm::vfs::recursive_directory_iterator::increment
recursive_directory_iterator & increment(std::error_code &EC)
Equivalent to operator++, with an error code.
Definition: VirtualFileSystem.cpp:2769
llvm::vfs::OverlayFileSystem::const_reverse_iterator
FileSystemList::const_iterator const_reverse_iterator
Definition: VirtualFileSystem.h:393
llvm::vfs::RedirectingFileSystem::NameKind
NameKind
Definition: VirtualFileSystem.h:733
uint64_t
llvm::vfs::Status::copyWithNewSize
static Status copyWithNewSize(const Status &In, uint64_t NewSize)
Get a copy of a Status with a different size.
Definition: VirtualFileSystem.cpp:75
llvm::vfs::File::setPath
virtual void setPath(const Twine &Path)
Definition: VirtualFileSystem.h:146
llvm::vfs::RedirectingFileSystem::RemapEntry
A file or directory in the vfs that is mapped to a file or directory in the external filesystem.
Definition: VirtualFileSystem.h:796
llvm::vfs::RedirectingFileSystem::DirectoryEntry::DirectoryEntry
DirectoryEntry(StringRef Name, Status S)
Constructs an empty directory entry.
Definition: VirtualFileSystem.h:775
llvm::vfs::File::getWithPath
static ErrorOr< std::unique_ptr< File > > getWithPath(ErrorOr< std::unique_ptr< File >> Result, const Twine &P)
Definition: VirtualFileSystem.cpp:2370
llvm::vfs::detail::NewInMemoryNodeInfo::Type
llvm::sys::fs::file_type Type
Definition: VirtualFileSystem.h:476
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::vfs::RedirectingFileSystem::RedirectKind::Fallback
@ Fallback
Lookup the provided path first and if that fails, "fallback" to a lookup of the redirected path.
llvm::vfs::Status::isDirectory
bool isDirectory() const
Definition: VirtualFileSystem.cpp:98
llvm::vfs::RedirectingFileSystem::DirectoryEntry::contents_end
iterator contents_end()
Definition: VirtualFileSystem.h:789
llvm::vfs::InMemoryFileSystem::toString
std::string toString() const
Definition: VirtualFileSystem.cpp:811
ErrorOr.h
llvm::SourceMgr::DiagHandlerTy
void(*)(const SMDiagnostic &, void *Context) DiagHandlerTy
Clients that want to handle their own diagnostics in a custom way can register a function pointer+con...
Definition: SourceMgr.h:43
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::vfs::OverlayFileSystem::overlays_range
range overlays_range()
Definition: VirtualFileSystem.h:413
llvm::vfs::RedirectingFileSystem::dir_begin
directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override
Get a directory_iterator for Dir.
Definition: VirtualFileSystem.cpp:1385
llvm::vfs::detail::NamedNodeOrError
Definition: VirtualFileSystem.h:482
llvm::sys::path::Style::native
@ native
llvm::vfs::RedirectingFileSystem::RedirectKind::Fallthrough
@ Fallthrough
Lookup the redirected path first (ie.
llvm::SmallVectorImpl< IntrusiveRefCntPtr< FileSystem > >::const_iterator
typename SuperClass::const_iterator const_iterator
Definition: SmallVector.h:559
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::vfs::RedirectingFileSystem::setExternalContentsPrefixDir
void setExternalContentsPrefixDir(StringRef PrefixDir)
Definition: VirtualFileSystem.cpp:1485
llvm::vfs::YAMLVFSEntry::YAMLVFSEntry
YAMLVFSEntry(T1 &&VPath, T2 &&RPath, bool IsDirectory=false)
Definition: VirtualFileSystem.h:625
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1675
llvm::X86AS::FS
@ FS
Definition: X86.h:192
llvm::vfs::ProxyFileSystem::openFileForRead
llvm::ErrorOr< std::unique_ptr< File > > openFileForRead(const Twine &Path) override
Get a File object for the file at Path, if one exists.
Definition: VirtualFileSystem.h:433
llvm::vfs::OverlayFileSystem::overlays_end
const_iterator overlays_end() const
Definition: VirtualFileSystem.h:403
llvm::vfs::RedirectingFileSystemParser
A helper class to hold the common YAML parsing state.
Definition: VirtualFileSystem.cpp:1567
llvm::vfs::InMemoryFileSystem::addHardLink
bool addHardLink(const Twine &NewLink, const Twine &Target)
Add a hard link to a file.
Definition: VirtualFileSystem.cpp:1004
llvm::vfs::InMemoryFileSystem::status
llvm::ErrorOr< Status > status(const Twine &Path) override
Get the status of the entry at Path, if one exists.
Definition: VirtualFileSystem.cpp:1045
llvm::vfs::directory_iterator::directory_iterator
directory_iterator()=default
Construct an 'end' iterator.
llvm::vfs::detail::NewInMemoryNodeInfo::Group
uint32_t Group
Definition: VirtualFileSystem.h:475
llvm::vfs::getNextVirtualUniqueID
llvm::sys::fs::UniqueID getNextVirtualUniqueID()
Get a globally unique ID for a virtual file or directory.
Definition: VirtualFileSystem.cpp:2563
llvm::vfs::YAMLVFSWriter::setCaseSensitivity
void setCaseSensitivity(bool CaseSensitive)
Definition: VirtualFileSystem.h:1032
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
None.h
DiagHandler
static void DiagHandler(const SMDiagnostic &Diag, void *Context)
Definition: TextStub.cpp:1094
llvm::vfs::RedirectingFileSystem::getRoots
std::vector< llvm::StringRef > getRoots() const
Definition: VirtualFileSystem.cpp:1506
llvm::vfs::RedirectingFileSystem::DirectoryEntry
A directory in the vfs with explicitly specified contents.
Definition: VirtualFileSystem.h:763
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
uint32_t
llvm::vfs::detail::NamedNodeOrError::getName
StringRef getName() const
Definition: VirtualFileSystem.h:493
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::vfs::InMemoryFileSystem::printImpl
void printImpl(raw_ostream &OS, PrintType Type, unsigned IndentLevel) const override
Definition: VirtualFileSystem.cpp:1173
llvm::vfs::Status::getUniqueID
llvm::sys::fs::UniqueID getUniqueID() const
Definition: VirtualFileSystem.h:95
llvm::vfs::OverlayFileSystem
A file system that allows overlaying one AbstractFileSystem on top of another.
Definition: VirtualFileSystem.h:367
Node
Definition: ItaniumDemangle.h:155
llvm::AMDGPU::HSAMD::Kernel::Arg::Key::IsVolatile
constexpr char IsVolatile[]
Key for Kernel::Arg::Metadata::mIsVolatile.
Definition: AMDGPUMetadata.h:199
llvm::vfs::detail::NewInMemoryNodeInfo::Path
StringRef Path
Definition: VirtualFileSystem.h:470
llvm::vfs::YAMLVFSWriter::write
void write(llvm::raw_ostream &OS)
Definition: VirtualFileSystem.cpp:2749
LLVM_FALLTHROUGH
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Definition: Compiler.h:280
llvm::sys::path::const_iterator
Path iterator.
Definition: Path.h:73
llvm::vfs::File
Represents an open file.
Definition: VirtualFileSystem.h:114
llvm::vfs::Status::ExposesExternalVFSPath
bool ExposesExternalVFSPath
Whether this entity has an external path different from the virtual path, and the external path is ex...
Definition: VirtualFileSystem.h:71
llvm::vfs::directory_entry::type
llvm::sys::fs::file_type type() const
Definition: VirtualFileSystem.h:161
llvm::vfs::recursive_directory_iterator::operator!=
bool operator!=(const recursive_directory_iterator &RHS) const
Definition: VirtualFileSystem.h:253
llvm::vfs::YAMLVFSWriter::setOverlayDir
void setOverlayDir(StringRef OverlayDirectory)
Definition: VirtualFileSystem.h:1038
llvm::errc
errc
Definition: Errc.h:35
llvm::vfs::directory_iterator::directory_iterator
directory_iterator(std::shared_ptr< detail::DirIterImpl > I)
Definition: VirtualFileSystem.h:186
llvm::vfs::Status::isSymlink
bool isSymlink() const
Definition: VirtualFileSystem.cpp:106
llvm::vfs::InMemoryFileSystem::addFileNoOwn
bool addFileNoOwn(const Twine &Path, time_t ModificationTime, const llvm::MemoryBufferRef &Buffer, Optional< uint32_t > User=None, Optional< uint32_t > Group=None, Optional< llvm::sys::fs::file_type > Type=None, Optional< llvm::sys::fs::perms > Perms=None)
Add a buffer to the VFS with a path.
Definition: VirtualFileSystem.cpp:910
llvm::vfs::RedirectingFileSystem::DirectoryEntry::classof
static bool classof(const Entry *E)
Definition: VirtualFileSystem.h:791
llvm::vfs::recursive_directory_iterator
An input iterator over the recursive contents of a virtual path, similar to llvm::sys::fs::recursive_...
Definition: VirtualFileSystem.h:232
llvm::vfs::OverlayFileSystem::reverse_iterator
FileSystemList::iterator reverse_iterator
Definition: VirtualFileSystem.h:392
llvm::vfs::YAMLVFSWriter::setUseExternalNames
void setUseExternalNames(bool UseExtNames)
Definition: VirtualFileSystem.h:1036
llvm::vfs::File::close
virtual std::error_code close()=0
Closes the file.
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::vfs::FileSystem::print
void print(raw_ostream &OS, PrintType Type=PrintType::Contents, unsigned IndentLevel=0) const
Definition: VirtualFileSystem.h:323
llvm::vfs::RedirectingFileSystem::DirectoryRemapEntry::DirectoryRemapEntry
DirectoryRemapEntry(StringRef Name, StringRef ExternalContentsPath, NameKind UseName)
Definition: VirtualFileSystem.h:834
llvm::vfs::OverlayFileSystem::const_iterator
FileSystemList::const_reverse_iterator const_iterator
Definition: VirtualFileSystem.h:391
llvm::vfs::RedirectingFileSystem::EK_DirectoryRemap
@ EK_DirectoryRemap
Definition: VirtualFileSystem.h:732
llvm::vfs::FileSystem
The virtual file system interface.
Definition: VirtualFileSystem.h:268
llvm::vfs::OverlayFileSystem::overlays_begin
const_iterator overlays_begin() const
Definition: VirtualFileSystem.h:399
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
std
Definition: BitVector.h:851
llvm::vfs::RedirectingFileSystem::DirectoryEntry::getStatus
Status getStatus()
Definition: VirtualFileSystem.h:778
llvm::vfs::InMemoryFileSystem
An in-memory file system.
Definition: VirtualFileSystem.h:503
llvm::vfs::directory_iterator::operator->
const directory_entry * operator->() const
Definition: VirtualFileSystem.h:206
llvm::vfs::InMemoryFileSystem::DirIterator
Adaptor from InMemoryDir::iterator to directory_iterator.
Definition: VirtualFileSystem.cpp:1069
llvm::vfs::RedirectingFileSystem::LookupResult::LookupResult
LookupResult(Entry *E, sys::path::const_iterator Start, sys::path::const_iterator End)
Definition: VirtualFileSystem.cpp:2171
llvm::vfs::RedirectingFileSystem::printImpl
void printImpl(raw_ostream &OS, PrintType Type, unsigned IndentLevel) const override
Definition: VirtualFileSystem.cpp:1513
llvm::vfs::directory_entry::directory_entry
directory_entry()=default
llvm::vfs::ProxyFileSystem::getCurrentWorkingDirectory
llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const override
Get the working directory of this file system.
Definition: VirtualFileSystem.h:439
llvm::vfs::recursive_directory_iterator::operator->
const directory_entry * operator->() const
Definition: VirtualFileSystem.h:248
llvm::vfs::RedirectingFileSystem::lookupPath
ErrorOr< LookupResult > lookupPath(StringRef Path) const
Looks up Path in Roots and returns a LookupResult giving the matched entry and, if the entry was a Fi...
Definition: VirtualFileSystem.cpp:2201
llvm::vfs::OverlayFileSystem::dir_begin
directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override
Get a directory_iterator for Dir.
Definition: VirtualFileSystem.cpp:577
llvm::vfs::InMemoryFileSystem::addSymbolicLink
bool addSymbolicLink(const Twine &NewLink, const Twine &Target, time_t ModificationTime, Optional< uint32_t > User=None, Optional< uint32_t > Group=None, Optional< llvm::sys::fs::perms > Perms=None)
Add a symbolic link.
Definition: VirtualFileSystem.cpp:1023
llvm::vfs::RedirectingFileSystem::NK_Virtual
@ NK_Virtual
Definition: VirtualFileSystem.h:733
llvm::vfs::directory_iterator::operator*
const directory_entry & operator*() const
Definition: VirtualFileSystem.h:205
llvm::vfs::RedirectingFileSystem::NK_NotSet
@ NK_NotSet
Definition: VirtualFileSystem.h:733
llvm::vfs::File::status
virtual llvm::ErrorOr< Status > status()=0
Get the status of the file.
llvm::vfs::YAMLVFSWriter::addFileMapping
void addFileMapping(StringRef VirtualPath, StringRef RealPath)
Definition: VirtualFileSystem.cpp:2579
llvm::vfs::RedirectingFileSystem::setRedirection
void setRedirection(RedirectingFileSystem::RedirectKind Kind)
Definition: VirtualFileSystem.cpp:1501
llvm::vfs::detail::RecDirIterState::Stack
std::stack< directory_iterator, std::vector< directory_iterator > > Stack
Definition: VirtualFileSystem.h:224
llvm::vfs::OverlayFileSystem::setCurrentWorkingDirectory
std::error_code setCurrentWorkingDirectory(const Twine &Path) override
Set the working directory.
Definition: VirtualFileSystem.cpp:458
llvm::vfs::ProxyFileSystem
By default, this delegates all calls to the underlying file system.
Definition: VirtualFileSystem.h:424
llvm::vfs::Status::exists
bool exists() const
Definition: VirtualFileSystem.cpp:110
llvm::vfs::InMemoryFileSystem::isLocal
std::error_code isLocal(const Twine &Path, bool &Result) override
Is the file mounted on a local filesystem?
Definition: VirtualFileSystem.cpp:1168
llvm::vfs::File::~File
virtual ~File()
Destroy the file after closing it (if open).
llvm::vfs::OverlayFileSystem::pushOverlay
void pushOverlay(IntrusiveRefCntPtr< FileSystem > FS)
Pushes a file system on top of the stack.
Definition: VirtualFileSystem.cpp:423
llvm::vfs::Status::getLastModificationTime
llvm::sys::TimePoint getLastModificationTime() const
Definition: VirtualFileSystem.h:94
llvm::vfs::OverlayFileSystem::openFileForRead
llvm::ErrorOr< std::unique_ptr< File > > openFileForRead(const Twine &Path) override
Get a File object for the file at Path, if one exists.
Definition: VirtualFileSystem.cpp:441
llvm::sys::fs::perms
perms
Definition: FileSystem.h:86
SmallVector.h
llvm::vfs::YAMLVFSWriter::getMappings
const std::vector< YAMLVFSEntry > & getMappings() const
Definition: VirtualFileSystem.h:1043
llvm::vfs::RedirectingFileSystem::FileEntry::classof
static bool classof(const Entry *E)
Definition: VirtualFileSystem.h:849
llvm::vfs::YAMLVFSEntry::RPath
std::string RPath
Definition: VirtualFileSystem.h:629
llvm::vfs::RedirectingFileSystem::printEntry
void printEntry(raw_ostream &OS, Entry *E, unsigned IndentLevel=0) const
Definition: VirtualFileSystem.cpp:1530
llvm::SmallVectorImpl< IntrusiveRefCntPtr< FileSystem > >::iterator
typename SuperClass::iterator iterator
Definition: SmallVector.h:558
llvm::sys::fs::status
std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
llvm::ErrorOr
Represents either an error or a value T.
Definition: ErrorOr.h:56
llvm::vfs::FileSystem::PrintType
PrintType
Definition: VirtualFileSystem.h:322
llvm::vfs::RedirectingFileSystem::LookupResult
Represents the result of a path lookup into the RedirectingFileSystem.
Definition: VirtualFileSystem.h:853
llvm::vfs::YAMLVFSWriter::addDirectoryMapping
void addDirectoryMapping(StringRef VirtualPath, StringRef RealPath)
Definition: VirtualFileSystem.cpp:2583
llvm::vfs::Status::getType
llvm::sys::fs::file_type getType() const
Definition: VirtualFileSystem.h:92
llvm::vfs::detail::RecDirIterState
Keeps state for the recursive_directory_iterator.
Definition: VirtualFileSystem.h:223
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::vfs::directory_iterator::operator==
bool operator==(const directory_iterator &RHS) const
Definition: VirtualFileSystem.h:208
llvm::vfs::recursive_directory_iterator::operator*
const directory_entry & operator*() const
Definition: VirtualFileSystem.h:247
llvm::vfs::Status::getGroup
uint32_t getGroup() const
Definition: VirtualFileSystem.h:97
llvm::SmallVectorImpl< char >
llvm::vfs::FileSystem::getRealPath
virtual std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output) const
Gets real path of Path e.g.
Definition: VirtualFileSystem.cpp:140
llvm::vfs::FileSystem::makeAbsolute
virtual std::error_code makeAbsolute(SmallVectorImpl< char > &Path) const
Make Path an absolute path.
Definition: VirtualFileSystem.cpp:128
llvm::vfs::detail::NewInMemoryNodeInfo::ModificationTime
time_t ModificationTime
Definition: VirtualFileSystem.h:472
llvm::vfs::ProxyFileSystem::ProxyFileSystem
ProxyFileSystem(IntrusiveRefCntPtr< FileSystem > FS)
Definition: VirtualFileSystem.h:426
From
BlockVerifier::State From
Definition: BlockVerifier.cpp:55
llvm::vfs::RedirectingFileSystem::makeAbsolute
std::error_code makeAbsolute(SmallVectorImpl< char > &Path) const override
Make Path an absolute path.
Definition: VirtualFileSystem.cpp:1348
llvm::vfs::Status::equivalent
bool equivalent(const Status &Other) const
Definition: VirtualFileSystem.cpp:93
llvm::vfs::OverlayFileSystem::isLocal
std::error_code isLocal(const Twine &Path, bool &Result) override
Is the file mounted on a local filesystem?
Definition: VirtualFileSystem.cpp:465
llvm::vfs::InMemoryFileSystem::openFileForRead
llvm::ErrorOr< std::unique_ptr< File > > openFileForRead(const Twine &Path) override
Get a File object for the file at Path, if one exists.
Definition: VirtualFileSystem.cpp:1053
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::vfs::detail::NewInMemoryNodeInfo::makeStatus
Status makeStatus() const
Definition: VirtualFileSystem.cpp:791
llvm::vfs::Status::isStatusKnown
bool isStatusKnown() const
Definition: VirtualFileSystem.cpp:108
llvm::IntrusiveRefCntPtr
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
Definition: IntrusiveRefCntPtr.h:168
llvm::vfs::Status::Status
Status()=default
llvm::sampleprof::Base
@ Base
Definition: Discriminator.h:58
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1236
llvm::vfs::RedirectingFileSystem::Entry
A single file or directory in the VFS.
Definition: VirtualFileSystem.h:750
llvm::vfs::RedirectingFileSystem::RedirectKind::RedirectOnly
@ RedirectOnly
Only lookup the redirected path, do not lookup the originally provided path.
llvm::vfs::RedirectingFileSystem::RedirectKind
RedirectKind
The type of redirection to perform.
Definition: VirtualFileSystem.h:736
llvm::vfs::FileSystem::~FileSystem
virtual ~FileSystem()
llvm::vfs::RedirectingFileSystem::Entry::~Entry
virtual ~Entry()=default
llvm::vfs::OverlayFileSystem::OverlayFileSystem
OverlayFileSystem(IntrusiveRefCntPtr< FileSystem > Base)
Definition: VirtualFileSystem.cpp:419