2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/Headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
#include "Path.h"
#include "Protocol.h"
#include "SourceCode.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Format/Format.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Tooling/Inclusions/HeaderIncludes.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/VirtualFileSystem.h"

namespace clang {
namespace clangd {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Format/Format.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/PCHContainerOperations.h"
Expand All @@ -21,6 +20,7 @@
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "gtest/gtest.h"
#include <memory>
#include <string>
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ runCheckOnCode(StringRef Code, std::vector<ClangTidyError> *Errors = nullptr,
Args.push_back(Filename.str());

ast_matchers::MatchFinder Finder;
llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
new FileManager(FileSystemOptions(), InMemoryFileSystem));

Expand Down
12 changes: 6 additions & 6 deletions clang-tools-extra/unittests/clangd/ClangdTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ int b = a;
TEST_F(ClangdVFSTest, PropagatesContexts) {
static Key<int> Secret;
struct FSProvider : public FileSystemProvider {
IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() const override {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> getFileSystem() const override {
Got = Context::current().getExisting(Secret);
return buildTestFS({});
}
Expand Down Expand Up @@ -973,19 +973,19 @@ TEST(ClangdTests, PreambleVFSStatCache) {
ListenStatsFSProvider(llvm::StringMap<unsigned> &CountStats)
: CountStats(CountStats) {}

IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() const override {
class ListenStatVFS : public vfs::ProxyFileSystem {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> getFileSystem() const override {
class ListenStatVFS : public llvm::vfs::ProxyFileSystem {
public:
ListenStatVFS(IntrusiveRefCntPtr<vfs::FileSystem> FS,
ListenStatVFS(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
llvm::StringMap<unsigned> &CountStats)
: ProxyFileSystem(std::move(FS)), CountStats(CountStats) {}

llvm::ErrorOr<std::unique_ptr<vfs::File>>
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
openFileForRead(const Twine &Path) override {
++CountStats[llvm::sys::path::filename(Path.str())];
return ProxyFileSystem::openFileForRead(Path);
}
llvm::ErrorOr<vfs::Status> status(const Twine &Path) override {
llvm::ErrorOr<llvm::vfs::Status> status(const Twine &Path) override {
++CountStats[llvm::sys::path::filename(Path.str())];
return ProxyFileSystem::status(Path);
}
Expand Down
7 changes: 4 additions & 3 deletions clang-tools-extra/unittests/clangd/FSTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ TEST(FSTests, PreambleStatusCache) {
// Main file is not cached.
EXPECT_FALSE(StatCache.lookup(testPath("main")).hasValue());

vfs::Status S("fake", llvm::sys::fs::UniqueID(0, 0),
std::chrono::system_clock::now(), 0, 0, 1024,
llvm::sys::fs::file_type::regular_file, llvm::sys::fs::all_all);
llvm::vfs::Status S("fake", llvm::sys::fs::UniqueID(0, 0),
std::chrono::system_clock::now(), 0, 0, 1024,
llvm::sys::fs::file_type::regular_file,
llvm::sys::fs::all_all);
StatCache.update(*FS, S);
auto ConsumeFS = StatCache.getConsumingFS(FS);
auto Cached = ConsumeFS->status(testPath("fake"));
Expand Down
6 changes: 3 additions & 3 deletions clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
#include "index/SymbolCollector.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Index/IndexingAction.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

Expand Down Expand Up @@ -219,7 +219,7 @@ class SymbolIndexActionFactory : public tooling::FrontendActionFactory {
class SymbolCollectorTest : public ::testing::Test {
public:
SymbolCollectorTest()
: InMemoryFileSystem(new vfs::InMemoryFileSystem),
: InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
TestHeaderName(testPath("symbol.h")),
TestFileName(testPath("symbol.cc")) {
TestHeaderURI = URI::createFile(TestHeaderName).toString();
Expand Down Expand Up @@ -258,7 +258,7 @@ class SymbolCollectorTest : public ::testing::Test {
}

protected:
llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem;
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem;
std::string TestHeaderName;
std::string TestHeaderURI;
std::string TestFileName;
Expand Down
6 changes: 3 additions & 3 deletions clang-tools-extra/unittests/clangd/TestFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
#define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
#include "ClangdServer.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"

namespace clang {
namespace clangd {

// Builds a VFS that provides access to the provided files, plus temporary
// directories.
llvm::IntrusiveRefCntPtr<vfs::FileSystem>
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
buildTestFS(llvm::StringMap<std::string> const &Files,
llvm::StringMap<time_t> const &Timestamps = {});

// A VFS provider that returns TestFSes containing a provided set of files.
class MockFSProvider : public FileSystemProvider {
public:
IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() const override {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> getFileSystem() const override {
return buildTestFS(Files);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ using find_all_symbols::SymbolAndSignals;
static bool runOnCode(tooling::ToolAction *ToolAction, StringRef Code,
StringRef FileName,
const std::vector<std::string> &ExtraArgs) {
llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
new FileManager(FileSystemOptions(), InMemoryFileSystem));
// FIXME: Investigate why -fms-compatibility breaks tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/PCHContainerOperations.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "gtest/gtest.h"
#include <memory>
#include <string>
Expand Down Expand Up @@ -63,8 +63,8 @@ class FindAllSymbolsTest : public ::testing::Test {
int used(const SymbolInfo &Symbol) { return Reporter.used(Symbol); }

bool runFindAllSymbols(StringRef HeaderCode, StringRef MainCode) {
llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
new FileManager(FileSystemOptions(), InMemoryFileSystem));

Expand Down
18 changes: 9 additions & 9 deletions clang/include/clang/Basic/FileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define LLVM_CLANG_BASIC_FILEMANAGER_H

#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/SmallVector.h"
Expand All @@ -25,9 +25,10 @@
#include "llvm/Support/Allocator.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <ctime>
#include <memory>
#include <map>
#include <memory>
#include <string>

namespace llvm {
Expand Down Expand Up @@ -71,7 +72,7 @@ class FileEntry {
bool IsValid; // Is this \c FileEntry initialized and valid?

/// The open file, if it is owned by the \p FileEntry.
mutable std::unique_ptr<vfs::File> File;
mutable std::unique_ptr<llvm::vfs::File> File;

public:
FileEntry()
Expand Down Expand Up @@ -114,7 +115,7 @@ struct FileData;
/// as a single file.
///
class FileManager : public RefCountedBase<FileManager> {
IntrusiveRefCntPtr<vfs::FileSystem> FS;
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS;
FileSystemOptions FileSystemOpts;

/// Cache for existing real directories.
Expand Down Expand Up @@ -165,15 +166,15 @@ class FileManager : public RefCountedBase<FileManager> {
std::unique_ptr<FileSystemStatCache> StatCache;

bool getStatValue(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F);
std::unique_ptr<llvm::vfs::File> *F);

/// Add all ancestors of the given path (pointing to either a file
/// or a directory) as virtual directories.
void addAncestorsAsVirtualDirs(StringRef Path);

public:
FileManager(const FileSystemOptions &FileSystemOpts,
IntrusiveRefCntPtr<vfs::FileSystem> FS = nullptr);
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS = nullptr);
~FileManager();

/// Installs the provided FileSystemStatCache object within
Expand Down Expand Up @@ -222,7 +223,7 @@ class FileManager : public RefCountedBase<FileManager> {
FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; }
const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; }

IntrusiveRefCntPtr<vfs::FileSystem> getVirtualFileSystem() const {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> getVirtualFileSystem() const {
return FS;
}

Expand All @@ -247,8 +248,7 @@ class FileManager : public RefCountedBase<FileManager> {
/// FileManager's FileSystemOptions.
///
/// \returns false on success, true on error.
bool getNoncachedStatValue(StringRef Path,
vfs::Status &Result);
bool getNoncachedStatValue(StringRef Path, llvm::vfs::Status &Result);

/// Remove the real file \p Entry from the cache.
void invalidateCache(const FileEntry *Entry);
Expand Down
20 changes: 12 additions & 8 deletions clang/include/clang/Basic/FileSystemStatCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@
#include <string>
#include <utility>

namespace clang {
namespace llvm {

namespace vfs {

class File;
class FileSystem;

} // namespace vfs
} // namespace llvm

namespace clang {

// FIXME: should probably replace this with vfs::Status
struct FileData {
Expand Down Expand Up @@ -82,8 +85,8 @@ class FileSystemStatCache {
/// implementation can optionally fill in \p F with a valid \p File object and
/// the client guarantees that it will close it.
static bool get(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F, FileSystemStatCache *Cache,
vfs::FileSystem &FS);
std::unique_ptr<llvm::vfs::File> *F,
FileSystemStatCache *Cache, llvm::vfs::FileSystem &FS);

/// Sets the next stat call cache in the chain of stat caches.
/// Takes ownership of the given stat cache.
Expand All @@ -106,11 +109,12 @@ class FileSystemStatCache {
// unique_ptr. Optional<unique_ptr<vfs::File>&> might be nicer, but
// Optional needs some work to support references so this isn't possible yet.
virtual LookupResult getStat(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F,
vfs::FileSystem &FS) = 0;
std::unique_ptr<llvm::vfs::File> *F,
llvm::vfs::FileSystem &FS) = 0;

LookupResult statChained(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F, vfs::FileSystem &FS) {
std::unique_ptr<llvm::vfs::File> *F,
llvm::vfs::FileSystem &FS) {
if (FileSystemStatCache *Next = getNextStatCache())
return Next->getStat(Path, Data, isFile, F, FS);

Expand All @@ -135,8 +139,8 @@ class MemorizeStatCalls : public FileSystemStatCache {
iterator end() const { return StatCalls.end(); }

LookupResult getStat(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F,
vfs::FileSystem &FS) override;
std::unique_ptr<llvm::vfs::File> *F,
llvm::vfs::FileSystem &FS) override;
};

} // namespace clang
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Driver/Distro.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef LLVM_CLANG_DRIVER_DISTRO_H
#define LLVM_CLANG_DRIVER_DISTRO_H

#include "clang/Basic/VirtualFileSystem.h"
#include "llvm/Support/VirtualFileSystem.h"

namespace clang {
namespace driver {
Expand Down Expand Up @@ -80,7 +80,7 @@ class Distro {
Distro(DistroType D) : DistroVal(D) {}

/// Detects the distribution using specified VFS.
explicit Distro(clang::vfs::FileSystem& VFS);
explicit Distro(llvm::vfs::FileSystem &VFS);

bool operator==(const Distro &Other) const {
return DistroVal == Other.DistroVal;
Expand Down
13 changes: 6 additions & 7 deletions clang/include/clang/Driver/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@

namespace llvm {
class Triple;
}

namespace clang {

namespace vfs {
class FileSystem;
}
} // namespace llvm

namespace clang {

namespace driver {

Expand All @@ -61,7 +60,7 @@ class Driver {

DiagnosticsEngine &Diags;

IntrusiveRefCntPtr<vfs::FileSystem> VFS;
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS;

enum DriverMode {
GCCMode,
Expand Down Expand Up @@ -284,7 +283,7 @@ class Driver {
public:
Driver(StringRef ClangExecutable, StringRef TargetTriple,
DiagnosticsEngine &Diags,
IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr);
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);

/// @name Accessors
/// @{
Expand All @@ -298,7 +297,7 @@ class Driver {

const DiagnosticsEngine &getDiags() const { return Diags; }

vfs::FileSystem &getVFS() const { return *VFS; }
llvm::vfs::FileSystem &getVFS() const { return *VFS; }

bool getCheckInputsExist() const { return CheckInputsExist; }

Expand Down
13 changes: 6 additions & 7 deletions clang/include/clang/Driver/ToolChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@ class ArgList;
class DerivedArgList;

} // namespace opt
} // namespace llvm

namespace clang {

class ObjCRuntime;

namespace vfs {

class FileSystem;

} // namespace vfs
} // namespace llvm

namespace clang {

class ObjCRuntime;

namespace driver {

Expand Down Expand Up @@ -183,7 +182,7 @@ class ToolChain {
// Accessors

const Driver &getDriver() const { return D; }
vfs::FileSystem &getVFS() const;
llvm::vfs::FileSystem &getVFS() const;
const llvm::Triple &getTriple() const { return Triple; }

/// Get the toolchain's aux triple, if it has one.
Expand Down
12 changes: 7 additions & 5 deletions clang/include/clang/Format/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@
#include "llvm/Support/Regex.h"
#include <system_error>

namespace llvm {
namespace vfs {
class FileSystem;
}
} // namespace llvm

namespace clang {

class Lexer;
class SourceManager;
class DiagnosticConsumer;

namespace vfs {
class FileSystem;
}

namespace format {

enum class ParseError { Success = 0, Error, Unsuitable };
Expand Down Expand Up @@ -2039,7 +2041,7 @@ extern const char *DefaultFallbackStyle;
llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
StringRef FallbackStyle,
StringRef Code = "",
vfs::FileSystem *FS = nullptr);
llvm::vfs::FileSystem *FS = nullptr);

// Guesses the language from the ``FileName`` and ``Code`` to be formatted.
// Defaults to FormatStyle::LK_Cpp.
Expand Down
48 changes: 24 additions & 24 deletions clang/include/clang/Frontend/ASTUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ namespace llvm {

class MemoryBuffer;

namespace vfs {

class FileSystem;

} // namespace vfs
} // namespace llvm

namespace clang {
Expand All @@ -75,12 +80,6 @@ class PreprocessorOptions;
class Sema;
class TargetInfo;

namespace vfs {

class FileSystem;

} // namespace vfs

/// \brief Enumerates the available scopes for skipping function bodies.
enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile };

Expand Down Expand Up @@ -365,12 +364,12 @@ class ASTUnit {

bool Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
std::unique_ptr<llvm::MemoryBuffer> OverrideMainBuffer,
IntrusiveRefCntPtr<vfs::FileSystem> VFS);
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);

std::unique_ptr<llvm::MemoryBuffer> getMainBufferWithPrecompiledPreamble(
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
CompilerInvocation &PreambleInvocationIn,
IntrusiveRefCntPtr<vfs::FileSystem> VFS, bool AllowRebuild = true,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, bool AllowRebuild = true,
unsigned MaxLines = 0);
void RealizeTopLevelDeclsFromPreamble();

Expand Down Expand Up @@ -698,17 +697,17 @@ class ASTUnit {
/// of this translation unit should be precompiled, to improve the performance
/// of reparsing. Set to zero to disable preambles.
///
/// \param VFS - A vfs::FileSystem to be used for all file accesses. Note that
/// preamble is saved to a temporary directory on a RealFileSystem, so in order
/// for it to be loaded correctly, VFS should have access to it(i.e., be an
/// overlay over RealFileSystem).
/// \param VFS - A llvm::vfs::FileSystem to be used for all file accesses.
/// Note that preamble is saved to a temporary directory on a RealFileSystem,
/// so in order for it to be loaded correctly, VFS should have access to
/// it(i.e., be an overlay over RealFileSystem).
///
/// \returns \c true if a catastrophic failure occurred (which means that the
/// \c ASTUnit itself is invalid), or \c false otherwise.
bool LoadFromCompilerInvocation(
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
unsigned PrecompilePreambleAfterNParses,
IntrusiveRefCntPtr<vfs::FileSystem> VFS);
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);

public:
/// Create an ASTUnit from a source file, via a CompilerInvocation
Expand Down Expand Up @@ -798,10 +797,11 @@ class ASTUnit {
/// (e.g. because the PCH could not be loaded), this accepts the ASTUnit
/// mainly to allow the caller to see the diagnostics.
///
/// \param VFS - A vfs::FileSystem to be used for all file accesses. Note that
/// preamble is saved to a temporary directory on a RealFileSystem, so in order
/// for it to be loaded correctly, VFS should have access to it(i.e., be an
/// overlay over RealFileSystem). RealFileSystem will be used if \p VFS is nullptr.
/// \param VFS - A llvm::vfs::FileSystem to be used for all file accesses.
/// Note that preamble is saved to a temporary directory on a RealFileSystem,
/// so in order for it to be loaded correctly, VFS should have access to
/// it(i.e., be an overlay over RealFileSystem). RealFileSystem will be used
/// if \p VFS is nullptr.
///
// FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
// shouldn't need to specify them at construction time.
Expand All @@ -823,22 +823,22 @@ class ASTUnit {
bool ForSerialization = false,
llvm::Optional<StringRef> ModuleFormat = llvm::None,
std::unique_ptr<ASTUnit> *ErrAST = nullptr,
IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr);
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);

/// Reparse the source files using the same command-line options that
/// were originally used to produce this translation unit.
///
/// \param VFS - A vfs::FileSystem to be used for all file accesses. Note that
/// preamble is saved to a temporary directory on a RealFileSystem, so in order
/// for it to be loaded correctly, VFS should give an access to this(i.e. be an
/// overlay over RealFileSystem). FileMgr->getVirtualFileSystem() will be used if
/// \p VFS is nullptr.
/// \param VFS - A llvm::vfs::FileSystem to be used for all file accesses.
/// Note that preamble is saved to a temporary directory on a RealFileSystem,
/// so in order for it to be loaded correctly, VFS should give an access to
/// this(i.e. be an overlay over RealFileSystem).
/// FileMgr->getVirtualFileSystem() will be used if \p VFS is nullptr.
///
/// \returns True if a failure occurred that causes the ASTUnit not to
/// contain any translation-unit information, false otherwise.
bool Reparse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
ArrayRef<RemappedFile> RemappedFiles = None,
IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr);
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);

/// Free data that will be re-generated on the next parse.
///
Expand Down
6 changes: 3 additions & 3 deletions clang/include/clang/Frontend/CompilerInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CompilerInstance : public ModuleLoader {
IntrusiveRefCntPtr<TargetInfo> AuxTarget;

/// The virtual file system.
IntrusiveRefCntPtr<vfs::FileSystem> VirtualFileSystem;
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VirtualFileSystem;

/// The file manager.
IntrusiveRefCntPtr<FileManager> FileMgr;
Expand Down Expand Up @@ -384,7 +384,7 @@ class CompilerInstance : public ModuleLoader {

bool hasVirtualFileSystem() const { return VirtualFileSystem != nullptr; }

vfs::FileSystem &getVirtualFileSystem() const {
llvm::vfs::FileSystem &getVirtualFileSystem() const {
assert(hasVirtualFileSystem() &&
"Compiler instance has no virtual file system");
return *VirtualFileSystem;
Expand All @@ -394,7 +394,7 @@ class CompilerInstance : public ModuleLoader {
///
/// \note Most clients should use setFileManager, which will implicitly reset
/// the virtual file system to the one contained in the file manager.
void setVirtualFileSystem(IntrusiveRefCntPtr<vfs::FileSystem> FS) {
void setVirtualFileSystem(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
VirtualFileSystem = std::move(FS);
}

Expand Down
21 changes: 10 additions & 11 deletions clang/include/clang/Frontend/CompilerInvocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class ArgList;

} // namespace opt

namespace vfs {

class FileSystem;

} // namespace vfs

} // namespace llvm

namespace clang {
Expand Down Expand Up @@ -217,20 +223,13 @@ class CompilerInvocation : public CompilerInvocationBase {
/// @}
};

namespace vfs {

class FileSystem;

} // namespace vfs

IntrusiveRefCntPtr<vfs::FileSystem>
IntrusiveRefCntPtr<llvm::vfs::FileSystem>
createVFSFromCompilerInvocation(const CompilerInvocation &CI,
DiagnosticsEngine &Diags);

IntrusiveRefCntPtr<vfs::FileSystem>
createVFSFromCompilerInvocation(const CompilerInvocation &CI,
DiagnosticsEngine &Diags,
IntrusiveRefCntPtr<vfs::FileSystem> BaseFS);
IntrusiveRefCntPtr<llvm::vfs::FileSystem> createVFSFromCompilerInvocation(
const CompilerInvocation &CI, DiagnosticsEngine &Diags,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS);

} // namespace clang

Expand Down
23 changes: 12 additions & 11 deletions clang/include/clang/Frontend/PrecompiledPreamble.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@

namespace llvm {
class MemoryBuffer;
}

namespace clang {
namespace vfs {
class FileSystem;
}
} // namespace llvm

namespace clang {
class CompilerInstance;
class CompilerInvocation;
class DeclGroupRef;
Expand Down Expand Up @@ -80,7 +79,8 @@ class PrecompiledPreamble {
static llvm::ErrorOr<PrecompiledPreamble>
Build(const CompilerInvocation &Invocation,
const llvm::MemoryBuffer *MainFileBuffer, PreambleBounds Bounds,
DiagnosticsEngine &Diagnostics, IntrusiveRefCntPtr<vfs::FileSystem> VFS,
DiagnosticsEngine &Diagnostics,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
bool StoreInMemory, PreambleCallbacks &Callbacks);

Expand All @@ -99,7 +99,7 @@ class PrecompiledPreamble {
/// MainFileBuffer) of the main file.
bool CanReuse(const CompilerInvocation &Invocation,
const llvm::MemoryBuffer *MainFileBuffer, PreambleBounds Bounds,
vfs::FileSystem *VFS) const;
llvm::vfs::FileSystem *VFS) const;

/// Changes options inside \p CI to use PCH from this preamble. Also remaps
/// main file to \p MainFileBuffer and updates \p VFS to ensure the preamble
Expand All @@ -110,14 +110,14 @@ class PrecompiledPreamble {
/// responsible for making sure the PrecompiledPreamble instance outlives the
/// compiler run and the AST that will be using the PCH.
void AddImplicitPreamble(CompilerInvocation &CI,
IntrusiveRefCntPtr<vfs::FileSystem> &VFS,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS,
llvm::MemoryBuffer *MainFileBuffer) const;

/// Configure \p CI to use this preamble.
/// Like AddImplicitPreamble, but doesn't assume CanReuse() is true.
/// If this preamble does not match the file, it may parse differently.
void OverridePreamble(CompilerInvocation &CI,
IntrusiveRefCntPtr<vfs::FileSystem> &VFS,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS,
llvm::MemoryBuffer *MainFileBuffer) const;

private:
Expand Down Expand Up @@ -233,15 +233,16 @@ class PrecompiledPreamble {
/// Helper function to set up PCH for the preamble into \p CI and \p VFS to
/// with the specified \p Bounds.
void configurePreamble(PreambleBounds Bounds, CompilerInvocation &CI,
IntrusiveRefCntPtr<vfs::FileSystem> &VFS,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS,
llvm::MemoryBuffer *MainFileBuffer) const;

/// Sets up the PreprocessorOptions and changes VFS, so that PCH stored in \p
/// Storage is accessible to clang. This method is an implementation detail of
/// AddImplicitPreamble.
static void setupPreambleStorage(const PCHStorage &Storage,
PreprocessorOptions &PreprocessorOpts,
IntrusiveRefCntPtr<vfs::FileSystem> &VFS);
static void
setupPreambleStorage(const PCHStorage &Storage,
PreprocessorOptions &PreprocessorOpts,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS);

/// Manages the memory buffer or temporary file that stores the PCH.
PCHStorage Storage;
Expand Down
8 changes: 4 additions & 4 deletions clang/include/clang/Frontend/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Option/OptSpecifier.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <cstdint>
#include <memory>
#include <string>
Expand Down Expand Up @@ -134,7 +134,7 @@ class ModuleDependencyCollector : public DependencyCollector {
std::string DestDir;
bool HasErrors = false;
llvm::StringSet<> Seen;
vfs::YAMLVFSWriter VFSWriter;
llvm::vfs::YAMLVFSWriter VFSWriter;
llvm::StringMap<std::string> SymLinkMap;

bool getRealPath(StringRef SrcPath, SmallVectorImpl<char> &Result);
Expand Down Expand Up @@ -201,7 +201,7 @@ std::unique_ptr<CompilerInvocation> createInvocationFromCommandLine(
ArrayRef<const char *> Args,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
IntrusiveRefCntPtr<DiagnosticsEngine>(),
IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr);
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);

/// Return the value of the last argument as an integer, or a default. If Diags
/// is non-null, emits an error if the argument is given, but non-integral.
Expand Down
3 changes: 2 additions & 1 deletion clang/include/clang/Tooling/StandaloneExecution.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class StandaloneToolExecutor : public ToolExecutor {
StandaloneToolExecutor(
const CompilationDatabase &Compilations,
llvm::ArrayRef<std::string> SourcePaths,
IntrusiveRefCntPtr<vfs::FileSystem> BaseFS = vfs::getRealFileSystem(),
IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS =
llvm::vfs::getRealFileSystem(),
std::shared_ptr<PCHContainerOperations> PCHContainerOps =
std::make_shared<PCHContainerOperations>());

Expand Down
14 changes: 7 additions & 7 deletions clang/include/clang/Tooling/Tooling.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "clang/AST/ASTConsumer.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Frontend/PCHContainerOperations.h"
#include "clang/Tooling/ArgumentsAdjusters.h"
Expand All @@ -44,6 +43,7 @@
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <memory>
#include <string>
#include <utility>
Expand Down Expand Up @@ -190,7 +190,7 @@ bool runToolOnCodeWithArgs(
// Similar to the overload except this takes a VFS.
bool runToolOnCodeWithArgs(
FrontendAction *ToolAction, const Twine &Code,
llvm::IntrusiveRefCntPtr<vfs::FileSystem> VFS,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
const std::vector<std::string> &Args, const Twine &FileName = "input.cc",
const Twine &ToolName = "clang-tool",
std::shared_ptr<PCHContainerOperations> PCHContainerOps =
Expand Down Expand Up @@ -319,8 +319,8 @@ class ClangTool {
ArrayRef<std::string> SourcePaths,
std::shared_ptr<PCHContainerOperations> PCHContainerOps =
std::make_shared<PCHContainerOperations>(),
IntrusiveRefCntPtr<vfs::FileSystem> BaseFS =
vfs::getRealFileSystem());
IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS =
llvm::vfs::getRealFileSystem());

~ClangTool();

Expand Down Expand Up @@ -373,8 +373,8 @@ class ClangTool {
std::vector<std::string> SourcePaths;
std::shared_ptr<PCHContainerOperations> PCHContainerOps;

llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> OverlayFileSystem;
llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem;
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem;
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem;
llvm::IntrusiveRefCntPtr<FileManager> Files;

// Contains a list of pairs (<file name>, <file content>).
Expand Down Expand Up @@ -467,7 +467,7 @@ inline std::unique_ptr<FrontendActionFactory> newFrontendActionFactory(
std::string getAbsolutePath(StringRef File);

/// An overload of getAbsolutePath that works over the provided \p FS.
llvm::Expected<std::string> getAbsolutePath(vfs::FileSystem &FS,
llvm::Expected<std::string> getAbsolutePath(llvm::vfs::FileSystem &FS,
StringRef File);

/// Changes CommandLine to contain implicit flags that would have been
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ add_clang_library(clangBasic
Targets/XCore.cpp
TokenKinds.cpp
Version.cpp
VirtualFileSystem.cpp
Warnings.cpp
XRayInstr.cpp
XRayLists.cpp
Expand Down
12 changes: 6 additions & 6 deletions clang/lib/Basic/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using namespace clang;
//===----------------------------------------------------------------------===//

FileManager::FileManager(const FileSystemOptions &FSO,
IntrusiveRefCntPtr<vfs::FileSystem> FS)
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS)
: FS(std::move(FS)), FileSystemOpts(FSO), SeenDirEntries(64),
SeenFileEntries(64), NextFileUID(0) {
NumDirLookups = NumFileLookups = 0;
Expand All @@ -58,7 +58,7 @@ FileManager::FileManager(const FileSystemOptions &FSO,
// If the caller doesn't provide a virtual file system, just grab the real
// file system.
if (!this->FS)
this->FS = vfs::getRealFileSystem();
this->FS = llvm::vfs::getRealFileSystem();
}

FileManager::~FileManager() = default;
Expand Down Expand Up @@ -252,7 +252,7 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
// FIXME: This will reduce the # syscalls.

// Nope, there isn't. Check to see if the file exists.
std::unique_ptr<vfs::File> F;
std::unique_ptr<llvm::vfs::File> F;
FileData Data;
if (getStatValue(InterndFileName, Data, true, openFile ? &F : nullptr)) {
// There's no real file at the given path.
Expand Down Expand Up @@ -475,7 +475,7 @@ FileManager::getBufferForFile(StringRef Filename, bool isVolatile) {
/// false if it's an existent real file. If FileDescriptor is NULL,
/// do directory look-up instead of file look-up.
bool FileManager::getStatValue(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F) {
std::unique_ptr<llvm::vfs::File> *F) {
// FIXME: FileSystemOpts shouldn't be passed in here, all paths should be
// absolute!
if (FileSystemOpts.WorkingDir.empty())
Expand All @@ -489,11 +489,11 @@ bool FileManager::getStatValue(StringRef Path, FileData &Data, bool isFile,
}

bool FileManager::getNoncachedStatValue(StringRef Path,
vfs::Status &Result) {
llvm::vfs::Status &Result) {
SmallString<128> FilePath(Path);
FixupRelativePath(FilePath);

llvm::ErrorOr<vfs::Status> S = FS->status(FilePath.c_str());
llvm::ErrorOr<llvm::vfs::Status> S = FS->status(FilePath.c_str());
if (!S)
return true;
Result = *S;
Expand Down
16 changes: 9 additions & 7 deletions clang/lib/Basic/FileSystemStatCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
//===----------------------------------------------------------------------===//

#include "clang/Basic/FileSystemStatCache.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "llvm/Support/Chrono.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <utility>

using namespace clang;

void FileSystemStatCache::anchor() {}

static void copyStatusToFileData(const vfs::Status &Status,
static void copyStatusToFileData(const llvm::vfs::Status &Status,
FileData &Data) {
Data.Name = Status.getName();
Data.Size = Status.getSize();
Expand All @@ -44,8 +44,9 @@ static void copyStatusToFileData(const vfs::Status &Status,
/// implementation can optionally fill in FileDescriptor with a valid
/// descriptor and the client guarantees that it will close it.
bool FileSystemStatCache::get(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F,
FileSystemStatCache *Cache, vfs::FileSystem &FS) {
std::unique_ptr<llvm::vfs::File> *F,
FileSystemStatCache *Cache,
llvm::vfs::FileSystem &FS) {
LookupResult R;
bool isForDir = !isFile;

Expand All @@ -55,7 +56,7 @@ bool FileSystemStatCache::get(StringRef Path, FileData &Data, bool isFile,
else if (isForDir || !F) {
// If this is a directory or a file descriptor is not needed and we have
// no cache, just go to the file system.
llvm::ErrorOr<vfs::Status> Status = FS.status(Path);
llvm::ErrorOr<llvm::vfs::Status> Status = FS.status(Path);
if (!Status) {
R = CacheMissing;
} else {
Expand All @@ -79,7 +80,7 @@ bool FileSystemStatCache::get(StringRef Path, FileData &Data, bool isFile,
// Otherwise, the open succeeded. Do an fstat to get the information
// about the file. We'll end up returning the open file descriptor to the
// client to do what they please with it.
llvm::ErrorOr<vfs::Status> Status = (*OwnedFile)->status();
llvm::ErrorOr<llvm::vfs::Status> Status = (*OwnedFile)->status();
if (Status) {
R = CacheExists;
copyStatusToFileData(*Status, Data);
Expand Down Expand Up @@ -111,7 +112,8 @@ bool FileSystemStatCache::get(StringRef Path, FileData &Data, bool isFile,

MemorizeStatCalls::LookupResult
MemorizeStatCalls::getStat(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F, vfs::FileSystem &FS) {
std::unique_ptr<llvm::vfs::File> *F,
llvm::vfs::FileSystem &FS) {
LookupResult Result = statChained(Path, Data, isFile, F, FS);

// Do not cache failed stats, it is easy to construct common inconsistent
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Basic/SourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2263,8 +2263,8 @@ SourceManagerForFile::SourceManagerForFile(StringRef FileName,
StringRef Content) {
// This is referenced by `FileMgr` and will be released by `FileMgr` when it
// is deleted.
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);
InMemoryFileSystem->addFile(
FileName, 0,
llvm::MemoryBuffer::getMemBuffer(Content, FileName,
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Driver/Distro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

#include "clang/Driver/Distro.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
Expand All @@ -17,7 +18,7 @@
using namespace clang::driver;
using namespace clang;

static Distro::DistroType DetectDistro(vfs::FileSystem &VFS) {
static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
VFS.getBufferForFile("/etc/lsb-release");
if (File) {
Expand Down Expand Up @@ -139,4 +140,4 @@ static Distro::DistroType DetectDistro(vfs::FileSystem &VFS) {
return Distro::UnknownDistro;
}

Distro::Distro(vfs::FileSystem &VFS) : DistroVal(DetectDistro(VFS)) {}
Distro::Distro(llvm::vfs::FileSystem &VFS) : DistroVal(DetectDistro(VFS)) {}
6 changes: 3 additions & 3 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "ToolChains/WebAssembly.h"
#include "ToolChains/XCore.h"
#include "clang/Basic/Version.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Config/config.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Compilation.h"
Expand Down Expand Up @@ -75,6 +74,7 @@
#include "llvm/Support/Program.h"
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <map>
#include <memory>
Expand All @@ -89,7 +89,7 @@ using namespace llvm::opt;

Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
DiagnosticsEngine &Diags,
IntrusiveRefCntPtr<vfs::FileSystem> VFS)
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS)
: Opts(createDriverOptTable()), Diags(Diags), VFS(std::move(VFS)),
Mode(GCCMode), SaveTemps(SaveTempsNone), BitcodeEmbed(EmbedNone),
LTOMode(LTOK_None), ClangExecutable(ClangExecutable),
Expand All @@ -104,7 +104,7 @@ Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,

// Provide a sane fallback if no VFS is specified.
if (!this->VFS)
this->VFS = vfs::getRealFileSystem();
this->VFS = llvm::vfs::getRealFileSystem();

Name = llvm::sys::path::filename(ClangExecutable);
Dir = llvm::sys::path::parent_path(ClangExecutable);
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "ToolChains/Clang.h"
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Basic/Sanitizers.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Config/config.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Driver.h"
Expand All @@ -39,6 +38,7 @@
#include "llvm/Support/TargetParser.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/VersionTuple.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <cassert>
#include <cstddef>
#include <cstring>
Expand Down Expand Up @@ -99,7 +99,9 @@ void ToolChain::setTripleEnvironment(llvm::Triple::EnvironmentType Env) {

ToolChain::~ToolChain() = default;

vfs::FileSystem &ToolChain::getVFS() const { return getDriver().getVFS(); }
llvm::vfs::FileSystem &ToolChain::getVFS() const {
return getDriver().getVFS();
}

bool ToolChain::useIntegratedAs() const {
return Args.hasFlag(options::OPT_fintegrated_as,
Expand Down
7 changes: 4 additions & 3 deletions clang/lib/Driver/ToolChains/BareMetal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
#include "InputInfo.h"
#include "Gnu.h"

#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm::opt;
Expand Down Expand Up @@ -119,8 +119,9 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(
std::error_code EC;
Generic_GCC::GCCVersion Version = {"", -1, -1, -1, "", "", ""};
// Walk the subdirs, and find the one with the newest gcc version:
for (vfs::directory_iterator LI =
getDriver().getVFS().dir_begin(Dir.str(), EC), LE;
for (llvm::vfs::directory_iterator
LI = getDriver().getVFS().dir_begin(Dir.str(), EC),
LE;
!EC && LI != LE; LI = LI.increment(EC)) {
StringRef VersionText = llvm::sys::path::filename(LI->path());
auto CandidateVersion = Generic_GCC::GCCVersion::Parse(VersionText);
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
#include "Arch/PPC.h"
#include "Arch/SystemZ.h"
#include "Arch/X86.h"
#include "Hexagon.h"
#include "HIP.h"
#include "Hexagon.h"
#include "InputInfo.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Basic/Version.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Config/config.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Compilation.h"
Expand Down Expand Up @@ -52,6 +51,7 @@
#include "llvm/Support/Program.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/TargetParser.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/YAMLParser.h"

using namespace clang::driver;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/Cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "CommonArgs.h"
#include "InputInfo.h"
#include "clang/Basic/Cuda.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Config/config.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Distro.h"
Expand All @@ -23,6 +22,7 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <system_error>

using namespace clang::driver;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "CommonArgs.h"
#include "clang/Basic/AlignedAllocation.h"
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
Expand All @@ -23,6 +22,7 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/TargetParser.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <cstdlib> // ::getenv

using namespace clang::driver;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/FreeBSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#include "Arch/Mips.h"
#include "Arch/Sparc.h"
#include "CommonArgs.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/VirtualFileSystem.h"

using namespace clang::driver;
using namespace clang::driver::tools;
Expand Down
13 changes: 7 additions & 6 deletions clang/lib/Driver/ToolChains/Gnu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "Arch/SystemZ.h"
#include "CommonArgs.h"
#include "Linux.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Config/config.h" // for GCC_INSTALL_PREFIX
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
Expand All @@ -27,6 +26,7 @@
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/TargetParser.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <system_error>

using namespace clang::driver;
Expand Down Expand Up @@ -791,10 +791,10 @@ namespace {
// Filter to remove Multilibs that don't exist as a suffix to Path
class FilterNonExistent {
StringRef Base, File;
vfs::FileSystem &VFS;
llvm::vfs::FileSystem &VFS;

public:
FilterNonExistent(StringRef Base, StringRef File, vfs::FileSystem &VFS)
FilterNonExistent(StringRef Base, StringRef File, llvm::vfs::FileSystem &VFS)
: Base(Base), File(File), VFS(VFS) {}
bool operator()(const Multilib &M) {
return !VFS.exists(Base + M.gccSuffix() + File);
Expand Down Expand Up @@ -940,7 +940,7 @@ static bool findMipsCsMultilibs(const Multilib::flags_list &Flags,
return false;
}

static bool findMipsAndroidMultilibs(vfs::FileSystem &VFS, StringRef Path,
static bool findMipsAndroidMultilibs(llvm::vfs::FileSystem &VFS, StringRef Path,
const Multilib::flags_list &Flags,
FilterNonExistent &NonExistent,
DetectedMultilibs &Result) {
Expand Down Expand Up @@ -1762,7 +1762,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(

std::string PrefixDir = SysRoot.str() + "/usr/gcc";
std::error_code EC;
for (vfs::directory_iterator LI = D.getVFS().dir_begin(PrefixDir, EC), LE;
for (llvm::vfs::directory_iterator LI = D.getVFS().dir_begin(PrefixDir, EC),
LE;
!EC && LI != LE; LI = LI.increment(EC)) {
StringRef VersionText = llvm::sys::path::filename(LI->path());
GCCVersion CandidateVersion = GCCVersion::Parse(VersionText);
Expand Down Expand Up @@ -2205,7 +2206,7 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(

StringRef LibSuffix = Suffix.LibSuffix;
std::error_code EC;
for (vfs::directory_iterator
for (llvm::vfs::directory_iterator
LI = D.getVFS().dir_begin(LibDir + "/" + LibSuffix, EC),
LE;
!EC && LI != LE; LI = LI.increment(EC)) {
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Driver/ToolChains/Hexagon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
//===----------------------------------------------------------------------===//

#include "Hexagon.h"
#include "InputInfo.h"
#include "CommonArgs.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "InputInfo.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
Expand All @@ -19,6 +18,7 @@
#include "llvm/Option/ArgList.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"

using namespace clang::driver;
using namespace clang::driver::tools;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/Linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "Arch/PPC.h"
#include "Arch/RISCV.h"
#include "CommonArgs.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Config/config.h"
#include "clang/Driver/Distro.h"
#include "clang/Driver/Driver.h"
Expand All @@ -23,6 +22,7 @@
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <system_error>

using namespace clang::driver;
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Driver/ToolChains/Minix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
//===----------------------------------------------------------------------===//

#include "Minix.h"
#include "InputInfo.h"
#include "CommonArgs.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "InputInfo.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/VirtualFileSystem.h"

using namespace clang::driver;
using namespace clang;
Expand Down
7 changes: 4 additions & 3 deletions clang/lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Lex/Lexer.h"
#include "clang/Tooling/Inclusions/HeaderIncludes.h"
#include "llvm/ADT/STLExtras.h"
Expand All @@ -38,6 +37,7 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Regex.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/YAMLTraits.h"
#include <algorithm>
#include <memory>
Expand Down Expand Up @@ -2326,9 +2326,10 @@ const char *DefaultFallbackStyle = "LLVM";

llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
StringRef FallbackStyleName,
StringRef Code, vfs::FileSystem *FS) {
StringRef Code,
llvm::vfs::FileSystem *FS) {
if (!FS) {
FS = vfs::getRealFileSystem().get();
FS = llvm::vfs::getRealFileSystem().get();
}
FormatStyle Style = getLLVMStyle();
Style.Language = guessLanguage(FileName, Code);
Expand Down
26 changes: 13 additions & 13 deletions clang/lib/Frontend/ASTUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/FrontendAction.h"
Expand Down Expand Up @@ -88,6 +87,7 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <atomic>
Expand Down Expand Up @@ -155,9 +155,8 @@ static bool moveOnNoError(llvm::ErrorOr<T> Val, T &Output) {
/// and file-to-buffer remappings inside \p Invocation.
static std::unique_ptr<llvm::MemoryBuffer>
getBufferForFileHandlingRemapping(const CompilerInvocation &Invocation,
vfs::FileSystem *VFS,
StringRef FilePath,
bool isVolatile) {
llvm::vfs::FileSystem *VFS,
StringRef FilePath, bool isVolatile) {
const auto &PreprocessorOpts = Invocation.getPreprocessorOpts();

// Try to determine if the main file has been remapped, either from the
Expand Down Expand Up @@ -752,7 +751,8 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->CaptureDiagnostics = CaptureDiagnostics;
AST->Diagnostics = Diags;
IntrusiveRefCntPtr<vfs::FileSystem> VFS = vfs::getRealFileSystem();
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
llvm::vfs::getRealFileSystem();
AST->FileMgr = new FileManager(FileSystemOpts, VFS);
AST->UserFilesAreVolatile = UserFilesAreVolatile;
AST->SourceMgr = new SourceManager(AST->getDiagnostics(),
Expand Down Expand Up @@ -1074,15 +1074,15 @@ static void checkAndSanitizeDiags(SmallVectorImpl<StoredDiagnostic> &
/// contain any translation-unit information, false otherwise.
bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
std::unique_ptr<llvm::MemoryBuffer> OverrideMainBuffer,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
if (!Invocation)
return true;

auto CCInvocation = std::make_shared<CompilerInvocation>(*Invocation);
if (OverrideMainBuffer) {
assert(Preamble &&
"No preamble was built, but OverrideMainBuffer is not null");
IntrusiveRefCntPtr<vfs::FileSystem> OldVFS = VFS;
IntrusiveRefCntPtr<llvm::vfs::FileSystem> OldVFS = VFS;
Preamble->AddImplicitPreamble(*CCInvocation, VFS, OverrideMainBuffer.get());
if (OldVFS != VFS && FileMgr) {
assert(OldVFS == FileMgr->getVirtualFileSystem() &&
Expand Down Expand Up @@ -1279,7 +1279,7 @@ std::unique_ptr<llvm::MemoryBuffer>
ASTUnit::getMainBufferWithPrecompiledPreamble(
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
CompilerInvocation &PreambleInvocationIn,
IntrusiveRefCntPtr<vfs::FileSystem> VFS, bool AllowRebuild,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, bool AllowRebuild,
unsigned MaxLines) {
auto MainFilePath =
PreambleInvocationIn.getFrontendOpts().Inputs[0].getFile();
Expand Down Expand Up @@ -1468,7 +1468,7 @@ ASTUnit::create(std::shared_ptr<CompilerInvocation> CI,
bool CaptureDiagnostics, bool UserFilesAreVolatile) {
std::unique_ptr<ASTUnit> AST(new ASTUnit(false));
ConfigureDiags(Diags, *AST, CaptureDiagnostics);
IntrusiveRefCntPtr<vfs::FileSystem> VFS =
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
createVFSFromCompilerInvocation(*CI, *Diags);
AST->Diagnostics = Diags;
AST->FileSystemOpts = CI->getFileSystemOpts();
Expand Down Expand Up @@ -1630,7 +1630,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
bool ASTUnit::LoadFromCompilerInvocation(
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
unsigned PrecompilePreambleAfterNParses,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
if (!Invocation)
return true;

Expand Down Expand Up @@ -1709,7 +1709,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
bool AllowPCHWithCompilerErrors, SkipFunctionBodiesScope SkipFunctionBodies,
bool SingleFileParse, bool UserFilesAreVolatile, bool ForSerialization,
llvm::Optional<StringRef> ModuleFormat, std::unique_ptr<ASTUnit> *ErrAST,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
assert(Diags.get() && "no DiagnosticsEngine was provided");

SmallVector<StoredDiagnostic, 4> StoredDiagnostics;
Expand Down Expand Up @@ -1754,7 +1754,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
AST->Diagnostics = Diags;
AST->FileSystemOpts = CI->getFileSystemOpts();
if (!VFS)
VFS = vfs::getRealFileSystem();
VFS = llvm::vfs::getRealFileSystem();
VFS = createVFSFromCompilerInvocation(*CI, *Diags, VFS);
AST->FileMgr = new FileManager(AST->FileSystemOpts, VFS);
AST->PCMCache = new MemoryBufferCache;
Expand Down Expand Up @@ -1794,7 +1794,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(

bool ASTUnit::Reparse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
ArrayRef<RemappedFile> RemappedFiles,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
if (!Invocation)
return true;

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Frontend/CacheTokens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,8 @@ class StatListener : public FileSystemStatCache {
~StatListener() override {}

LookupResult getStat(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F,
vfs::FileSystem &FS) override {
std::unique_ptr<llvm::vfs::File> *F,
llvm::vfs::FileSystem &FS) override {
LookupResult Result = statChained(Path, Data, isFile, F, FS);

if (Result == CacheMissing) // Failed 'stat'.
Expand Down
12 changes: 6 additions & 6 deletions clang/lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ static void collectIncludePCH(CompilerInstance &CI,
std::error_code EC;
SmallString<128> DirNative;
llvm::sys::path::native(PCHDir->getName(), DirNative);
vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
llvm::vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
SimpleASTReaderListener Validator(CI.getPreprocessor());
for (vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
for (llvm::vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
// Check whether this is an AST file. ASTReader::isAcceptableASTFile is not
// used here since we're not interested in validating the PCH at this time,
Expand All @@ -198,14 +198,14 @@ static void collectVFSEntries(CompilerInstance &CI,
return;

// Collect all VFS found.
SmallVector<vfs::YAMLVFSEntry, 16> VFSEntries;
SmallVector<llvm::vfs::YAMLVFSEntry, 16> VFSEntries;
for (const std::string &VFSFile : CI.getHeaderSearchOpts().VFSOverlayFiles) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer =
llvm::MemoryBuffer::getFile(VFSFile);
if (!Buffer)
return;
vfs::collectVFSFromYAML(std::move(Buffer.get()), /*DiagHandler*/ nullptr,
VFSFile, VFSEntries);
llvm::vfs::collectVFSFromYAML(std::move(Buffer.get()),
/*DiagHandler*/ nullptr, VFSFile, VFSEntries);
}

for (auto &E : VFSEntries)
Expand Down Expand Up @@ -303,7 +303,7 @@ CompilerInstance::createDiagnostics(DiagnosticOptions *Opts,

FileManager *CompilerInstance::createFileManager() {
if (!hasVirtualFileSystem()) {
IntrusiveRefCntPtr<vfs::FileSystem> VFS =
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
createVFSFromCompilerInvocation(getInvocation(), getDiagnostics());
setVirtualFileSystem(VFS);
}
Expand Down
20 changes: 10 additions & 10 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Basic/Version.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Basic/Visibility.h"
#include "clang/Basic/XRayInstr.h"
#include "clang/Config/config.h"
Expand Down Expand Up @@ -77,6 +76,7 @@
#include "llvm/Support/Process.h"
#include "llvm/Support/Regex.h"
#include "llvm/Support/VersionTuple.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetOptions.h"
#include <algorithm>
Expand Down Expand Up @@ -3245,21 +3245,21 @@ void BuryPointer(const void *Ptr) {
GraveYard[Idx] = Ptr;
}

IntrusiveRefCntPtr<vfs::FileSystem>
IntrusiveRefCntPtr<llvm::vfs::FileSystem>
createVFSFromCompilerInvocation(const CompilerInvocation &CI,
DiagnosticsEngine &Diags) {
return createVFSFromCompilerInvocation(CI, Diags, vfs::getRealFileSystem());
return createVFSFromCompilerInvocation(CI, Diags,
llvm::vfs::getRealFileSystem());
}

IntrusiveRefCntPtr<vfs::FileSystem>
createVFSFromCompilerInvocation(const CompilerInvocation &CI,
DiagnosticsEngine &Diags,
IntrusiveRefCntPtr<vfs::FileSystem> BaseFS) {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> createVFSFromCompilerInvocation(
const CompilerInvocation &CI, DiagnosticsEngine &Diags,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) {
if (CI.getHeaderSearchOpts().VFSOverlayFiles.empty())
return BaseFS;

IntrusiveRefCntPtr<vfs::OverlayFileSystem> Overlay(
new vfs::OverlayFileSystem(BaseFS));
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> Overlay(
new llvm::vfs::OverlayFileSystem(BaseFS));
// earlier vfs files are on the bottom
for (const auto &File : CI.getHeaderSearchOpts().VFSOverlayFiles) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer =
Expand All @@ -3269,7 +3269,7 @@ createVFSFromCompilerInvocation(const CompilerInvocation &CI,
continue;
}

IntrusiveRefCntPtr<vfs::FileSystem> FS = vfs::getVFSFromYAML(
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS = llvm::vfs::getVFSFromYAML(
std::move(Buffer.get()), /*DiagHandler*/ nullptr, File);
if (FS)
Overlay->pushOverlay(FS);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using namespace llvm::opt;
/// argument vector.
std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine(
ArrayRef<const char *> ArgList, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
if (!Diags.get()) {
// No diagnostics engine was provided, so create our own diagnostics object
// with the default options.
Expand Down
9 changes: 5 additions & 4 deletions clang/lib/Frontend/FrontendAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ static std::error_code collectModuleHeaderIncludes(
SmallString<128> DirNative;
llvm::sys::path::native(UmbrellaDir.Entry->getName(), DirNative);

vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
for (vfs::recursive_directory_iterator Dir(FS, DirNative, EC), End;
llvm::vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
for (llvm::vfs::recursive_directory_iterator Dir(FS, DirNative, EC), End;
Dir != End && !EC; Dir.increment(EC)) {
// Check whether this entry has an extension typically associated with
// headers.
Expand Down Expand Up @@ -696,8 +696,9 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
SmallString<128> DirNative;
llvm::sys::path::native(PCHDir->getName(), DirNative);
bool Found = false;
vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
for (vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
llvm::vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
for (llvm::vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC),
DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
// Check whether this is an acceptable AST file.
if (ASTReader::isAcceptableASTFile(
Expand Down
36 changes: 19 additions & 17 deletions clang/lib/Frontend/PrecompiledPreamble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "clang/Frontend/PrecompiledPreamble.h"
#include "clang/AST/DeclObjC.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/FrontendActions.h"
Expand All @@ -30,6 +29,7 @@
#include "llvm/Support/Mutex.h"
#include "llvm/Support/MutexGuard.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <limits>
#include <utility>

Expand All @@ -48,17 +48,17 @@ StringRef getInMemoryPreamblePath() {
#endif
}

IntrusiveRefCntPtr<vfs::FileSystem>
IntrusiveRefCntPtr<llvm::vfs::FileSystem>
createVFSOverlayForPreamblePCH(StringRef PCHFilename,
std::unique_ptr<llvm::MemoryBuffer> PCHBuffer,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
// We want only the PCH file from the real filesystem to be available,
// so we create an in-memory VFS with just that and overlay it on top.
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> PCHFS(
new vfs::InMemoryFileSystem());
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> PCHFS(
new llvm::vfs::InMemoryFileSystem());
PCHFS->addFile(PCHFilename, 0, std::move(PCHBuffer));
IntrusiveRefCntPtr<vfs::OverlayFileSystem> Overlay(
new vfs::OverlayFileSystem(VFS));
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> Overlay(
new llvm::vfs::OverlayFileSystem(VFS));
Overlay->pushOverlay(PCHFS);
return Overlay;
}
Expand Down Expand Up @@ -232,7 +232,8 @@ PreambleBounds clang::ComputePreambleBounds(const LangOptions &LangOpts,
llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build(
const CompilerInvocation &Invocation,
const llvm::MemoryBuffer *MainFileBuffer, PreambleBounds Bounds,
DiagnosticsEngine &Diagnostics, IntrusiveRefCntPtr<vfs::FileSystem> VFS,
DiagnosticsEngine &Diagnostics,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
std::shared_ptr<PCHContainerOperations> PCHContainerOps, bool StoreInMemory,
PreambleCallbacks &Callbacks) {
assert(VFS && "VFS is null");
Expand Down Expand Up @@ -410,7 +411,7 @@ std::size_t PrecompiledPreamble::getSize() const {
bool PrecompiledPreamble::CanReuse(const CompilerInvocation &Invocation,
const llvm::MemoryBuffer *MainFileBuffer,
PreambleBounds Bounds,
vfs::FileSystem *VFS) const {
llvm::vfs::FileSystem *VFS) const {

assert(
Bounds.Size <= MainFileBuffer->getBufferSize() &&
Expand All @@ -437,7 +438,7 @@ bool PrecompiledPreamble::CanReuse(const CompilerInvocation &Invocation,
// remapping or unsaved_files.
std::map<llvm::sys::fs::UniqueID, PreambleFileHash> OverriddenFiles;
for (const auto &R : PreprocessorOpts.RemappedFiles) {
vfs::Status Status;
llvm::vfs::Status Status;
if (!moveOnNoError(VFS->status(R.second), Status)) {
// If we can't stat the file we're remapping to, assume that something
// horrible happened.
Expand All @@ -449,7 +450,7 @@ bool PrecompiledPreamble::CanReuse(const CompilerInvocation &Invocation,
}

for (const auto &RB : PreprocessorOpts.RemappedFileBuffers) {
vfs::Status Status;
llvm::vfs::Status Status;
if (!moveOnNoError(VFS->status(RB.first), Status))
return false;

Expand All @@ -459,7 +460,7 @@ bool PrecompiledPreamble::CanReuse(const CompilerInvocation &Invocation,

// Check whether anything has changed.
for (const auto &F : FilesInPreamble) {
vfs::Status Status;
llvm::vfs::Status Status;
if (!moveOnNoError(VFS->status(F.first()), Status)) {
// If we can't stat the file, assume that something horrible happened.
return false;
Expand All @@ -485,14 +486,14 @@ bool PrecompiledPreamble::CanReuse(const CompilerInvocation &Invocation,
}

void PrecompiledPreamble::AddImplicitPreamble(
CompilerInvocation &CI, IntrusiveRefCntPtr<vfs::FileSystem> &VFS,
CompilerInvocation &CI, IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS,
llvm::MemoryBuffer *MainFileBuffer) const {
PreambleBounds Bounds(PreambleBytes.size(), PreambleEndsAtStartOfLine);
configurePreamble(Bounds, CI, VFS, MainFileBuffer);
}

void PrecompiledPreamble::OverridePreamble(
CompilerInvocation &CI, IntrusiveRefCntPtr<vfs::FileSystem> &VFS,
CompilerInvocation &CI, IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS,
llvm::MemoryBuffer *MainFileBuffer) const {
auto Bounds = ComputePreambleBounds(*CI.getLangOpts(), MainFileBuffer, 0);
configurePreamble(Bounds, CI, VFS, MainFileBuffer);
Expand Down Expand Up @@ -680,7 +681,7 @@ PrecompiledPreamble::PreambleFileHash::createForMemoryBuffer(

void PrecompiledPreamble::configurePreamble(
PreambleBounds Bounds, CompilerInvocation &CI,
IntrusiveRefCntPtr<vfs::FileSystem> &VFS,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS,
llvm::MemoryBuffer *MainFileBuffer) const {
assert(VFS);

Expand All @@ -701,13 +702,14 @@ void PrecompiledPreamble::configurePreamble(

void PrecompiledPreamble::setupPreambleStorage(
const PCHStorage &Storage, PreprocessorOptions &PreprocessorOpts,
IntrusiveRefCntPtr<vfs::FileSystem> &VFS) {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS) {
if (Storage.getKind() == PCHStorage::Kind::TempFile) {
const TempPCHFile &PCHFile = Storage.asFile();
PreprocessorOpts.ImplicitPCHInclude = PCHFile.getFilePath();

// Make sure we can access the PCH file even if we're using a VFS
IntrusiveRefCntPtr<vfs::FileSystem> RealFS = vfs::getRealFileSystem();
IntrusiveRefCntPtr<llvm::vfs::FileSystem> RealFS =
llvm::vfs::getRealFileSystem();
auto PCHPath = PCHFile.getFilePath();
if (VFS == RealFS || VFS->exists(PCHPath))
return;
Expand Down
10 changes: 4 additions & 6 deletions clang/lib/Index/SimpleFormatContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ class SimpleFormatContext {
public:
SimpleFormatContext(LangOptions Options)
: DiagOpts(new DiagnosticOptions()),
Diagnostics(new DiagnosticsEngine(new DiagnosticIDs,
DiagOpts.get())),
InMemoryFileSystem(new vfs::InMemoryFileSystem),
Diagnostics(new DiagnosticsEngine(new DiagnosticIDs, DiagOpts.get())),
InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
Files(FileSystemOptions(), InMemoryFileSystem),
Sources(*Diagnostics, Files),
Rewrite(Sources, Options) {
Sources(*Diagnostics, Files), Rewrite(Sources, Options) {
Diagnostics->setClient(new IgnoringDiagConsumer, true);
}

Expand All @@ -63,7 +61,7 @@ class SimpleFormatContext {

IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics;
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem;
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem;
FileManager Files;
SourceManager Sources;
Rewriter Rewrite;
Expand Down
11 changes: 6 additions & 5 deletions clang/lib/Lex/HeaderSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/Module.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Lex/DirectoryLookup.h"
#include "clang/Lex/ExternalPreprocessorSource.h"
#include "clang/Lex/HeaderMap.h"
Expand All @@ -35,6 +34,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
Expand Down Expand Up @@ -1571,8 +1571,9 @@ void HeaderSearch::collectAllModules(SmallVectorImpl<Module *> &Modules) {
DirNative);

// Search each of the ".framework" directories to load them as modules.
vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
for (vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
llvm::vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
for (llvm::vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC),
DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
if (llvm::sys::path::extension(Dir->path()) != ".framework")
continue;
Expand Down Expand Up @@ -1639,8 +1640,8 @@ void HeaderSearch::loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir) {
std::error_code EC;
SmallString<128> DirNative;
llvm::sys::path::native(SearchDir.getDir()->getName(), DirNative);
vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
for (vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
llvm::vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
for (llvm::vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC), DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
bool IsFramework = llvm::sys::path::extension(Dir->path()) == ".framework";
if (IsFramework == SearchDir.isFramework())
Expand Down
14 changes: 8 additions & 6 deletions clang/lib/Lex/ModuleMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/LexDiagnostic.h"
Expand All @@ -43,6 +42,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
Expand Down Expand Up @@ -1020,9 +1020,10 @@ Module *ModuleMap::inferFrameworkModule(const DirectoryEntry *FrameworkDir,
= StringRef(FrameworkDir->getName());
llvm::sys::path::append(SubframeworksDirName, "Frameworks");
llvm::sys::path::native(SubframeworksDirName);
vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
for (vfs::directory_iterator Dir = FS.dir_begin(SubframeworksDirName, EC),
DirEnd;
llvm::vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
for (llvm::vfs::directory_iterator
Dir = FS.dir_begin(SubframeworksDirName, EC),
DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
if (!StringRef(Dir->path()).endswith(".framework"))
continue;
Expand Down Expand Up @@ -2394,8 +2395,9 @@ void ModuleMapParser::parseUmbrellaDirDecl(SourceLocation UmbrellaLoc) {
// uncommonly used Tcl module on Darwin platforms.
std::error_code EC;
SmallVector<Module::Header, 6> Headers;
vfs::FileSystem &FS = *SourceMgr.getFileManager().getVirtualFileSystem();
for (vfs::recursive_directory_iterator I(FS, Dir->getName(), EC), E;
llvm::vfs::FileSystem &FS =
*SourceMgr.getFileManager().getVirtualFileSystem();
for (llvm::vfs::recursive_directory_iterator I(FS, Dir->getName(), EC), E;
I != E && !EC; I.increment(EC)) {
if (const FileEntry *FE = SourceMgr.getFileManager().getFile(I->path())) {

Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Lex/PPLexerChange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,10 @@ void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {

ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap();
const DirectoryEntry *Dir = Mod.getUmbrellaDir().Entry;
vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
llvm::vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
std::error_code EC;
for (vfs::recursive_directory_iterator Entry(FS, Dir->getName(), EC), End;
for (llvm::vfs::recursive_directory_iterator Entry(FS, Dir->getName(), EC),
End;
Entry != End && !EC; Entry.increment(EC)) {
using llvm::StringSwitch;

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Lex/PTHLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,8 @@ class PTHStatCache : public FileSystemStatCache {
FL.getBase()) {}

LookupResult getStat(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F,
vfs::FileSystem &FS) override {
std::unique_ptr<llvm::vfs::File> *F,
llvm::vfs::FileSystem &FS) override {
// Do the lookup for the file's data in the PTH file.
CacheTy::iterator I = Cache.find(Path);

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaCodeComplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8152,7 +8152,7 @@ void Sema::CodeCompleteIncludedFile(llvm::StringRef Dir, bool Angled) {
std::error_code EC;
unsigned Count = 0;
for (auto It = FS->dir_begin(Dir, EC);
!EC && It != vfs::directory_iterator(); It.increment(EC)) {
!EC && It != llvm::vfs::directory_iterator(); It.increment(EC)) {
if (++Count == 2500) // If we happen to hit a huge directory,
break; // bail out early so we're not too slow.
StringRef Filename = llvm::sys::path::filename(It->path());
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Serialization/ModuleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "clang/Basic/FileManager.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/MemoryBufferCache.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Frontend/PCHContainerOperations.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/ModuleMap.h"
Expand All @@ -33,6 +32,7 @@
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <algorithm>
#include <cassert>
#include <memory>
Expand Down Expand Up @@ -150,7 +150,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,

if (NewModule->Kind == MK_ImplicitModule) {
std::string TimestampFilename = NewModule->getTimestampFilename();
vfs::Status Status;
llvm::vfs::Status Status;
// A cached stat value would be fine as well.
if (!FileMgr.getNoncachedStatValue(TimestampFilename, Status))
NewModule->InputFilesValidationTimestamp =
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Tooling/Core/Replacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Lex/Lexer.h"
#include "clang/Rewrite/Core/RewriteBuffer.h"
#include "clang/Rewrite/Core/Rewriter.h"
Expand All @@ -29,6 +28,7 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
Expand Down Expand Up @@ -583,8 +583,8 @@ llvm::Expected<std::string> applyAllReplacements(StringRef Code,
if (Replaces.empty())
return Code.str();

IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
DiagnosticsEngine Diagnostics(
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Tooling/StandaloneExecution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static ArgumentsAdjuster getDefaultArgumentsAdjusters() {
StandaloneToolExecutor::StandaloneToolExecutor(
const CompilationDatabase &Compilations,
llvm::ArrayRef<std::string> SourcePaths,
IntrusiveRefCntPtr<vfs::FileSystem> BaseFS,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS,
std::shared_ptr<PCHContainerOperations> PCHContainerOps)
: Tool(Compilations, SourcePaths, std::move(PCHContainerOps),
std::move(BaseFS)),
Expand Down
36 changes: 18 additions & 18 deletions clang/lib/Tooling/Tooling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Job.h"
Expand Down Expand Up @@ -51,6 +50,7 @@
#include "llvm/Support/Host.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstring>
Expand All @@ -74,9 +74,9 @@ FrontendActionFactory::~FrontendActionFactory() = default;
// it to be based on the same framework.

/// Builds a clang driver initialized for running clang tools.
static driver::Driver *newDriver(
DiagnosticsEngine *Diagnostics, const char *BinaryName,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
static driver::Driver *
newDriver(DiagnosticsEngine *Diagnostics, const char *BinaryName,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
driver::Driver *CompilerDriver =
new driver::Driver(BinaryName, llvm::sys::getDefaultTargetTriple(),
*Diagnostics, std::move(VFS));
Expand Down Expand Up @@ -155,7 +155,7 @@ namespace tooling {

bool runToolOnCodeWithArgs(
FrontendAction *ToolAction, const Twine &Code,
llvm::IntrusiveRefCntPtr<vfs::FileSystem> VFS,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
const std::vector<std::string> &Args, const Twine &FileName,
const Twine &ToolName,
std::shared_ptr<PCHContainerOperations> PCHContainerOps) {
Expand All @@ -178,10 +178,10 @@ bool runToolOnCodeWithArgs(
const Twine &ToolName,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
const FileContentMappings &VirtualMappedFiles) {
llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> OverlayFileSystem(
new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);
OverlayFileSystem->pushOverlay(InMemoryFileSystem);

SmallString<1024> CodeStorage;
Expand All @@ -199,7 +199,7 @@ bool runToolOnCodeWithArgs(
FileName, ToolName);
}

llvm::Expected<std::string> getAbsolutePath(vfs::FileSystem &FS,
llvm::Expected<std::string> getAbsolutePath(llvm::vfs::FileSystem &FS,
StringRef File) {
StringRef RelativePath(File);
// FIXME: Should '.\\' be accepted on Win32?
Expand All @@ -215,7 +215,7 @@ llvm::Expected<std::string> getAbsolutePath(vfs::FileSystem &FS,
}

std::string getAbsolutePath(StringRef File) {
return llvm::cantFail(getAbsolutePath(*vfs::getRealFileSystem(), File));
return llvm::cantFail(getAbsolutePath(*llvm::vfs::getRealFileSystem(), File));
}

void addTargetAndModeForProgramName(std::vector<std::string> &CommandLine,
Expand Down Expand Up @@ -372,11 +372,11 @@ bool FrontendActionFactory::runInvocation(
ClangTool::ClangTool(const CompilationDatabase &Compilations,
ArrayRef<std::string> SourcePaths,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
IntrusiveRefCntPtr<vfs::FileSystem> BaseFS)
IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS)
: Compilations(Compilations), SourcePaths(SourcePaths),
PCHContainerOps(std::move(PCHContainerOps)),
OverlayFileSystem(new vfs::OverlayFileSystem(std::move(BaseFS))),
InMemoryFileSystem(new vfs::InMemoryFileSystem),
OverlayFileSystem(new llvm::vfs::OverlayFileSystem(std::move(BaseFS))),
InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
Files(new FileManager(FileSystemOptions(), OverlayFileSystem)) {
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
appendArgumentsAdjuster(getClangStripOutputAdjuster());
Expand Down Expand Up @@ -586,10 +586,10 @@ std::unique_ptr<ASTUnit> buildASTFromCodeWithArgs(

std::vector<std::unique_ptr<ASTUnit>> ASTs;
ASTBuilderAction Action(ASTs);
llvm::IntrusiveRefCntPtr<vfs::OverlayFileSystem> OverlayFileSystem(
new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
llvm::IntrusiveRefCntPtr<FileManager> Files(
new FileManager(FileSystemOptions(), OverlayFileSystem));
Expand Down
10 changes: 5 additions & 5 deletions clang/tools/clang-format/ClangFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace format {

static FileID createInMemoryFile(StringRef FileName, MemoryBuffer *Source,
SourceManager &Sources, FileManager &Files,
vfs::InMemoryFileSystem *MemFS) {
llvm::vfs::InMemoryFileSystem *MemFS) {
MemFS->addFileNoOwn(FileName, 0, Source);
return Sources.createFileID(Files.getFile(FileName), SourceLocation(),
SrcMgr::C_User);
Expand All @@ -133,8 +133,8 @@ static bool parseLineRange(StringRef Input, unsigned &FromLine,

static bool fillRanges(MemoryBuffer *Code,
std::vector<tooling::Range> &Ranges) {
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
DiagnosticsEngine Diagnostics(
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
Expand Down Expand Up @@ -301,8 +301,8 @@ static bool format(StringRef FileName) {
outputReplacementsXML(Replaces);
outs() << "</replacements>\n";
} else {
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
DiagnosticsEngine Diagnostics(
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/driver/cc1gen_reproducer_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"

Expand Down
6 changes: 3 additions & 3 deletions clang/tools/libclang/BuildSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

#include "clang-c/BuildSystem.h"
#include "CXString.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/Chrono.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"

using namespace clang;
Expand All @@ -28,11 +28,11 @@ unsigned long long clang_getBuildSessionTimestamp(void) {
return llvm::sys::toTimeT(std::chrono::system_clock::now());
}

DEFINE_SIMPLE_CONVERSION_FUNCTIONS(clang::vfs::YAMLVFSWriter,
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(llvm::vfs::YAMLVFSWriter,
CXVirtualFileOverlay)

CXVirtualFileOverlay clang_VirtualFileOverlay_create(unsigned) {
return wrap(new clang::vfs::YAMLVFSWriter());
return wrap(new llvm::vfs::YAMLVFSWriter());
}

enum CXErrorCode
Expand Down
10 changes: 5 additions & 5 deletions clang/unittests/AST/ASTImporterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ createVirtualFileIfNeeded(ASTUnit *ToAST, StringRef FileName,
std::unique_ptr<llvm::MemoryBuffer> &&Buffer) {
assert(ToAST);
ASTContext &ToCtx = ToAST->getASTContext();
auto *OFS = static_cast<vfs::OverlayFileSystem *>(
auto *OFS = static_cast<llvm::vfs::OverlayFileSystem *>(
ToCtx.getSourceManager().getFileManager().getVirtualFileSystem().get());
auto *MFS =
static_cast<vfs::InMemoryFileSystem *>(OFS->overlays_begin()->get());
auto *MFS = static_cast<llvm::vfs::InMemoryFileSystem *>(
OFS->overlays_begin()->get());
MFS->addFile(FileName, 0, std::move(Buffer));
}

Expand Down Expand Up @@ -2482,7 +2482,7 @@ TEST_P(ImportFriendFunctions, ImportFriendChangesLookup) {
LookupRes = ToTU->noload_lookup(ToName);
EXPECT_EQ(LookupRes.size(), 1u);
EXPECT_EQ(DeclCounter<FunctionDecl>().match(ToTU, Pattern), 1u);

auto *ToFriendF = cast<FunctionDecl>(Import(FromFriendF, Lang_CXX));
LookupRes = ToTU->noload_lookup(ToName);
EXPECT_EQ(LookupRes.size(), 1u);
Expand Down Expand Up @@ -2758,7 +2758,7 @@ TEST_P(ASTImporterTestBase, ImportOfEquivalentRecord) {

ToR2 = Import(FromR, Lang_CXX);
}

EXPECT_EQ(ToR1, ToR2);
}

Expand Down
2 changes: 1 addition & 1 deletion clang/unittests/AST/CommentTextTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <gtest/gtest.h>

namespace clang {
Expand Down
1 change: 0 additions & 1 deletion clang/unittests/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ add_clang_unittest(BasicTests
FixedPointTest.cpp
MemoryBufferCacheTest.cpp
SourceManagerTest.cpp
VirtualFileSystemTest.cpp
)

target_link_libraries(BasicTests
Expand Down
10 changes: 5 additions & 5 deletions clang/unittests/Basic/FileManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/FileSystemStatCache.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "gtest/gtest.h"

using namespace llvm;
Expand Down Expand Up @@ -60,8 +60,8 @@ class FakeStatCache : public FileSystemStatCache {

// Implement FileSystemStatCache::getStat().
LookupResult getStat(StringRef Path, FileData &Data, bool isFile,
std::unique_ptr<vfs::File> *F,
vfs::FileSystem &FS) override {
std::unique_ptr<llvm::vfs::File> *F,
llvm::vfs::FileSystem &FS) override {
#ifndef _WIN32
SmallString<128> NormalizedPath(Path);
llvm::sys::path::native(NormalizedPath);
Expand Down Expand Up @@ -305,8 +305,8 @@ TEST_F(FileManagerTest, makeAbsoluteUsesVFS) {
#endif
llvm::sys::path::append(CustomWorkingDir, "some", "weird", "path");

auto FS =
IntrusiveRefCntPtr<vfs::InMemoryFileSystem>(new vfs::InMemoryFileSystem);
auto FS = IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>(
new llvm::vfs::InMemoryFileSystem);
// setCurrentworkingdirectory must finish without error.
ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir));

Expand Down
24 changes: 12 additions & 12 deletions clang/unittests/Driver/DistroTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//

#include "clang/Driver/Distro.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "gtest/gtest.h"
using namespace clang;
Expand All @@ -25,7 +25,7 @@ namespace {
// accidentally result in incorrect distribution guess.

TEST(DistroTest, DetectUbuntu) {
vfs::InMemoryFileSystem UbuntuTrustyFileSystem;
llvm::vfs::InMemoryFileSystem UbuntuTrustyFileSystem;
// Ubuntu uses Debian Sid version.
UbuntuTrustyFileSystem.addFile("/etc/debian_version", 0,
llvm::MemoryBuffer::getMemBuffer("jessie/sid\n"));
Expand All @@ -52,7 +52,7 @@ TEST(DistroTest, DetectUbuntu) {
ASSERT_FALSE(UbuntuTrusty.IsOpenSUSE());
ASSERT_FALSE(UbuntuTrusty.IsDebian());

vfs::InMemoryFileSystem UbuntuYakketyFileSystem;
llvm::vfs::InMemoryFileSystem UbuntuYakketyFileSystem;
UbuntuYakketyFileSystem.addFile("/etc/debian_version", 0,
llvm::MemoryBuffer::getMemBuffer("stretch/sid\n"));
UbuntuYakketyFileSystem.addFile("/etc/lsb-release", 0,
Expand Down Expand Up @@ -83,7 +83,7 @@ TEST(DistroTest, DetectUbuntu) {
}

TEST(DistroTest, DetectRedhat) {
vfs::InMemoryFileSystem Fedora25FileSystem;
llvm::vfs::InMemoryFileSystem Fedora25FileSystem;
Fedora25FileSystem.addFile("/etc/system-release-cpe", 0,
llvm::MemoryBuffer::getMemBuffer("cpe:/o:fedoraproject:fedora:25\n"));
// Both files are symlinks to fedora-release.
Expand Down Expand Up @@ -115,7 +115,7 @@ TEST(DistroTest, DetectRedhat) {
ASSERT_FALSE(Fedora25.IsOpenSUSE());
ASSERT_FALSE(Fedora25.IsDebian());

vfs::InMemoryFileSystem CentOS7FileSystem;
llvm::vfs::InMemoryFileSystem CentOS7FileSystem;
CentOS7FileSystem.addFile("/etc/system-release-cpe", 0,
llvm::MemoryBuffer::getMemBuffer("cpe:/o:centos:centos:7\n"));
// Both files are symlinks to centos-release.
Expand Down Expand Up @@ -153,7 +153,7 @@ TEST(DistroTest, DetectRedhat) {
}

TEST(DistroTest, DetectOpenSUSE) {
vfs::InMemoryFileSystem OpenSUSELeap421FileSystem;
llvm::vfs::InMemoryFileSystem OpenSUSELeap421FileSystem;
OpenSUSELeap421FileSystem.addFile("/etc/SuSE-release", 0,
llvm::MemoryBuffer::getMemBuffer("openSUSE 42.1 (x86_64)\n"
"VERSION = 42.1\n"
Expand All @@ -178,7 +178,7 @@ TEST(DistroTest, DetectOpenSUSE) {
ASSERT_TRUE(OpenSUSELeap421.IsOpenSUSE());
ASSERT_FALSE(OpenSUSELeap421.IsDebian());

vfs::InMemoryFileSystem OpenSUSE132FileSystem;
llvm::vfs::InMemoryFileSystem OpenSUSE132FileSystem;
OpenSUSE132FileSystem.addFile("/etc/SuSE-release", 0,
llvm::MemoryBuffer::getMemBuffer("openSUSE 13.2 (x86_64)\n"
"VERSION = 13.2\n"
Expand All @@ -203,7 +203,7 @@ TEST(DistroTest, DetectOpenSUSE) {
ASSERT_TRUE(OpenSUSE132.IsOpenSUSE());
ASSERT_FALSE(OpenSUSE132.IsDebian());

vfs::InMemoryFileSystem SLES10FileSystem;
llvm::vfs::InMemoryFileSystem SLES10FileSystem;
SLES10FileSystem.addFile("/etc/SuSE-release", 0,
llvm::MemoryBuffer::getMemBuffer("SUSE Linux Enterprise Server 10 (x86_64)\n"
"VERSION = 10\n"
Expand All @@ -221,7 +221,7 @@ TEST(DistroTest, DetectOpenSUSE) {
}

TEST(DistroTest, DetectDebian) {
vfs::InMemoryFileSystem DebianJessieFileSystem;
llvm::vfs::InMemoryFileSystem DebianJessieFileSystem;
DebianJessieFileSystem.addFile("/etc/debian_version", 0,
llvm::MemoryBuffer::getMemBuffer("8.6\n"));
DebianJessieFileSystem.addFile("/etc/os-release", 0,
Expand All @@ -241,7 +241,7 @@ TEST(DistroTest, DetectDebian) {
ASSERT_FALSE(DebianJessie.IsOpenSUSE());
ASSERT_TRUE(DebianJessie.IsDebian());

vfs::InMemoryFileSystem DebianStretchSidFileSystem;
llvm::vfs::InMemoryFileSystem DebianStretchSidFileSystem;
DebianStretchSidFileSystem.addFile("/etc/debian_version", 0,
llvm::MemoryBuffer::getMemBuffer("stretch/sid\n"));
DebianStretchSidFileSystem.addFile("/etc/os-release", 0,
Expand All @@ -261,7 +261,7 @@ TEST(DistroTest, DetectDebian) {
}

TEST(DistroTest, DetectExherbo) {
vfs::InMemoryFileSystem ExherboFileSystem;
llvm::vfs::InMemoryFileSystem ExherboFileSystem;
ExherboFileSystem.addFile("/etc/exherbo-release", 0, // (ASCII art)
llvm::MemoryBuffer::getMemBuffer(""));
ExherboFileSystem.addFile("/etc/os-release", 0,
Expand All @@ -282,7 +282,7 @@ TEST(DistroTest, DetectExherbo) {
}

TEST(DistroTest, DetectArchLinux) {
vfs::InMemoryFileSystem ArchLinuxFileSystem;
llvm::vfs::InMemoryFileSystem ArchLinuxFileSystem;
ArchLinuxFileSystem.addFile("/etc/arch-release", 0, // (empty)
llvm::MemoryBuffer::getMemBuffer(""));
ArchLinuxFileSystem.addFile("/etc/os-release", 0,
Expand Down
14 changes: 7 additions & 7 deletions clang/unittests/Driver/ToolChainTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
#include "clang/Basic/DiagnosticIDs.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "gtest/gtest.h"
using namespace clang;
Expand All @@ -33,8 +33,8 @@ TEST(ToolChainTest, VFSGCCInstallation) {
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);
Driver TheDriver("/bin/clang", "arm-linux-gnueabihf", Diags,
InMemoryFileSystem);

Expand Down Expand Up @@ -87,8 +87,8 @@ TEST(ToolChainTest, VFSGCCInstallationRelativeDir) {
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);
Driver TheDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
InMemoryFileSystem);

Expand Down Expand Up @@ -127,8 +127,8 @@ TEST(ToolChainTest, DefaultDriverMode) {
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem(
new vfs::InMemoryFileSystem);
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);

Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
InMemoryFileSystem);
Expand Down
4 changes: 2 additions & 2 deletions clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12375,14 +12375,14 @@ TEST_F(FormatTest, NoSpaceAfterSuper) {
}

TEST(FormatStyle, GetStyleWithEmptyFileName) {
vfs::InMemoryFileSystem FS;
llvm::vfs::InMemoryFileSystem FS;
auto Style1 = getStyle("file", "", "Google", "", &FS);
ASSERT_TRUE((bool)Style1);
ASSERT_EQ(*Style1, getGoogleStyle());
}

TEST(FormatStyle, GetStyleOfFile) {
vfs::InMemoryFileSystem FS;
llvm::vfs::InMemoryFileSystem FS;
// Test 1: format file in the same directory.
ASSERT_TRUE(
FS.addFile("/a/.clang-format", 0,
Expand Down
2 changes: 1 addition & 1 deletion clang/unittests/Index/IndexTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "clang/AST/ASTConsumer.h"
#include "clang/AST/Decl.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Index/IndexDataConsumer.h"
Expand All @@ -18,6 +17,7 @@
#include "clang/Lex/Preprocessor.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <memory>
Expand Down
4 changes: 2 additions & 2 deletions clang/unittests/Lex/HeaderSearchTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace {
class HeaderSearchTest : public ::testing::Test {
protected:
HeaderSearchTest()
: VFS(new vfs::InMemoryFileSystem), FileMgr(FileMgrOpts, VFS),
: VFS(new llvm::vfs::InMemoryFileSystem), FileMgr(FileMgrOpts, VFS),
DiagID(new DiagnosticIDs()),
Diags(DiagID, new DiagnosticOptions, new IgnoringDiagConsumer()),
SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions),
Expand All @@ -46,7 +46,7 @@ class HeaderSearchTest : public ::testing::Test {
Search.AddSearchPath(DL, /*isAngled=*/false);
}

IntrusiveRefCntPtr<vfs::InMemoryFileSystem> VFS;
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS;
FileSystemOptions FileMgrOpts;
FileManager FileMgr;
IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
Expand Down
42 changes: 21 additions & 21 deletions clang/unittests/Lex/PPCallbacksTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class PragmaOpenCLExtensionCallbacks : public PPCallbacks {
class PPCallbacksTest : public ::testing::Test {
protected:
PPCallbacksTest()
: InMemoryFileSystem(new vfs::InMemoryFileSystem),
: InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
FileMgr(FileSystemOptions(), InMemoryFileSystem),
DiagID(new DiagnosticIDs()), DiagOpts(new DiagnosticOptions()),
Diags(DiagID, DiagOpts.get(), new IgnoringDiagConsumer()),
Expand All @@ -104,7 +104,7 @@ class PPCallbacksTest : public ::testing::Test {
Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts);
}

IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem;
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem;
FileManager FileMgr;
IntrusiveRefCntPtr<DiagnosticIDs> DiagID;
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
Expand All @@ -116,17 +116,17 @@ class PPCallbacksTest : public ::testing::Test {

// Register a header path as a known file and add its location
// to search path.
void AddFakeHeader(HeaderSearch& HeaderInfo, const char* HeaderPath,
bool IsSystemHeader) {
// Tell FileMgr about header.
InMemoryFileSystem->addFile(HeaderPath, 0,
llvm::MemoryBuffer::getMemBuffer("\n"));

// Add header's parent path to search path.
StringRef SearchPath = llvm::sys::path::parent_path(HeaderPath);
const DirectoryEntry *DE = FileMgr.getDirectory(SearchPath);
DirectoryLookup DL(DE, SrcMgr::C_User, false);
HeaderInfo.AddSearchPath(DL, IsSystemHeader);
void AddFakeHeader(HeaderSearch &HeaderInfo, const char *HeaderPath,
bool IsSystemHeader) {
// Tell FileMgr about header.
InMemoryFileSystem->addFile(HeaderPath, 0,
llvm::MemoryBuffer::getMemBuffer("\n"));

// Add header's parent path to search path.
StringRef SearchPath = llvm::sys::path::parent_path(HeaderPath);
const DirectoryEntry *DE = FileMgr.getDirectory(SearchPath);
DirectoryLookup DL(DE, SrcMgr::C_User, false);
HeaderInfo.AddSearchPath(DL, IsSystemHeader);
}

// Get the raw source string of the range.
Expand All @@ -139,8 +139,9 @@ class PPCallbacksTest : public ::testing::Test {

// Run lexer over SourceText and collect FilenameRange from
// the InclusionDirective callback.
CharSourceRange InclusionDirectiveFilenameRange(const char* SourceText,
const char* HeaderPath, bool SystemHeader) {
CharSourceRange InclusionDirectiveFilenameRange(const char *SourceText,
const char *HeaderPath,
bool SystemHeader) {
std::unique_ptr<llvm::MemoryBuffer> Buf =
llvm::MemoryBuffer::getMemBuffer(SourceText);
SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
Expand Down Expand Up @@ -198,8 +199,8 @@ class PPCallbacksTest : public ::testing::Test {
return Callbacks;
}

PragmaOpenCLExtensionCallbacks::CallbackParameters
PragmaOpenCLExtensionCall(const char* SourceText) {
PragmaOpenCLExtensionCallbacks::CallbackParameters
PragmaOpenCLExtensionCall(const char *SourceText) {
LangOptions OpenCLLangOpts;
OpenCLLangOpts.OpenCL = 1;

Expand All @@ -221,9 +222,8 @@ class PPCallbacksTest : public ::testing::Test {
// parser actually sets correct pragma handlers for preprocessor
// according to LangOptions, so we init Parser to register opencl
// pragma handlers
ASTContext Context(OpenCLLangOpts, SourceMgr,
PP.getIdentifierTable(), PP.getSelectorTable(),
PP.getBuiltinInfo());
ASTContext Context(OpenCLLangOpts, SourceMgr, PP.getIdentifierTable(),
PP.getSelectorTable(), PP.getBuiltinInfo());
Context.InitBuiltinTypes(*Target);

ASTConsumer Consumer;
Expand All @@ -245,7 +245,7 @@ class PPCallbacksTest : public ::testing::Test {
Callbacks->Name,
Callbacks->State
};
return RetVal;
return RetVal;
}
};

Expand Down
2 changes: 1 addition & 1 deletion clang/unittests/Rename/ClangRenameTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Format/Format.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/PCHContainerOperations.h"
Expand All @@ -26,6 +25,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "gtest/gtest.h"
#include <memory>
#include <string>
Expand Down
Loading