LLVM: include/llvm/Support/VirtualFileSystem.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_SUPPORT_VIRTUALFILESYSTEM_H

15#define LLVM_SUPPORT_VIRTUALFILESYSTEM_H

16

29#include

30#include

31#include

32#include

33#include

34#include

35#include <system_error>

36#include

37#include

38

39namespace llvm {

40

41class MemoryBuffer;

42class MemoryBufferRef;

43class Twine;

44

45namespace vfs {

46

47

49 std::string Name;

57

58public:

59

60

61

62

63

64

65

66

67

69

76

77

79

82 const Twine &NewName);

83

84

86

87

88

96

97

98

99

107

108};

109

110

112public:

113

114

115

117

118

120

121

125 else

126 return Status.getError();

127 }

128

129

132 bool RequiresNullTerminator = true, bool IsVolatile = false) = 0;

133

134

135 virtual std::error_code close() = 0;

136

137

140

141protected:

142

144};

145

146

147

149 std::string Path;

151

152public:

156

159};

160

162

163

164

167

168

169

171

173};

174

175}

176

177

178

180 std::shared_ptrdetail::DirIterImpl Impl;

181

182public:

185 assert(Impl.get() != nullptr && "requires non-null implementation");

186 if (Impl->CurrentEntry.path().empty())

187 Impl.reset();

188 }

189

190

192

193

195 assert(Impl && "attempting to increment past end");

196 EC = Impl->increment();

197 if (Impl->CurrentEntry.path().empty())

198 Impl.reset();

199 return *this;

200 }

201

204

206 if (Impl && RHS.Impl)

207 return Impl->CurrentEntry.path() == RHS.Impl->CurrentEntry.path();

208 return !Impl && RHS.Impl;

209 }

211 return !(*this == RHS);

212 }

213};

214

215class FileSystem;

216

218

219

221 std::vector<directory_iterator> Stack;

223};

224

225}

226

227

228

231 std::shared_ptrdetail::RecDirIterState

232 State;

233

234public:

236 std::error_code &EC);

237

238

240

241

243

246

248 return State == Other.State;

249 }

251 return !(*this == RHS);

252 }

253

254

256 assert(!State->Stack.empty() &&

257 "Cannot get level without any iteration state");

258 return State->Stack.size() - 1;

259 }

260

261 void no_push() { State->HasNoPushRequest = true; }

262};

263

264

266 public RTTIExtends<FileSystem, RTTIRoot> {

267public:

268 static const char ID;

270

271

273

274

277

278

279

280

281

282

286 }

287

288

289

290

291

294 bool RequiresNullTerminator = true, bool IsVolatile = false,

295 bool IsText = true);

296

297

298

300 std::error_code &EC) = 0;

301

302

303

305

306

308

309

310

311

314

315

316

318

319

320 virtual std::error_code isLocal(const Twine &Path, bool &Result);

321

322

323

324

325

326

327

328

329

330

331

332

334

335

336

338

341 unsigned IndentLevel = 0) const {

343 }

344

348 Callback(*this);

350 }

351

352#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

354#endif

355

356protected:

358 unsigned IndentLevel) const {

360 OS << "FileSystem\n";

361 }

362

364 for (unsigned i = 0; i < IndentLevel; ++i)

365 OS << " ";

366 }

367};

368

369

370

371

372

374

375

376

377

378

380

381

382

383

384

385

386

387

388

389

390

393

394

395

397

398public:

399 static const char ID;

401

402

404

412 std::error_code isLocal(const Twine &Path, bool &Result) override;

415

422

423

426

427

430

431

434

435

438

441

442protected:

444 unsigned IndentLevel) const override;

446};

447

448

449

450

452public:

453 static const char ID;

456

458 return FS->status(Path);

459 }

460 bool exists(const Twine &Path) override { return FS->exists(Path); }

463 return FS->openFileForRead(Path);

464 }

466 return FS->dir_begin(Dir, EC);

467 }

469 return FS->getCurrentWorkingDirectory();

470 }

472 return FS->setCurrentWorkingDirectory(Path);

473 }

476 return FS->getRealPath(Path, Output);

477 }

478 std::error_code isLocal(const Twine &Path, bool &Result) override {

479 return FS->isLocal(Path, Result);

480 }

481

482protected:

485 if (FS) {

486 Callback(*FS);

487 FS->visitChildFileSystems(Callback);

488 }

489 }

490

491private:

493

494 virtual void anchor() override;

495};

496

498

499class InMemoryDirectory;

500class InMemoryNode;

501

507 std::unique_ptrllvm::MemoryBuffer Buffer;

512

514};

515

519

520public:

526

528 explicit operator bool() const { return static_cast<bool>(Value); }

529 operator std::error_code() const { return Value.getError(); }

530 std::error_code getError() const { return Value.getError(); }

532};

533

534}

535

536

538 std::unique_ptrdetail::InMemoryDirectory Root;

539 std::string WorkingDirectory;

540 bool UseNormalizedPaths = true;

541

542public:

543 static const char ID;

544

545private:

548

549

550 bool addFile(const Twine &Path, time_t ModificationTime,

551 std::unique_ptrllvm::MemoryBuffer Buffer,

552 std::optional<uint32_t> User, std::optional<uint32_t> Group,

553 std::optionalllvm::sys::fs::file\_type Type,

554 std::optionalllvm::sys::fs::perms Perms, MakeNodeFn MakeNode);

555

556

557

558

560 size_t SymlinkDepth = 0) const;

561

563

564public:

567

568

569

570

571

572

573

574 bool addFile(const Twine &Path, time_t ModificationTime,

575 std::unique_ptrllvm::MemoryBuffer Buffer,

576 std::optional<uint32_t> User = std::nullopt,

577 std::optional<uint32_t> Group = std::nullopt,

578 std::optionalllvm::sys::fs::file\_type Type = std::nullopt,

579 std::optionalllvm::sys::fs::perms Perms = std::nullopt);

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

596

597

598

600

601

602

603

604 bool

606 time_t ModificationTime,

607 std::optional<uint32_t> User = std::nullopt,

608 std::optional<uint32_t> Group = std::nullopt,

609 std::optionalllvm::sys::fs::perms Perms = std::nullopt);

610

611

612

613

614

615

616

619 std::optional<uint32_t> User = std::nullopt,

620 std::optional<uint32_t> Group = std::nullopt,

621 std::optionalllvm::sys::fs::file\_type Type = std::nullopt,

622 std::optionalllvm::sys::fs::perms Perms = std::nullopt);

623

624 std::string toString() const;

625

626

628

633

635 return WorkingDirectory;

636 }

637

638

639

640

641

642

645 std::error_code isLocal(const Twine &Path, bool &Result) override;

647

648protected:

650 unsigned IndentLevel) const override;

651};

652

653

655

656

657

658std::unique_ptr

661 StringRef YAMLFilePath, void *DiagContext = nullptr,

663

665 template <typename T1, typename T2>

672};

673

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

778 : public RTTIExtends<RedirectingFileSystem, vfs::FileSystem> {

779public:

780 static const char ID;

783

784

786

787

788

790

791

793

794

796 };

797

798

800

802

803

805 };

806

807

810 std::string Name;

811

812 public:

815

818 };

819

820

822 std::vector<std::unique_ptr> Contents;

824

825 public:

826

831

832

835

837

839 Contents.push_back(std::move(Content));

840 }

841

843

845

848

850 };

851

852

853

855 std::string ExternalContentsPath;

857

858 protected:

861 : Entry(K, Name), ExternalContentsPath(ExternalContentsPath),

862 UseName(UseName) {}

863

864 public:

866

867

869 return UseName == NK_NotSet ? GlobalUseExternalName

871 }

872

874

876 switch (E->getKind()) {

878 [[fallthrough]];

880 return true;

882 return false;

883 }

885 }

886 };

887

888

889

891 public:

895

898 }

899 };

900

901

903 public:

906

908 };

909

910

912

914

915

917

918 private:

919

920

921

922 std::optionalstd::string ExternalRedirect;

923

924 public:

927

928

929

930

932 if (isa(E))

933 return StringRef(*ExternalRedirect);

934 if (auto *FE = dyn_cast(E))

935 return FE->getExternalContentsPath();

936 return std::nullopt;

937 }

938

939

940

942 };

943

944private:

947

948

949

950

952

953

954

955

957 const Twine &OriginalPath) const;

958

959

960

961

962

963

964

965

966

967

968

969

970

973

974

975

976

977

978

981 return true;

982 return (lhs == "/" && rhs == "\\") || (lhs == "\\" && rhs == "/");

983 }

984

985

986 std::vector<std::unique_ptr> Roots;

987

988

989 std::string WorkingDirectory;

990

991

993

994

995

996

997

998 std::string OverlayFileDir;

999

1000

1001

1002

1003

1004

1005

1007

1008

1009

1010 bool IsRelativeOverlay = false;

1011

1012

1013

1014 bool UseExternalNames = true;

1015

1016

1017

1018 mutable bool HasBeenUsed = false;

1019

1020

1021 bool UsageTrackingActive = false;

1022

1023

1024

1026

1027

1028

1030

1031

1033

1034

1035

1036

1037

1042

1043

1045 const LookupResult &Result);

1046

1047public:

1048

1049

1050

1052

1053

1054

1055 static std::unique_ptr

1056 create(std::unique_ptr Buffer,

1059

1060

1061 static std::unique_ptr

1062 create(ArrayRef<std::pair<std::string, std::string>> RemappedFiles,

1063 bool UseExternalNames, FileSystem &ExternalFS);

1064

1066 bool exists(const Twine &Path) override;

1068

1071

1073

1075

1076 std::error_code isLocal(const Twine &Path, bool &Result) override;

1077

1079

1081

1083

1085

1086

1087

1089

1091

1092 std::vectorllvm::StringRef getRoots() const;

1093

1096

1098

1100

1101protected:

1103 unsigned IndentLevel) const override;

1105};

1106

1107

1108

1109

1111 std::unique_ptrllvm::MemoryBuffer Buffer,

1114 void *DiagContext = nullptr,

1116

1118 std::vector Mappings;

1119 std::optional IsCaseSensitive;

1120 std::optional IsOverlayRelative;

1121 std::optional UseExternalNames;

1122 std::string OverlayDir;

1123

1124 void addEntry(StringRef VirtualPath, StringRef RealPath, bool IsDirectory);

1125

1126public:

1128

1131

1133 IsCaseSensitive = CaseSensitive;

1134 }

1135

1137

1139 IsOverlayRelative = true;

1140 OverlayDir.assign(OverlayDirectory.str());

1141 }

1142

1143 const std::vector &getMappings() const { return Mappings; }

1144

1146};

1147

1148

1149

1150

1152 : public llvm::RTTIExtends<TracingFileSystem, ProxyFileSystem> {

1153public:

1154 static const char ID;

1155

1162

1165

1169 }

1170

1174 }

1175

1179 }

1180

1185 }

1186

1190 }

1191

1192 std::error_code isLocal(const Twine &Path, bool &Result) override {

1195 }

1196

1197protected:

1199 unsigned IndentLevel) const override;

1200};

1201

1202}

1203}

1204

1205#endif

BlockVerifier::State From

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

#define LLVM_DUMP_METHOD

Mark debug helper function definitions like dump() that should not be stripped from debug builds.

Provides ErrorOr smart pointer.

static void makeAbsolute(SmallVectorImpl< char > &Path)

Make Path absolute.

This file defines the RefCountedBase, ThreadSafeRefCountedBase, and IntrusiveRefCntPtr classes.

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

This file defines the SmallVector class.

static void DiagHandler(const SMDiagnostic &Diag, void *Context)

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

Represents either an error or a value T.

A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...

Inheritance utility for extensible RTTI.

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

reverse_iterator rbegin()

std::reverse_iterator< const_iterator > const_reverse_iterator

std::reverse_iterator< iterator > reverse_iterator

void(*)(const SMDiagnostic &, void *Context) DiagHandlerTy

Clients that want to handle their own diagnostics in a custom way can register a function pointer+con...

StringRef - Represent a constant reference to a string, i.e.

std::string str() const

str - Get the contents as an std::string.

bool equals_insensitive(StringRef RHS) const

Check for string equality, ignoring case.

Target - Wrapper for Target specific information.

A thread-safe version of RefCountedBase.

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

The instances of the Type class are immutable: once they are created, they are never changed.

LLVM Value Representation.

An efficient, type-erasing, non-owning reference to a callable.

A range adaptor for a pair of iterators.

This class implements an extremely fast bulk output stream that can only output to a stream.

Represents the result of a call to sys::fs::status().

The virtual file system interface.

llvm::function_ref< void(FileSystem &)> VisitCallbackTy

virtual llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const =0

Get the working directory of this file system.

virtual bool exists(const Twine &Path)

Check whether Path exists.

virtual llvm::ErrorOr< std::unique_ptr< File > > openFileForReadBinary(const Twine &Path)

Get a File object for the binary file at Path, if one exists.

virtual std::error_code setCurrentWorkingDirectory(const Twine &Path)=0

Set the working directory.

virtual void printImpl(raw_ostream &OS, PrintType Type, unsigned IndentLevel) const

virtual std::error_code makeAbsolute(SmallVectorImpl< char > &Path) const

Make Path an absolute path.

virtual llvm::ErrorOr< std::unique_ptr< File > > openFileForRead(const Twine &Path)=0

Get a File object for the text file at Path, if one exists.

virtual std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output)

Gets real path of Path e.g.

virtual directory_iterator dir_begin(const Twine &Dir, std::error_code &EC)=0

Get a directory_iterator for Dir.

void printIndent(raw_ostream &OS, unsigned IndentLevel) const

LLVM_DUMP_METHOD void dump() const

void print(raw_ostream &OS, PrintType Type=PrintType::Contents, unsigned IndentLevel=0) const

virtual void visitChildFileSystems(VisitCallbackTy Callback)

void visit(VisitCallbackTy Callback)

llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(const Twine &Name, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false, bool IsText=true)

This is a convenience method that opens a file, gets its content and then closes the file.

llvm::ErrorOr< bool > equivalent(const Twine &A, const Twine &B)

virtual std::error_code isLocal(const Twine &Path, bool &Result)

Is the file mounted on a local filesystem?

virtual llvm::ErrorOr< Status > status(const Twine &Path)=0

Get the status of the entry at Path, if one exists.

static ErrorOr< std::unique_ptr< File > > getWithPath(ErrorOr< std::unique_ptr< File > > Result, const Twine &P)

virtual llvm::ErrorOr< Status > status()=0

Get the status of the file.

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.

virtual llvm::ErrorOr< std::string > getName()

Get the name of the file.

virtual void setPath(const Twine &Path)

virtual ~File()

Destroy the file after closing it (if open).

virtual std::error_code close()=0

Closes the file.

Adaptor from InMemoryDir::iterator to directory_iterator.

An in-memory file system.

std::error_code isLocal(const Twine &Path, bool &Result) override

directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override

std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output) override

Canonicalizes Path by combining with the current working directory and normalizing the path (e....

~InMemoryFileSystem() override

static constexpr size_t MaxSymlinkDepth

Arbitrary max depth to search through symlinks.

bool useNormalizedPaths() const

Return true if this file system normalizes . and .. in paths.

void printImpl(raw_ostream &OS, PrintType Type, unsigned IndentLevel) const override

llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const override

bool addHardLink(const Twine &NewLink, const Twine &Target)

Add a hard link to a file.

std::string toString() const

bool addFileNoOwn(const Twine &Path, time_t ModificationTime, const llvm::MemoryBufferRef &Buffer, std::optional< uint32_t > User=std::nullopt, std::optional< uint32_t > Group=std::nullopt, std::optional< llvm::sys::fs::file_type > Type=std::nullopt, std::optional< llvm::sys::fs::perms > Perms=std::nullopt)

Add a buffer to the VFS with a path.

bool addSymbolicLink(const Twine &NewLink, const Twine &Target, time_t ModificationTime, std::optional< uint32_t > User=std::nullopt, std::optional< uint32_t > Group=std::nullopt, std::optional< llvm::sys::fs::perms > Perms=std::nullopt)

Add a symbolic link.

std::error_code setCurrentWorkingDirectory(const Twine &Path) override

llvm::ErrorOr< Status > status(const Twine &Path) override

llvm::ErrorOr< std::unique_ptr< File > > openFileForRead(const Twine &Path) override

A file system that allows overlaying one AbstractFileSystem on top of another.

const_iterator overlays_end() const

const_iterator overlays_begin() const

directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override

reverse_iterator overlays_rbegin()

Get an iterator pointing to the least recently added file system.

const_range overlays_range() const

void visitChildFileSystems(VisitCallbackTy Callback) override

const_reverse_iterator overlays_rend() const

llvm::ErrorOr< std::unique_ptr< File > > openFileForRead(const Twine &Path) override

reverse_iterator overlays_rend()

Get an iterator pointing one-past the most recently added file system.

std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output) override

std::error_code setCurrentWorkingDirectory(const Twine &Path) override

void pushOverlay(IntrusiveRefCntPtr< FileSystem > FS)

Pushes a file system on top of the stack.

FileSystemList::const_reverse_iterator const_iterator

llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const override

iterator overlays_end()

Get an iterator pointing one-past the least recently added file system.

std::error_code isLocal(const Twine &Path, bool &Result) override

bool exists(const Twine &Path) override

llvm::ErrorOr< Status > status(const Twine &Path) override

iterator overlays_begin()

Get an iterator pointing to the most recently added file system.

const_reverse_iterator overlays_rbegin() const

FileSystemList::reverse_iterator iterator

void printImpl(raw_ostream &OS, PrintType Type, unsigned IndentLevel) const override

By default, this delegates all calls to the underlying file system.

llvm::ErrorOr< std::unique_ptr< File > > openFileForRead(const Twine &Path) override

void visitChildFileSystems(VisitCallbackTy Callback) override

std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output) override

directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override

llvm::ErrorOr< Status > status(const Twine &Path) override

bool exists(const Twine &Path) override

std::error_code setCurrentWorkingDirectory(const Twine &Path) override

std::error_code isLocal(const Twine &Path, bool &Result) override

ProxyFileSystem(IntrusiveRefCntPtr< FileSystem > FS)

llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const override

FileSystem & getUnderlyingFS() const

Directory iterator implementation for RedirectingFileSystem's directory entries.

A helper class to hold the common YAML parsing state.

A directory in the vfs with explicitly specified contents.

iterator contents_begin()

static bool classof(const Entry *E)

DirectoryEntry(StringRef Name, Status S)

Constructs an empty directory entry.

DirectoryEntry(StringRef Name, std::vector< std::unique_ptr< Entry > > Contents, Status S)

Constructs a directory entry with explicitly specified contents.

decltype(Contents)::iterator iterator

void addContent(std::unique_ptr< Entry > Content)

Entry * getLastContent() const

A directory in the vfs that maps to a directory in the external file system.

DirectoryRemapEntry(StringRef Name, StringRef ExternalContentsPath, NameKind UseName)

static bool classof(const Entry *E)

A single file or directory in the VFS.

StringRef getName() const

EntryKind getKind() const

Entry(EntryKind K, StringRef Name)

A file in the vfs that maps to a file in the external file system.

static bool classof(const Entry *E)

FileEntry(StringRef Name, StringRef ExternalContentsPath, NameKind UseName)

A file or directory in the vfs that is mapped to a file or directory in the external filesystem.

StringRef getExternalContentsPath() const

NameKind getUseName() const

RemapEntry(EntryKind K, StringRef Name, StringRef ExternalContentsPath, NameKind UseName)

bool useExternalName(bool GlobalUseExternalName) const

Whether to use the external path as the name for this file or directory.

static bool classof(const Entry *E)

A virtual file system parsed from a YAML file.

void setUsageTrackingActive(bool Active)

RootRelativeKind

The type of relative path used by Roots.

@ OverlayDir

The roots are relative to the directory where the Overlay YAML file.

@ CWD

The roots are relative to the current working directory.

bool exists(const Twine &Path) override

Check whether Path exists.

void printImpl(raw_ostream &OS, PrintType Type, unsigned IndentLevel) const override

std::vector< llvm::StringRef > getRoots() const

directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override

Get a directory_iterator for Dir.

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...

RedirectKind

The type of redirection to perform.

@ Fallthrough

Lookup the redirected path first (ie.

@ Fallback

Lookup the provided path first and if that fails, "fallback" to a lookup of the redirected path.

@ RedirectOnly

Only lookup the redirected path, do not lookup the originally provided path.

void setFallthrough(bool Fallthrough)

Sets the redirection kind to Fallthrough if true or RedirectOnly otherwise.

void visitChildFileSystems(VisitCallbackTy Callback) override

std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output) override

Gets real path of Path e.g.

ErrorOr< std::unique_ptr< File > > openFileForRead(const Twine &Path) override

Get a File object for the text file at Path, if one exists.

void setOverlayFileDir(StringRef PrefixDir)

llvm::ErrorOr< std::string > getCurrentWorkingDirectory() const override

Get the working directory of this file system.

void setRedirection(RedirectingFileSystem::RedirectKind Kind)

std::error_code isLocal(const Twine &Path, bool &Result) override

Is the file mounted on a local filesystem?

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 ...

std::error_code setCurrentWorkingDirectory(const Twine &Path) override

Set the working directory.

StringRef getOverlayFileDir() const

void printEntry(raw_ostream &OS, Entry *E, unsigned IndentLevel=0) const

The result of a status operation.

llvm::sys::fs::perms getPermissions() const

llvm::sys::fs::UniqueID getUniqueID() const

bool equivalent(const Status &Other) const

static Status copyWithNewName(const Status &In, const Twine &NewName)

Get a copy of a Status with a different name.

bool isStatusKnown() const

bool ExposesExternalVFSPath

Whether this entity has an external path different from the virtual path, and the external path is ex...

uint32_t getGroup() const

static Status copyWithNewSize(const Status &In, uint64_t NewSize)

Get a copy of a Status with a different size.

llvm::sys::TimePoint getLastModificationTime() const

llvm::sys::fs::file_type getType() const

bool isRegularFile() const

StringRef getName() const

Returns the name that should be used for this file or directory.

Status(const Twine &Name, llvm::sys::fs::UniqueID UID, llvm::sys::TimePoint<> MTime, uint32_t User, uint32_t Group, uint64_t Size, llvm::sys::fs::file_type Type, llvm::sys::fs::perms Perms)

File system that tracks the number of calls to the underlying file system.

bool exists(const Twine &Path) override

TracingFileSystem(llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > FS)

ErrorOr< std::unique_ptr< File > > openFileForRead(const Twine &Path) override

std::size_t NumOpenFileForReadCalls

std::size_t NumIsLocalCalls

directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override

std::size_t NumExistsCalls

ErrorOr< Status > status(const Twine &Path) override

void printImpl(raw_ostream &OS, PrintType Type, unsigned IndentLevel) const override

std::error_code isLocal(const Twine &Path, bool &Result) override

std::size_t NumDirBeginCalls

std::size_t NumGetRealPathCalls

std::size_t NumStatusCalls

std::error_code getRealPath(const Twine &Path, SmallVectorImpl< char > &Output) override

void addFileMapping(StringRef VirtualPath, StringRef RealPath)

void setCaseSensitivity(bool CaseSensitive)

void setOverlayDir(StringRef OverlayDirectory)

const std::vector< YAMLVFSEntry > & getMappings() const

void write(llvm::raw_ostream &OS)

void addDirectoryMapping(StringRef VirtualPath, StringRef RealPath)

void setUseExternalNames(bool UseExtNames)

The in memory file system is a tree of Nodes.

std::error_code getError() const

NamedNodeOrError(std::error_code EC)

const detail::InMemoryNode * operator*() const

StringRef getName() const

NamedNodeOrError(llvm::errc EC)

NamedNodeOrError(llvm::SmallString< 128 > Name, const detail::InMemoryNode *Node)

A member of a directory, yielded by a directory_iterator.

directory_entry()=default

directory_entry(std::string Path, llvm::sys::fs::file_type Type)

llvm::StringRef path() const

llvm::sys::fs::file_type type() const

An input iterator over the entries in a virtual path, similar to llvm::sys::fs::directory_iterator.

directory_iterator(std::shared_ptr< detail::DirIterImpl > I)

bool operator==(const directory_iterator &RHS) const

const directory_entry * operator->() const

const directory_entry & operator*() const

directory_iterator & increment(std::error_code &EC)

Equivalent to operator++, with an error code.

bool operator!=(const directory_iterator &RHS) const

directory_iterator()=default

Construct an 'end' iterator.

An input iterator over the recursive contents of a virtual path, similar to llvm::sys::fs::recursive_...

const directory_entry & operator*() const

recursive_directory_iterator()=default

Construct an 'end' iterator.

bool operator!=(const recursive_directory_iterator &RHS) const

bool operator==(const recursive_directory_iterator &Other) const

int level() const

Gets the current level. Starting path is at level 0.

recursive_directory_iterator & increment(std::error_code &EC)

Equivalent to operator++, with an error code.

const directory_entry * operator->() const

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

file_type

An enumeration for the file system's view of the type.

std::chrono::time_point< std::chrono::system_clock, D > TimePoint

A time point on the system clock.

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.

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.

std::unique_ptr< FileSystem > createPhysicalFileSystem()

Create an vfs::FileSystem for the 'real' file system, as seen by the operating system.

llvm::sys::fs::UniqueID getNextVirtualUniqueID()

Get a globally unique ID for a virtual file or directory.

IntrusiveRefCntPtr< FileSystem > getRealFileSystem()

Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.

This is an optimization pass for GlobalISel generic memory operations.

auto reverse(ContainerTy &&C)

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

Implement std::hash so that hash_code can be used in STL containers.

Represents the result of a path lookup into the RedirectingFileSystem.

std::optional< StringRef > getExternalRedirect() const

If the found Entry maps the input path to a path in the external file system (i.e.

Entry * E

The entry the looked-up path corresponds to.

void getPath(llvm::SmallVectorImpl< char > &Path) const

Get the (canonical) path of the found entry.

llvm::SmallVector< Entry *, 32 > Parents

Chain of parent directory entries for E.

YAMLVFSEntry(T1 &&VPath, T2 &&RPath, bool IsDirectory=false)

An interface for virtual file systems to provide an iterator over the (non-recursive) contents of a d...

virtual std::error_code increment()=0

Sets CurrentEntry to the next entry in the directory on success, to directory_entry() at end,...

directory_entry CurrentEntry

Status makeStatus() const

llvm::sys::fs::file_type Type

std::unique_ptr< llvm::MemoryBuffer > Buffer

llvm::sys::fs::perms Perms

llvm::sys::fs::UniqueID DirUID

Keeps state for the recursive_directory_iterator.

std::vector< directory_iterator > Stack