From fc51490baf1d6ad5796d8cb8bb0792de13ce8fce Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 10 Oct 2018 13:27:25 +0000 Subject: [PATCH] Lift VFS from clang to llvm (NFC) This patch moves the virtual file system form clang to llvm so it can be used by more projects. Concretely the patch: - Moves VirtualFileSystem.{h|cpp} from clang/Basic to llvm/Support. - Moves the corresponding unit test from clang to llvm. - Moves the vfs namespace from clang::vfs to llvm::vfs. - Formats the lines affected by this change, mostly this is the result of the added llvm namespace. RFC on the mailing list: http://lists.llvm.org/pipermail/llvm-dev/2018-October/126657.html Differential revision: https://reviews.llvm.org/D52783 llvm-svn: 344140 --- clang-tools-extra/clang-tidy/ClangTidy.cpp | 8 +- clang-tools-extra/clang-tidy/ClangTidy.h | 4 +- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp | 4 +- clang-tools-extra/clang-tidy/ClangTidyOptions.h | 15 +- clang-tools-extra/clangd/ClangdUnit.cpp | 2 +- clang-tools-extra/clangd/ClangdUnit.h | 12 +- clang-tools-extra/clangd/CodeComplete.cpp | 8 +- clang-tools-extra/clangd/CodeComplete.h | 4 +- clang-tools-extra/clangd/Compiler.cpp | 2 +- clang-tools-extra/clangd/Compiler.h | 6 +- clang-tools-extra/clangd/FS.cpp | 31 +- clang-tools-extra/clangd/FS.h | 17 +- clang-tools-extra/clangd/FSProvider.h | 8 +- clang-tools-extra/clangd/Headers.h | 2 +- .../change-namespace/ChangeNamespaceTests.cpp | 2 +- .../unittests/clang-tidy/ClangTidyTest.h | 4 +- clang-tools-extra/unittests/clangd/ClangdTests.cpp | 12 +- clang-tools-extra/unittests/clangd/FSTests.cpp | 7 +- .../unittests/clangd/SymbolCollectorTests.cpp | 6 +- clang-tools-extra/unittests/clangd/TestFS.h | 6 +- .../unittests/include-fixer/IncludeFixerTest.cpp | 4 +- .../find-all-symbols/FindAllSymbolsTests.cpp | 6 +- clang/include/clang/Basic/FileManager.h | 18 +- clang/include/clang/Basic/FileSystemStatCache.h | 20 +- clang/include/clang/Driver/Distro.h | 4 +- clang/include/clang/Driver/Driver.h | 13 +- clang/include/clang/Driver/ToolChain.h | 13 +- clang/include/clang/Format/Format.h | 12 +- clang/include/clang/Frontend/ASTUnit.h | 48 ++-- clang/include/clang/Frontend/CompilerInstance.h | 6 +- clang/include/clang/Frontend/CompilerInvocation.h | 21 +- clang/include/clang/Frontend/PrecompiledPreamble.h | 23 +- clang/include/clang/Frontend/Utils.h | 8 +- clang/include/clang/Tooling/StandaloneExecution.h | 3 +- clang/include/clang/Tooling/Tooling.h | 14 +- clang/lib/Basic/CMakeLists.txt | 1 - clang/lib/Basic/FileManager.cpp | 12 +- clang/lib/Basic/FileSystemStatCache.cpp | 16 +- clang/lib/Basic/SourceManager.cpp | 4 +- clang/lib/Driver/Distro.cpp | 5 +- clang/lib/Driver/Driver.cpp | 6 +- clang/lib/Driver/ToolChain.cpp | 6 +- clang/lib/Driver/ToolChains/BareMetal.cpp | 7 +- clang/lib/Driver/ToolChains/CommonArgs.cpp | 4 +- clang/lib/Driver/ToolChains/Cuda.cpp | 2 +- clang/lib/Driver/ToolChains/Darwin.cpp | 2 +- clang/lib/Driver/ToolChains/FreeBSD.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 13 +- clang/lib/Driver/ToolChains/Hexagon.cpp | 4 +- clang/lib/Driver/ToolChains/Linux.cpp | 2 +- clang/lib/Driver/ToolChains/Minix.cpp | 4 +- clang/lib/Format/Format.cpp | 7 +- clang/lib/Frontend/ASTUnit.cpp | 26 +- clang/lib/Frontend/CacheTokens.cpp | 4 +- clang/lib/Frontend/CompilerInstance.cpp | 12 +- clang/lib/Frontend/CompilerInvocation.cpp | 20 +- .../Frontend/CreateInvocationFromCommandLine.cpp | 2 +- clang/lib/Frontend/FrontendAction.cpp | 9 +- clang/lib/Frontend/PrecompiledPreamble.cpp | 36 +-- clang/lib/Index/SimpleFormatContext.h | 10 +- clang/lib/Lex/HeaderSearch.cpp | 11 +- clang/lib/Lex/ModuleMap.cpp | 14 +- clang/lib/Lex/PPLexerChange.cpp | 5 +- clang/lib/Lex/PTHLexer.cpp | 4 +- clang/lib/Sema/SemaCodeComplete.cpp | 2 +- clang/lib/Serialization/ModuleManager.cpp | 4 +- clang/lib/Tooling/Core/Replacement.cpp | 6 +- clang/lib/Tooling/StandaloneExecution.cpp | 2 +- clang/lib/Tooling/Tooling.cpp | 36 +-- clang/tools/clang-format/ClangFormat.cpp | 10 +- clang/tools/driver/cc1gen_reproducer_main.cpp | 2 +- clang/tools/libclang/BuildSystem.cpp | 6 +- clang/unittests/AST/ASTImporterTest.cpp | 10 +- clang/unittests/AST/CommentTextTest.cpp | 2 +- clang/unittests/Basic/CMakeLists.txt | 1 - clang/unittests/Basic/FileManagerTest.cpp | 10 +- clang/unittests/Driver/DistroTest.cpp | 24 +- clang/unittests/Driver/ToolChainTest.cpp | 14 +- clang/unittests/Format/FormatTest.cpp | 4 +- clang/unittests/Index/IndexTests.cpp | 2 +- clang/unittests/Lex/HeaderSearchTest.cpp | 4 +- clang/unittests/Lex/PPCallbacksTest.cpp | 42 +-- clang/unittests/Rename/ClangRenameTest.h | 2 +- clang/unittests/Tooling/RefactoringTest.cpp | 16 +- clang/unittests/Tooling/RewriterTestContext.h | 16 +- clang/unittests/Tooling/ToolingTest.cpp | 24 +- .../include/llvm/Support}/VirtualFileSystem.h | 29 +- llvm/lib/Support/CMakeLists.txt | 1 + .../lib/Support}/VirtualFileSystem.cpp | 131 ++++----- llvm/unittests/Support/CMakeLists.txt | 1 + .../unittests/Support}/VirtualFileSystemTest.cpp | 311 +++++++++++---------- 91 files changed, 670 insertions(+), 665 deletions(-) rename {clang/include/clang/Basic => llvm/include/llvm/Support}/VirtualFileSystem.h (96%) rename {clang/lib/Basic => llvm/lib/Support}/VirtualFileSystem.cpp (96%) rename {clang/unittests/Basic => llvm/unittests/Support}/VirtualFileSystemTest.cpp (89%) diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp index 729371f..9ab85b6 100644 --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -96,7 +96,7 @@ private: class ErrorReporter { public: ErrorReporter(ClangTidyContext &Context, bool ApplyFixes, - llvm::IntrusiveRefCntPtr BaseFS) + llvm::IntrusiveRefCntPtr BaseFS) : Files(FileSystemOptions(), BaseFS), DiagOpts(new DiagnosticOptions()), DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)), Diags(IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts, @@ -503,7 +503,7 @@ getCheckOptions(const ClangTidyOptions &Options, void runClangTidy(clang::tidy::ClangTidyContext &Context, const CompilationDatabase &Compilations, ArrayRef InputFiles, - llvm::IntrusiveRefCntPtr BaseFS, + llvm::IntrusiveRefCntPtr BaseFS, bool EnableCheckProfile, llvm::StringRef StoreCheckProfile) { ClangTool Tool(Compilations, InputFiles, std::make_shared(), BaseFS); @@ -590,9 +590,9 @@ void runClangTidy(clang::tidy::ClangTidyContext &Context, void handleErrors(ClangTidyContext &Context, bool Fix, unsigned &WarningsAsErrorsCount, - llvm::IntrusiveRefCntPtr BaseFS) { + llvm::IntrusiveRefCntPtr BaseFS) { ErrorReporter Reporter(Context, Fix, BaseFS); - vfs::FileSystem &FileSystem = + llvm::vfs::FileSystem &FileSystem = *Reporter.getSourceManager().getFileManager().getVirtualFileSystem(); auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory(); if (!InitialWorkingDir) diff --git a/clang-tools-extra/clang-tidy/ClangTidy.h b/clang-tools-extra/clang-tidy/ClangTidy.h index 0ea9a701..031a7a2 100644 --- a/clang-tools-extra/clang-tidy/ClangTidy.h +++ b/clang-tools-extra/clang-tidy/ClangTidy.h @@ -233,7 +233,7 @@ getCheckOptions(const ClangTidyOptions &Options, void runClangTidy(clang::tidy::ClangTidyContext &Context, const tooling::CompilationDatabase &Compilations, ArrayRef InputFiles, - llvm::IntrusiveRefCntPtr BaseFS, + llvm::IntrusiveRefCntPtr BaseFS, bool EnableCheckProfile = false, llvm::StringRef StoreCheckProfile = StringRef()); @@ -245,7 +245,7 @@ void runClangTidy(clang::tidy::ClangTidyContext &Context, /// clang-format configuration file is found, the given \P FormatStyle is used. void handleErrors(ClangTidyContext &Context, bool Fix, unsigned &WarningsAsErrorsCount, - llvm::IntrusiveRefCntPtr BaseFS); + llvm::IntrusiveRefCntPtr BaseFS); /// \brief Serializes replacements into YAML and writes them to the specified /// output stream. diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp index 430f8b3..c40e97c 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp @@ -204,11 +204,11 @@ FileOptionsProvider::FileOptionsProvider( const ClangTidyGlobalOptions &GlobalOptions, const ClangTidyOptions &DefaultOptions, const ClangTidyOptions &OverrideOptions, - llvm::IntrusiveRefCntPtr VFS) + llvm::IntrusiveRefCntPtr VFS) : DefaultOptionsProvider(GlobalOptions, DefaultOptions), OverrideOptions(OverrideOptions), FS(std::move(VFS)) { if (!FS) - FS = vfs::getRealFileSystem(); + FS = llvm::vfs::getRealFileSystem(); ConfigHandlers.emplace_back(".clang-tidy", parseConfiguration); } diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h b/clang-tools-extra/clang-tidy/ClangTidyOptions.h index b2a4ce4..1a75354 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h +++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h @@ -10,12 +10,12 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H +#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" -#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/Support/ErrorOr.h" -#include "clang/Basic/VirtualFileSystem.h" +#include "llvm/Support/VirtualFileSystem.h" #include #include #include @@ -218,10 +218,11 @@ public: /// /// If any of the \param OverrideOptions fields are set, they will override /// whatever options are read from the configuration file. - FileOptionsProvider(const ClangTidyGlobalOptions &GlobalOptions, - const ClangTidyOptions &DefaultOptions, - const ClangTidyOptions &OverrideOptions, - llvm::IntrusiveRefCntPtr FS = nullptr); + FileOptionsProvider( + const ClangTidyGlobalOptions &GlobalOptions, + const ClangTidyOptions &DefaultOptions, + const ClangTidyOptions &OverrideOptions, + llvm::IntrusiveRefCntPtr FS = nullptr); /// \brief Initializes the \c FileOptionsProvider instance with a custom set /// of configuration file handlers. @@ -255,7 +256,7 @@ protected: llvm::StringMap CachedOptions; ClangTidyOptions OverrideOptions; ConfigFileHandlers ConfigHandlers; - llvm::IntrusiveRefCntPtr FS; + llvm::IntrusiveRefCntPtr FS; }; /// \brief Parses LineFilter from JSON and stores it to the \p Options. diff --git a/clang-tools-extra/clangd/ClangdUnit.cpp b/clang-tools-extra/clangd/ClangdUnit.cpp index 4cc6ef6..85c7fd8 100644 --- a/clang-tools-extra/clangd/ClangdUnit.cpp +++ b/clang-tools-extra/clangd/ClangdUnit.cpp @@ -126,7 +126,7 @@ ParsedAST::build(std::unique_ptr CI, std::shared_ptr Preamble, std::unique_ptr Buffer, std::shared_ptr PCHs, - IntrusiveRefCntPtr VFS) { + IntrusiveRefCntPtr VFS) { assert(CI); // Command-line parsing sets DisableFree to true by default, but we don't want // to leak memory in clangd. diff --git a/clang-tools-extra/clangd/ClangdUnit.h b/clang-tools-extra/clangd/ClangdUnit.h index 184a7a6..15bf998 100644 --- a/clang-tools-extra/clangd/ClangdUnit.h +++ b/clang-tools-extra/clangd/ClangdUnit.h @@ -28,14 +28,14 @@ namespace llvm { class raw_ostream; -} - -namespace clang { -class PCHContainerOperations; namespace vfs { class FileSystem; } +} // namespace llvm + +namespace clang { +class PCHContainerOperations; namespace tooling { struct CompileCommand; @@ -63,7 +63,7 @@ struct PreambleData { /// Information required to run clang, e.g. to parse AST or do code completion. struct ParseInputs { tooling::CompileCommand CompileCommand; - IntrusiveRefCntPtr FS; + IntrusiveRefCntPtr FS; std::string Contents; }; @@ -77,7 +77,7 @@ public: std::shared_ptr Preamble, std::unique_ptr Buffer, std::shared_ptr PCHs, - IntrusiveRefCntPtr VFS); + IntrusiveRefCntPtr VFS); ParsedAST(ParsedAST &&Other); ParsedAST &operator=(ParsedAST &&Other); diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp index 9c634f5..92018b1 100644 --- a/clang-tools-extra/clangd/CodeComplete.cpp +++ b/clang-tools-extra/clangd/CodeComplete.cpp @@ -986,7 +986,7 @@ struct SemaCompleteInput { const PreambleData *Preamble; StringRef Contents; Position Pos; - IntrusiveRefCntPtr VFS; + IntrusiveRefCntPtr VFS; std::shared_ptr PCHs; }; @@ -1007,7 +1007,7 @@ bool semaCodeComplete(std::unique_ptr Consumer, // working dirs. } - IntrusiveRefCntPtr VFS = Input.VFS; + IntrusiveRefCntPtr VFS = Input.VFS; if (Input.Preamble && Input.Preamble->StatCache) VFS = Input.Preamble->StatCache->getConsumingFS(std::move(VFS)); IgnoreDiagnostics DummyDiagsConsumer; @@ -1567,7 +1567,7 @@ speculateCompletionFilter(llvm::StringRef Content, Position Pos) { CodeCompleteResult codeComplete(PathRef FileName, const tooling::CompileCommand &Command, const PreambleData *Preamble, StringRef Contents, Position Pos, - IntrusiveRefCntPtr VFS, + IntrusiveRefCntPtr VFS, std::shared_ptr PCHs, CodeCompleteOptions Opts, SpeculativeFuzzyFind *SpecFuzzyFind) { return CodeCompleteFlow(FileName, @@ -1580,7 +1580,7 @@ SignatureHelp signatureHelp(PathRef FileName, const tooling::CompileCommand &Command, const PreambleData *Preamble, StringRef Contents, Position Pos, - IntrusiveRefCntPtr VFS, + IntrusiveRefCntPtr VFS, std::shared_ptr PCHs, const SymbolIndex *Index) { SignatureHelp Result; diff --git a/clang-tools-extra/clangd/CodeComplete.h b/clang-tools-extra/clangd/CodeComplete.h index d0c8a70..4d32414 100644 --- a/clang-tools-extra/clangd/CodeComplete.h +++ b/clang-tools-extra/clangd/CodeComplete.h @@ -224,7 +224,7 @@ CodeCompleteResult codeComplete(PathRef FileName, const tooling::CompileCommand &Command, const PreambleData *Preamble, StringRef Contents, Position Pos, - IntrusiveRefCntPtr VFS, + IntrusiveRefCntPtr VFS, std::shared_ptr PCHs, CodeCompleteOptions Opts, SpeculativeFuzzyFind *SpecFuzzyFind = nullptr); @@ -234,7 +234,7 @@ SignatureHelp signatureHelp(PathRef FileName, const tooling::CompileCommand &Command, const PreambleData *Preamble, StringRef Contents, Position Pos, - IntrusiveRefCntPtr VFS, + IntrusiveRefCntPtr VFS, std::shared_ptr PCHs, const SymbolIndex *Index); diff --git a/clang-tools-extra/clangd/Compiler.cpp b/clang-tools-extra/clangd/Compiler.cpp index 9c7a59b..27967f9 100644 --- a/clang-tools-extra/clangd/Compiler.cpp +++ b/clang-tools-extra/clangd/Compiler.cpp @@ -44,7 +44,7 @@ prepareCompilerInstance(std::unique_ptr CI, const PrecompiledPreamble *Preamble, std::unique_ptr Buffer, std::shared_ptr PCHs, - IntrusiveRefCntPtr VFS, + IntrusiveRefCntPtr VFS, DiagnosticConsumer &DiagsClient) { assert(VFS && "VFS is null"); assert(!CI->getPreprocessorOpts().RetainRemappedFileBuffers && diff --git a/clang-tools-extra/clangd/Compiler.h b/clang-tools-extra/clangd/Compiler.h index 49c1c90..7a3c43d 100644 --- a/clang-tools-extra/clangd/Compiler.h +++ b/clang-tools-extra/clangd/Compiler.h @@ -37,8 +37,8 @@ public: /// - Preamble is overriden to use PCH passed to this function. It means the /// changes to the preamble headers or files included in the preamble are /// not visible to this compiler instance. -/// - vfs::FileSystem is used for all underlying file accesses. The actual -/// vfs used by the compiler may be an overlay over the passed vfs. +/// - llvm::vfs::FileSystem is used for all underlying file accesses. The +/// actual vfs used by the compiler may be an overlay over the passed vfs. /// Returns null on errors. When non-null value is returned, it is expected to /// be consumed by FrontendAction::BeginSourceFile to properly destroy \p /// MainFile. @@ -46,7 +46,7 @@ std::unique_ptr prepareCompilerInstance( std::unique_ptr, const PrecompiledPreamble *, std::unique_ptr MainFile, std::shared_ptr, - IntrusiveRefCntPtr, DiagnosticConsumer &); + IntrusiveRefCntPtr, DiagnosticConsumer &); } // namespace clangd } // namespace clang diff --git a/clang-tools-extra/clangd/FS.cpp b/clang-tools-extra/clangd/FS.cpp index fa94b96..5f5dd5c 100644 --- a/clang-tools-extra/clangd/FS.cpp +++ b/clang-tools-extra/clangd/FS.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// #include "FS.h" -#include "clang/Basic/VirtualFileSystem.h" +#include "clang/Basic/LLVM.h" #include "llvm/ADT/None.h" #include "llvm/Support/Path.h" @@ -20,7 +20,8 @@ PreambleFileStatusCache::PreambleFileStatusCache(llvm::StringRef MainFilePath) assert(llvm::sys::path::is_absolute(MainFilePath)); } -void PreambleFileStatusCache::update(const vfs::FileSystem &FS, vfs::Status S) { +void PreambleFileStatusCache::update(const llvm::vfs::FileSystem &FS, + llvm::vfs::Status S) { SmallString<32> PathStore(S.getName()); if (FS.makeAbsolute(PathStore)) return; @@ -31,7 +32,7 @@ void PreambleFileStatusCache::update(const vfs::FileSystem &FS, vfs::Status S) { StatCache.insert({PathStore, std::move(S)}); } -llvm::Optional +llvm::Optional PreambleFileStatusCache::lookup(llvm::StringRef File) const { auto I = StatCache.find(File); if (I != StatCache.end()) @@ -39,17 +40,18 @@ PreambleFileStatusCache::lookup(llvm::StringRef File) const { return llvm::None; } -IntrusiveRefCntPtr PreambleFileStatusCache::getProducingFS( - IntrusiveRefCntPtr FS) { +IntrusiveRefCntPtr +PreambleFileStatusCache::getProducingFS( + IntrusiveRefCntPtr FS) { // This invalidates old status in cache if files are re-`open()`ed or // re-`stat()`ed in case file status has changed during preamble build. - class CollectFS : public vfs::ProxyFileSystem { + class CollectFS : public llvm::vfs::ProxyFileSystem { public: - CollectFS(IntrusiveRefCntPtr FS, + CollectFS(IntrusiveRefCntPtr FS, PreambleFileStatusCache &StatCache) : ProxyFileSystem(std::move(FS)), StatCache(StatCache) {} - llvm::ErrorOr> + llvm::ErrorOr> openFileForRead(const Twine &Path) override { auto File = getUnderlyingFS().openFileForRead(Path); if (!File || !*File) @@ -64,7 +66,7 @@ IntrusiveRefCntPtr PreambleFileStatusCache::getProducingFS( return File; } - llvm::ErrorOr status(const Twine &Path) override { + llvm::ErrorOr status(const Twine &Path) override { auto S = getUnderlyingFS().status(Path); if (S) StatCache.update(getUnderlyingFS(), *S); @@ -77,15 +79,16 @@ IntrusiveRefCntPtr PreambleFileStatusCache::getProducingFS( return IntrusiveRefCntPtr(new CollectFS(std::move(FS), *this)); } -IntrusiveRefCntPtr PreambleFileStatusCache::getConsumingFS( - IntrusiveRefCntPtr FS) const { - class CacheVFS : public vfs::ProxyFileSystem { +IntrusiveRefCntPtr +PreambleFileStatusCache::getConsumingFS( + IntrusiveRefCntPtr FS) const { + class CacheVFS : public llvm::vfs::ProxyFileSystem { public: - CacheVFS(IntrusiveRefCntPtr FS, + CacheVFS(IntrusiveRefCntPtr FS, const PreambleFileStatusCache &StatCache) : ProxyFileSystem(std::move(FS)), StatCache(StatCache) {} - llvm::ErrorOr status(const Twine &Path) override { + llvm::ErrorOr status(const Twine &Path) override { if (auto S = StatCache.lookup(Path.str())) return *S; return getUnderlyingFS().status(Path); diff --git a/clang-tools-extra/clangd/FS.h b/clang-tools-extra/clangd/FS.h index 33a8ac9..d400304 100644 --- a/clang-tools-extra/clangd/FS.h +++ b/clang-tools-extra/clangd/FS.h @@ -10,8 +10,9 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_H -#include "clang/Basic/VirtualFileSystem.h" +#include "clang/Basic/LLVM.h" #include "llvm/ADT/Optional.h" +#include "llvm/Support/VirtualFileSystem.h" namespace clang { namespace clangd { @@ -39,10 +40,10 @@ public: /// corresponds to. The stat for the main file will not be cached. PreambleFileStatusCache(llvm::StringRef MainFilePath); - void update(const vfs::FileSystem &FS, vfs::Status S); + void update(const llvm::vfs::FileSystem &FS, llvm::vfs::Status S); /// \p Path is a path stored in preamble. - llvm::Optional lookup(llvm::StringRef Path) const; + llvm::Optional lookup(llvm::StringRef Path) const; /// Returns a VFS that collects file status. /// Only cache stats for files that exist because @@ -51,18 +52,18 @@ public: /// 2) we use the file name in the Status as the cache key. /// /// Note that the returned VFS should not outlive the cache. - IntrusiveRefCntPtr - getProducingFS(IntrusiveRefCntPtr FS); + IntrusiveRefCntPtr + getProducingFS(IntrusiveRefCntPtr FS); /// Returns a VFS that uses the cache collected. /// /// Note that the returned VFS should not outlive the cache. - IntrusiveRefCntPtr - getConsumingFS(IntrusiveRefCntPtr FS) const; + IntrusiveRefCntPtr + getConsumingFS(IntrusiveRefCntPtr FS) const; private: std::string MainFilePath; - llvm::StringMap StatCache; + llvm::StringMap StatCache; }; } // namespace clangd diff --git a/clang-tools-extra/clangd/FSProvider.h b/clang-tools-extra/clangd/FSProvider.h index a11d3810..0d1d5e9 100644 --- a/clang-tools-extra/clangd/FSProvider.h +++ b/clang-tools-extra/clangd/FSProvider.h @@ -10,8 +10,8 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H -#include "clang/Basic/VirtualFileSystem.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/Support/VirtualFileSystem.h" namespace clang { namespace clangd { @@ -25,14 +25,14 @@ public: /// Context::current() will be the context passed to the clang entrypoint, /// such as addDocument(), and will also be propagated to result callbacks. /// Embedders may use this to isolate filesystem accesses. - virtual IntrusiveRefCntPtr getFileSystem() const = 0; + virtual IntrusiveRefCntPtr getFileSystem() const = 0; }; class RealFileSystemProvider : public FileSystemProvider { public: // FIXME: returns the single real FS instance, which is not threadsafe. - IntrusiveRefCntPtr getFileSystem() const override { - return vfs::getRealFileSystem(); + IntrusiveRefCntPtr getFileSystem() const override { + return llvm::vfs::getRealFileSystem(); } }; diff --git a/clang-tools-extra/clangd/Headers.h b/clang-tools-extra/clangd/Headers.h index c140a65..a193a65 100644 --- a/clang-tools-extra/clangd/Headers.h +++ b/clang-tools-extra/clangd/Headers.h @@ -13,7 +13,6 @@ #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" @@ -21,6 +20,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" #include "llvm/Support/Error.h" +#include "llvm/Support/VirtualFileSystem.h" namespace clang { namespace clangd { diff --git a/clang-tools-extra/unittests/change-namespace/ChangeNamespaceTests.cpp b/clang-tools-extra/unittests/change-namespace/ChangeNamespaceTests.cpp index 917f7b0..6b1259a 100644 --- a/clang-tools-extra/unittests/change-namespace/ChangeNamespaceTests.cpp +++ b/clang-tools-extra/unittests/change-namespace/ChangeNamespaceTests.cpp @@ -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" @@ -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 #include diff --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h index 197c137..2d26754 100644 --- a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h +++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h @@ -99,8 +99,8 @@ runCheckOnCode(StringRef Code, std::vector *Errors = nullptr, Args.push_back(Filename.str()); ast_matchers::MatchFinder Finder; - llvm::IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + llvm::IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( new FileManager(FileSystemOptions(), InMemoryFileSystem)); diff --git a/clang-tools-extra/unittests/clangd/ClangdTests.cpp b/clang-tools-extra/unittests/clangd/ClangdTests.cpp index 87741df..82824fb 100644 --- a/clang-tools-extra/unittests/clangd/ClangdTests.cpp +++ b/clang-tools-extra/unittests/clangd/ClangdTests.cpp @@ -264,7 +264,7 @@ int b = a; TEST_F(ClangdVFSTest, PropagatesContexts) { static Key Secret; struct FSProvider : public FileSystemProvider { - IntrusiveRefCntPtr getFileSystem() const override { + IntrusiveRefCntPtr getFileSystem() const override { Got = Context::current().getExisting(Secret); return buildTestFS({}); } @@ -973,19 +973,19 @@ TEST(ClangdTests, PreambleVFSStatCache) { ListenStatsFSProvider(llvm::StringMap &CountStats) : CountStats(CountStats) {} - IntrusiveRefCntPtr getFileSystem() const override { - class ListenStatVFS : public vfs::ProxyFileSystem { + IntrusiveRefCntPtr getFileSystem() const override { + class ListenStatVFS : public llvm::vfs::ProxyFileSystem { public: - ListenStatVFS(IntrusiveRefCntPtr FS, + ListenStatVFS(IntrusiveRefCntPtr FS, llvm::StringMap &CountStats) : ProxyFileSystem(std::move(FS)), CountStats(CountStats) {} - llvm::ErrorOr> + llvm::ErrorOr> openFileForRead(const Twine &Path) override { ++CountStats[llvm::sys::path::filename(Path.str())]; return ProxyFileSystem::openFileForRead(Path); } - llvm::ErrorOr status(const Twine &Path) override { + llvm::ErrorOr status(const Twine &Path) override { ++CountStats[llvm::sys::path::filename(Path.str())]; return ProxyFileSystem::status(Path); } diff --git a/clang-tools-extra/unittests/clangd/FSTests.cpp b/clang-tools-extra/unittests/clangd/FSTests.cpp index 64e6f8a..6c0bfec 100644 --- a/clang-tools-extra/unittests/clangd/FSTests.cpp +++ b/clang-tools-extra/unittests/clangd/FSTests.cpp @@ -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")); diff --git a/clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp b/clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp index 5b3c58e..7c18e7e 100644 --- a/clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp +++ b/clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp @@ -13,7 +13,6 @@ #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" @@ -21,6 +20,7 @@ #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" @@ -219,7 +219,7 @@ public: 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(); @@ -258,7 +258,7 @@ public: } protected: - llvm::IntrusiveRefCntPtr InMemoryFileSystem; + llvm::IntrusiveRefCntPtr InMemoryFileSystem; std::string TestHeaderName; std::string TestHeaderURI; std::string TestFileName; diff --git a/clang-tools-extra/unittests/clangd/TestFS.h b/clang-tools-extra/unittests/clangd/TestFS.h index 39c0bb2..56bf8a3 100644 --- a/clang-tools-extra/unittests/clangd/TestFS.h +++ b/clang-tools-extra/unittests/clangd/TestFS.h @@ -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 +llvm::IntrusiveRefCntPtr buildTestFS(llvm::StringMap const &Files, llvm::StringMap const &Timestamps = {}); // A VFS provider that returns TestFSes containing a provided set of files. class MockFSProvider : public FileSystemProvider { public: - IntrusiveRefCntPtr getFileSystem() const override { + IntrusiveRefCntPtr getFileSystem() const override { return buildTestFS(Files); } diff --git a/clang-tools-extra/unittests/include-fixer/IncludeFixerTest.cpp b/clang-tools-extra/unittests/include-fixer/IncludeFixerTest.cpp index 4da14f5..519c083 100644 --- a/clang-tools-extra/unittests/include-fixer/IncludeFixerTest.cpp +++ b/clang-tools-extra/unittests/include-fixer/IncludeFixerTest.cpp @@ -24,8 +24,8 @@ using find_all_symbols::SymbolAndSignals; static bool runOnCode(tooling::ToolAction *ToolAction, StringRef Code, StringRef FileName, const std::vector &ExtraArgs) { - llvm::IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + llvm::IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( new FileManager(FileSystemOptions(), InMemoryFileSystem)); // FIXME: Investigate why -fms-compatibility breaks tests. diff --git a/clang-tools-extra/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp b/clang-tools-extra/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp index 760a253..1ad9e7f 100644 --- a/clang-tools-extra/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp +++ b/clang-tools-extra/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp @@ -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/Frontend/CompilerInstance.h" #include "clang/Frontend/PCHContainerOperations.h" #include "clang/Tooling/Tooling.h" @@ -22,6 +21,7 @@ #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 #include @@ -63,8 +63,8 @@ public: int used(const SymbolInfo &Symbol) { return Reporter.used(Symbol); } bool runFindAllSymbols(StringRef HeaderCode, StringRef MainCode) { - llvm::IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + llvm::IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( new FileManager(FileSystemOptions(), InMemoryFileSystem)); diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h index ab5dfca..3e91dd9 100644 --- a/clang/include/clang/Basic/FileManager.h +++ b/clang/include/clang/Basic/FileManager.h @@ -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" @@ -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 -#include #include +#include #include namespace llvm { @@ -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 File; + mutable std::unique_ptr File; public: FileEntry() @@ -114,7 +115,7 @@ struct FileData; /// as a single file. /// class FileManager : public RefCountedBase { - IntrusiveRefCntPtr FS; + IntrusiveRefCntPtr FS; FileSystemOptions FileSystemOpts; /// Cache for existing real directories. @@ -165,7 +166,7 @@ class FileManager : public RefCountedBase { std::unique_ptr StatCache; bool getStatValue(StringRef Path, FileData &Data, bool isFile, - std::unique_ptr *F); + std::unique_ptr *F); /// Add all ancestors of the given path (pointing to either a file /// or a directory) as virtual directories. @@ -173,7 +174,7 @@ class FileManager : public RefCountedBase { public: FileManager(const FileSystemOptions &FileSystemOpts, - IntrusiveRefCntPtr FS = nullptr); + IntrusiveRefCntPtr FS = nullptr); ~FileManager(); /// Installs the provided FileSystemStatCache object within @@ -222,7 +223,7 @@ public: FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; } const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; } - IntrusiveRefCntPtr getVirtualFileSystem() const { + IntrusiveRefCntPtr getVirtualFileSystem() const { return FS; } @@ -247,8 +248,7 @@ public: /// 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); diff --git a/clang/include/clang/Basic/FileSystemStatCache.h b/clang/include/clang/Basic/FileSystemStatCache.h index 1ec3446..a027700 100644 --- a/clang/include/clang/Basic/FileSystemStatCache.h +++ b/clang/include/clang/Basic/FileSystemStatCache.h @@ -26,7 +26,7 @@ #include #include -namespace clang { +namespace llvm { namespace vfs { @@ -34,6 +34,9 @@ class File; class FileSystem; } // namespace vfs +} // namespace llvm + +namespace clang { // FIXME: should probably replace this with vfs::Status struct FileData { @@ -82,8 +85,8 @@ public: /// 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 *F, FileSystemStatCache *Cache, - vfs::FileSystem &FS); + std::unique_ptr *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. @@ -106,11 +109,12 @@ protected: // unique_ptr. Optional&> 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 *F, - vfs::FileSystem &FS) = 0; + std::unique_ptr *F, + llvm::vfs::FileSystem &FS) = 0; LookupResult statChained(StringRef Path, FileData &Data, bool isFile, - std::unique_ptr *F, vfs::FileSystem &FS) { + std::unique_ptr *F, + llvm::vfs::FileSystem &FS) { if (FileSystemStatCache *Next = getNextStatCache()) return Next->getStat(Path, Data, isFile, F, FS); @@ -135,8 +139,8 @@ public: iterator end() const { return StatCalls.end(); } LookupResult getStat(StringRef Path, FileData &Data, bool isFile, - std::unique_ptr *F, - vfs::FileSystem &FS) override; + std::unique_ptr *F, + llvm::vfs::FileSystem &FS) override; }; } // namespace clang diff --git a/clang/include/clang/Driver/Distro.h b/clang/include/clang/Driver/Distro.h index 7b34a09..d3b0bc9 100644 --- a/clang/include/clang/Driver/Distro.h +++ b/clang/include/clang/Driver/Distro.h @@ -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 { @@ -80,7 +80,7 @@ public: 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; diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index b7b8022..29fd31c 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -28,13 +28,12 @@ namespace llvm { class Triple; -} - -namespace clang { - namespace vfs { class FileSystem; } +} // namespace llvm + +namespace clang { namespace driver { @@ -61,7 +60,7 @@ class Driver { DiagnosticsEngine &Diags; - IntrusiveRefCntPtr VFS; + IntrusiveRefCntPtr VFS; enum DriverMode { GCCMode, @@ -284,7 +283,7 @@ private: public: Driver(StringRef ClangExecutable, StringRef TargetTriple, DiagnosticsEngine &Diags, - IntrusiveRefCntPtr VFS = nullptr); + IntrusiveRefCntPtr VFS = nullptr); /// @name Accessors /// @{ @@ -298,7 +297,7 @@ public: const DiagnosticsEngine &getDiags() const { return Diags; } - vfs::FileSystem &getVFS() const { return *VFS; } + llvm::vfs::FileSystem &getVFS() const { return *VFS; } bool getCheckInputsExist() const { return CheckInputsExist; } diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 36c0e92..bc61bc6 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -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 { @@ -183,7 +182,7 @@ public: // 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. diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index 904b787..cb5886f 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -22,16 +22,18 @@ #include "llvm/Support/Regex.h" #include +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 }; @@ -2039,7 +2041,7 @@ extern const char *DefaultFallbackStyle; llvm::Expected 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. diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h index ba14596..d0b532c 100644 --- a/clang/include/clang/Frontend/ASTUnit.h +++ b/clang/include/clang/Frontend/ASTUnit.h @@ -51,6 +51,11 @@ namespace llvm { class MemoryBuffer; +namespace vfs { + +class FileSystem; + +} // namespace vfs } // namespace llvm namespace clang { @@ -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 }; @@ -365,12 +364,12 @@ private: bool Parse(std::shared_ptr PCHContainerOps, std::unique_ptr OverrideMainBuffer, - IntrusiveRefCntPtr VFS); + IntrusiveRefCntPtr VFS); std::unique_ptr getMainBufferWithPrecompiledPreamble( std::shared_ptr PCHContainerOps, CompilerInvocation &PreambleInvocationIn, - IntrusiveRefCntPtr VFS, bool AllowRebuild = true, + IntrusiveRefCntPtr VFS, bool AllowRebuild = true, unsigned MaxLines = 0); void RealizeTopLevelDeclsFromPreamble(); @@ -698,17 +697,17 @@ private: /// 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 PCHContainerOps, unsigned PrecompilePreambleAfterNParses, - IntrusiveRefCntPtr VFS); + IntrusiveRefCntPtr VFS); public: /// Create an ASTUnit from a source file, via a CompilerInvocation @@ -798,10 +797,11 @@ public: /// (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. @@ -823,22 +823,22 @@ public: bool ForSerialization = false, llvm::Optional ModuleFormat = llvm::None, std::unique_ptr *ErrAST = nullptr, - IntrusiveRefCntPtr VFS = nullptr); + IntrusiveRefCntPtr 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 PCHContainerOps, ArrayRef RemappedFiles = None, - IntrusiveRefCntPtr VFS = nullptr); + IntrusiveRefCntPtr VFS = nullptr); /// Free data that will be re-generated on the next parse. /// diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h index 818c733..ad9784b 100644 --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -83,7 +83,7 @@ class CompilerInstance : public ModuleLoader { IntrusiveRefCntPtr AuxTarget; /// The virtual file system. - IntrusiveRefCntPtr VirtualFileSystem; + IntrusiveRefCntPtr VirtualFileSystem; /// The file manager. IntrusiveRefCntPtr FileMgr; @@ -384,7 +384,7 @@ public: 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; @@ -394,7 +394,7 @@ public: /// /// \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 FS) { + void setVirtualFileSystem(IntrusiveRefCntPtr FS) { VirtualFileSystem = std::move(FS); } diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h index 1d421f0..c2f3a43e 100644 --- a/clang/include/clang/Frontend/CompilerInvocation.h +++ b/clang/include/clang/Frontend/CompilerInvocation.h @@ -35,6 +35,12 @@ class ArgList; } // namespace opt +namespace vfs { + +class FileSystem; + +} // namespace vfs + } // namespace llvm namespace clang { @@ -217,20 +223,13 @@ public: /// @} }; -namespace vfs { - -class FileSystem; - -} // namespace vfs - -IntrusiveRefCntPtr +IntrusiveRefCntPtr createVFSFromCompilerInvocation(const CompilerInvocation &CI, DiagnosticsEngine &Diags); -IntrusiveRefCntPtr -createVFSFromCompilerInvocation(const CompilerInvocation &CI, - DiagnosticsEngine &Diags, - IntrusiveRefCntPtr BaseFS); +IntrusiveRefCntPtr createVFSFromCompilerInvocation( + const CompilerInvocation &CI, DiagnosticsEngine &Diags, + IntrusiveRefCntPtr BaseFS); } // namespace clang diff --git a/clang/include/clang/Frontend/PrecompiledPreamble.h b/clang/include/clang/Frontend/PrecompiledPreamble.h index e2855fb..6c79895 100644 --- a/clang/include/clang/Frontend/PrecompiledPreamble.h +++ b/clang/include/clang/Frontend/PrecompiledPreamble.h @@ -26,13 +26,12 @@ namespace llvm { class MemoryBuffer; -} - -namespace clang { namespace vfs { class FileSystem; } +} // namespace llvm +namespace clang { class CompilerInstance; class CompilerInvocation; class DeclGroupRef; @@ -80,7 +79,8 @@ public: static llvm::ErrorOr Build(const CompilerInvocation &Invocation, const llvm::MemoryBuffer *MainFileBuffer, PreambleBounds Bounds, - DiagnosticsEngine &Diagnostics, IntrusiveRefCntPtr VFS, + DiagnosticsEngine &Diagnostics, + IntrusiveRefCntPtr VFS, std::shared_ptr PCHContainerOps, bool StoreInMemory, PreambleCallbacks &Callbacks); @@ -99,7 +99,7 @@ public: /// 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 @@ -110,14 +110,14 @@ public: /// 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, + IntrusiveRefCntPtr &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, + IntrusiveRefCntPtr &VFS, llvm::MemoryBuffer *MainFileBuffer) const; private: @@ -233,15 +233,16 @@ private: /// 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, + IntrusiveRefCntPtr &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); + static void + setupPreambleStorage(const PCHStorage &Storage, + PreprocessorOptions &PreprocessorOpts, + IntrusiveRefCntPtr &VFS); /// Manages the memory buffer or temporary file that stores the PCH. PCHStorage Storage; diff --git a/clang/include/clang/Frontend/Utils.h b/clang/include/clang/Frontend/Utils.h index 67912a8..d1dd44e 100644 --- a/clang/include/clang/Frontend/Utils.h +++ b/clang/include/clang/Frontend/Utils.h @@ -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 #include #include @@ -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 SymLinkMap; bool getRealPath(StringRef SrcPath, SmallVectorImpl &Result); @@ -201,7 +201,7 @@ std::unique_ptr createInvocationFromCommandLine( ArrayRef Args, IntrusiveRefCntPtr Diags = IntrusiveRefCntPtr(), - IntrusiveRefCntPtr VFS = nullptr); + IntrusiveRefCntPtr 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. diff --git a/clang/include/clang/Tooling/StandaloneExecution.h b/clang/include/clang/Tooling/StandaloneExecution.h index d787267..96487b4 100644 --- a/clang/include/clang/Tooling/StandaloneExecution.h +++ b/clang/include/clang/Tooling/StandaloneExecution.h @@ -37,7 +37,8 @@ public: StandaloneToolExecutor( const CompilationDatabase &Compilations, llvm::ArrayRef SourcePaths, - IntrusiveRefCntPtr BaseFS = vfs::getRealFileSystem(), + IntrusiveRefCntPtr BaseFS = + llvm::vfs::getRealFileSystem(), std::shared_ptr PCHContainerOps = std::make_shared()); diff --git a/clang/include/clang/Tooling/Tooling.h b/clang/include/clang/Tooling/Tooling.h index bbcccc5..358acf3 100644 --- a/clang/include/clang/Tooling/Tooling.h +++ b/clang/include/clang/Tooling/Tooling.h @@ -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" @@ -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 #include #include @@ -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, + llvm::IntrusiveRefCntPtr VFS, const std::vector &Args, const Twine &FileName = "input.cc", const Twine &ToolName = "clang-tool", std::shared_ptr PCHContainerOps = @@ -319,8 +319,8 @@ public: ArrayRef SourcePaths, std::shared_ptr PCHContainerOps = std::make_shared(), - IntrusiveRefCntPtr BaseFS = - vfs::getRealFileSystem()); + IntrusiveRefCntPtr BaseFS = + llvm::vfs::getRealFileSystem()); ~ClangTool(); @@ -373,8 +373,8 @@ private: std::vector SourcePaths; std::shared_ptr PCHContainerOps; - llvm::IntrusiveRefCntPtr OverlayFileSystem; - llvm::IntrusiveRefCntPtr InMemoryFileSystem; + llvm::IntrusiveRefCntPtr OverlayFileSystem; + llvm::IntrusiveRefCntPtr InMemoryFileSystem; llvm::IntrusiveRefCntPtr Files; // Contains a list of pairs (, ). @@ -467,7 +467,7 @@ inline std::unique_ptr newFrontendActionFactory( std::string getAbsolutePath(StringRef File); /// An overload of getAbsolutePath that works over the provided \p FS. -llvm::Expected getAbsolutePath(vfs::FileSystem &FS, +llvm::Expected getAbsolutePath(llvm::vfs::FileSystem &FS, StringRef File); /// Changes CommandLine to contain implicit flags that would have been diff --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt index f127023..303e63f 100644 --- a/clang/lib/Basic/CMakeLists.txt +++ b/clang/lib/Basic/CMakeLists.txt @@ -94,7 +94,6 @@ add_clang_library(clangBasic Targets/XCore.cpp TokenKinds.cpp Version.cpp - VirtualFileSystem.cpp Warnings.cpp XRayInstr.cpp XRayLists.cpp diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index a45a8f2..c4b15b3 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -49,7 +49,7 @@ using namespace clang; //===----------------------------------------------------------------------===// FileManager::FileManager(const FileSystemOptions &FSO, - IntrusiveRefCntPtr FS) + IntrusiveRefCntPtr FS) : FS(std::move(FS)), FileSystemOpts(FSO), SeenDirEntries(64), SeenFileEntries(64), NextFileUID(0) { NumDirLookups = NumFileLookups = 0; @@ -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; @@ -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 F; + std::unique_ptr F; FileData Data; if (getStatValue(InterndFileName, Data, true, openFile ? &F : nullptr)) { // There's no real file at the given path. @@ -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 *F) { + std::unique_ptr *F) { // FIXME: FileSystemOpts shouldn't be passed in here, all paths should be // absolute! if (FileSystemOpts.WorkingDir.empty()) @@ -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 S = FS->status(FilePath.c_str()); + llvm::ErrorOr S = FS->status(FilePath.c_str()); if (!S) return true; Result = *S; diff --git a/clang/lib/Basic/FileSystemStatCache.cpp b/clang/lib/Basic/FileSystemStatCache.cpp index f5856cb..9a515e8 100644 --- a/clang/lib/Basic/FileSystemStatCache.cpp +++ b/clang/lib/Basic/FileSystemStatCache.cpp @@ -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 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(); @@ -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 *F, - FileSystemStatCache *Cache, vfs::FileSystem &FS) { + std::unique_ptr *F, + FileSystemStatCache *Cache, + llvm::vfs::FileSystem &FS) { LookupResult R; bool isForDir = !isFile; @@ -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 Status = FS.status(Path); + llvm::ErrorOr Status = FS.status(Path); if (!Status) { R = CacheMissing; } else { @@ -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 Status = (*OwnedFile)->status(); + llvm::ErrorOr Status = (*OwnedFile)->status(); if (Status) { R = CacheExists; copyStatusToFileData(*Status, Data); @@ -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 *F, vfs::FileSystem &FS) { + std::unique_ptr *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 diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index efa6ad2..6f35ecb 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -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 InMemoryFileSystem( - new vfs::InMemoryFileSystem); + IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); InMemoryFileSystem->addFile( FileName, 0, llvm::MemoryBuffer::getMemBuffer(Content, FileName, diff --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp index 2c4d44f..fbfc041 100644 --- a/clang/lib/Driver/Distro.cpp +++ b/clang/lib/Driver/Distro.cpp @@ -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" @@ -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> File = VFS.getBufferForFile("/etc/lsb-release"); if (File) { @@ -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)) {} diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 203dcbe..73639f3 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -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" @@ -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 #include @@ -89,7 +89,7 @@ using namespace llvm::opt; Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple, DiagnosticsEngine &Diags, - IntrusiveRefCntPtr VFS) + IntrusiveRefCntPtr VFS) : Opts(createDriverOptTable()), Diags(Diags), VFS(std::move(VFS)), Mode(GCCMode), SaveTemps(SaveTempsNone), BitcodeEmbed(EmbedNone), LTOMode(LTOK_None), ClangExecutable(ClangExecutable), @@ -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); diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index f05c8a3..1667536 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -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" @@ -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 #include #include @@ -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, diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp index adce108..31d1692 100644 --- a/clang/lib/Driver/ToolChains/BareMetal.cpp +++ b/clang/lib/Driver/ToolChains/BareMetal.cpp @@ -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; @@ -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); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 355e8d4..171d1ae 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -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" @@ -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; diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp index ddcb008..b298617 100644 --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -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" @@ -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 using namespace clang::driver; diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 9d7f784..a5cc117 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -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" @@ -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 // ::getenv using namespace clang::driver; diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp index c16eabf..7a176d2 100644 --- a/clang/lib/Driver/ToolChains/FreeBSD.cpp +++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp @@ -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; diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index fda02b5..cb9e927 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -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" @@ -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 using namespace clang::driver; @@ -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); @@ -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) { @@ -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); @@ -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)) { diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp index 778852f..b4f299a 100644 --- a/clang/lib/Driver/ToolChains/Hexagon.cpp +++ b/clang/lib/Driver/ToolChains/Hexagon.cpp @@ -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" @@ -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; diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index a7f4e93..0db75f7 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -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" @@ -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 using namespace clang::driver; diff --git a/clang/lib/Driver/ToolChains/Minix.cpp b/clang/lib/Driver/ToolChains/Minix.cpp index 39e6f90..7fadcb1 100644 --- a/clang/lib/Driver/ToolChains/Minix.cpp +++ b/clang/lib/Driver/ToolChains/Minix.cpp @@ -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; diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 382f053..afedb9c 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -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" @@ -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 #include @@ -2326,9 +2326,10 @@ const char *DefaultFallbackStyle = "LLVM"; llvm::Expected 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); diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index d72fc92..c999458 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -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" @@ -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 #include @@ -155,9 +155,8 @@ static bool moveOnNoError(llvm::ErrorOr Val, T &Output) { /// and file-to-buffer remappings inside \p Invocation. static std::unique_ptr 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 @@ -752,7 +751,8 @@ std::unique_ptr ASTUnit::LoadFromASTFile( AST->OnlyLocalDecls = OnlyLocalDecls; AST->CaptureDiagnostics = CaptureDiagnostics; AST->Diagnostics = Diags; - IntrusiveRefCntPtr VFS = vfs::getRealFileSystem(); + IntrusiveRefCntPtr VFS = + llvm::vfs::getRealFileSystem(); AST->FileMgr = new FileManager(FileSystemOpts, VFS); AST->UserFilesAreVolatile = UserFilesAreVolatile; AST->SourceMgr = new SourceManager(AST->getDiagnostics(), @@ -1074,7 +1074,7 @@ static void checkAndSanitizeDiags(SmallVectorImpl & /// contain any translation-unit information, false otherwise. bool ASTUnit::Parse(std::shared_ptr PCHContainerOps, std::unique_ptr OverrideMainBuffer, - IntrusiveRefCntPtr VFS) { + IntrusiveRefCntPtr VFS) { if (!Invocation) return true; @@ -1082,7 +1082,7 @@ bool ASTUnit::Parse(std::shared_ptr PCHContainerOps, if (OverrideMainBuffer) { assert(Preamble && "No preamble was built, but OverrideMainBuffer is not null"); - IntrusiveRefCntPtr OldVFS = VFS; + IntrusiveRefCntPtr OldVFS = VFS; Preamble->AddImplicitPreamble(*CCInvocation, VFS, OverrideMainBuffer.get()); if (OldVFS != VFS && FileMgr) { assert(OldVFS == FileMgr->getVirtualFileSystem() && @@ -1279,7 +1279,7 @@ std::unique_ptr ASTUnit::getMainBufferWithPrecompiledPreamble( std::shared_ptr PCHContainerOps, CompilerInvocation &PreambleInvocationIn, - IntrusiveRefCntPtr VFS, bool AllowRebuild, + IntrusiveRefCntPtr VFS, bool AllowRebuild, unsigned MaxLines) { auto MainFilePath = PreambleInvocationIn.getFrontendOpts().Inputs[0].getFile(); @@ -1468,7 +1468,7 @@ ASTUnit::create(std::shared_ptr CI, bool CaptureDiagnostics, bool UserFilesAreVolatile) { std::unique_ptr AST(new ASTUnit(false)); ConfigureDiags(Diags, *AST, CaptureDiagnostics); - IntrusiveRefCntPtr VFS = + IntrusiveRefCntPtr VFS = createVFSFromCompilerInvocation(*CI, *Diags); AST->Diagnostics = Diags; AST->FileSystemOpts = CI->getFileSystemOpts(); @@ -1630,7 +1630,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction( bool ASTUnit::LoadFromCompilerInvocation( std::shared_ptr PCHContainerOps, unsigned PrecompilePreambleAfterNParses, - IntrusiveRefCntPtr VFS) { + IntrusiveRefCntPtr VFS) { if (!Invocation) return true; @@ -1709,7 +1709,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine( bool AllowPCHWithCompilerErrors, SkipFunctionBodiesScope SkipFunctionBodies, bool SingleFileParse, bool UserFilesAreVolatile, bool ForSerialization, llvm::Optional ModuleFormat, std::unique_ptr *ErrAST, - IntrusiveRefCntPtr VFS) { + IntrusiveRefCntPtr VFS) { assert(Diags.get() && "no DiagnosticsEngine was provided"); SmallVector StoredDiagnostics; @@ -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; @@ -1794,7 +1794,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine( bool ASTUnit::Reparse(std::shared_ptr PCHContainerOps, ArrayRef RemappedFiles, - IntrusiveRefCntPtr VFS) { + IntrusiveRefCntPtr VFS) { if (!Invocation) return true; diff --git a/clang/lib/Frontend/CacheTokens.cpp b/clang/lib/Frontend/CacheTokens.cpp index c4504a1..4d63afc 100644 --- a/clang/lib/Frontend/CacheTokens.cpp +++ b/clang/lib/Frontend/CacheTokens.cpp @@ -556,8 +556,8 @@ public: ~StatListener() override {} LookupResult getStat(StringRef Path, FileData &Data, bool isFile, - std::unique_ptr *F, - vfs::FileSystem &FS) override { + std::unique_ptr *F, + llvm::vfs::FileSystem &FS) override { LookupResult Result = statChained(Path, Data, isFile, F, FS); if (Result == CacheMissing) // Failed 'stat'. diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 05ba3c0..bba1ef1 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -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, @@ -198,14 +198,14 @@ static void collectVFSEntries(CompilerInstance &CI, return; // Collect all VFS found. - SmallVector VFSEntries; + SmallVector VFSEntries; for (const std::string &VFSFile : CI.getHeaderSearchOpts().VFSOverlayFiles) { llvm::ErrorOr> 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) @@ -303,7 +303,7 @@ CompilerInstance::createDiagnostics(DiagnosticOptions *Opts, FileManager *CompilerInstance::createFileManager() { if (!hasVirtualFileSystem()) { - IntrusiveRefCntPtr VFS = + IntrusiveRefCntPtr VFS = createVFSFromCompilerInvocation(getInvocation(), getDiagnostics()); setVirtualFileSystem(VFS); } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 851fd49..e848e50 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -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" @@ -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 @@ -3245,21 +3245,21 @@ void BuryPointer(const void *Ptr) { GraveYard[Idx] = Ptr; } -IntrusiveRefCntPtr +IntrusiveRefCntPtr createVFSFromCompilerInvocation(const CompilerInvocation &CI, DiagnosticsEngine &Diags) { - return createVFSFromCompilerInvocation(CI, Diags, vfs::getRealFileSystem()); + return createVFSFromCompilerInvocation(CI, Diags, + llvm::vfs::getRealFileSystem()); } -IntrusiveRefCntPtr -createVFSFromCompilerInvocation(const CompilerInvocation &CI, - DiagnosticsEngine &Diags, - IntrusiveRefCntPtr BaseFS) { +IntrusiveRefCntPtr createVFSFromCompilerInvocation( + const CompilerInvocation &CI, DiagnosticsEngine &Diags, + IntrusiveRefCntPtr BaseFS) { if (CI.getHeaderSearchOpts().VFSOverlayFiles.empty()) return BaseFS; - IntrusiveRefCntPtr Overlay( - new vfs::OverlayFileSystem(BaseFS)); + IntrusiveRefCntPtr Overlay( + new llvm::vfs::OverlayFileSystem(BaseFS)); // earlier vfs files are on the bottom for (const auto &File : CI.getHeaderSearchOpts().VFSOverlayFiles) { llvm::ErrorOr> Buffer = @@ -3269,7 +3269,7 @@ createVFSFromCompilerInvocation(const CompilerInvocation &CI, continue; } - IntrusiveRefCntPtr FS = vfs::getVFSFromYAML( + IntrusiveRefCntPtr FS = llvm::vfs::getVFSFromYAML( std::move(Buffer.get()), /*DiagHandler*/ nullptr, File); if (FS) Overlay->pushOverlay(FS); diff --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp index c3ce7ce..2d4c40f 100644 --- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp +++ b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp @@ -32,7 +32,7 @@ using namespace llvm::opt; /// argument vector. std::unique_ptr clang::createInvocationFromCommandLine( ArrayRef ArgList, IntrusiveRefCntPtr Diags, - IntrusiveRefCntPtr VFS) { + IntrusiveRefCntPtr VFS) { if (!Diags.get()) { // No diagnostics engine was provided, so create our own diagnostics object // with the default options. diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index d247005..16c7564 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -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. @@ -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( diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp b/clang/lib/Frontend/PrecompiledPreamble.cpp index c6dd89c..1930af1 100644 --- a/clang/lib/Frontend/PrecompiledPreamble.cpp +++ b/clang/lib/Frontend/PrecompiledPreamble.cpp @@ -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" @@ -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 #include @@ -48,17 +48,17 @@ StringRef getInMemoryPreamblePath() { #endif } -IntrusiveRefCntPtr +IntrusiveRefCntPtr createVFSOverlayForPreamblePCH(StringRef PCHFilename, std::unique_ptr PCHBuffer, - IntrusiveRefCntPtr VFS) { + IntrusiveRefCntPtr 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 PCHFS( - new vfs::InMemoryFileSystem()); + IntrusiveRefCntPtr PCHFS( + new llvm::vfs::InMemoryFileSystem()); PCHFS->addFile(PCHFilename, 0, std::move(PCHBuffer)); - IntrusiveRefCntPtr Overlay( - new vfs::OverlayFileSystem(VFS)); + IntrusiveRefCntPtr Overlay( + new llvm::vfs::OverlayFileSystem(VFS)); Overlay->pushOverlay(PCHFS); return Overlay; } @@ -232,7 +232,8 @@ PreambleBounds clang::ComputePreambleBounds(const LangOptions &LangOpts, llvm::ErrorOr PrecompiledPreamble::Build( const CompilerInvocation &Invocation, const llvm::MemoryBuffer *MainFileBuffer, PreambleBounds Bounds, - DiagnosticsEngine &Diagnostics, IntrusiveRefCntPtr VFS, + DiagnosticsEngine &Diagnostics, + IntrusiveRefCntPtr VFS, std::shared_ptr PCHContainerOps, bool StoreInMemory, PreambleCallbacks &Callbacks) { assert(VFS && "VFS is null"); @@ -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() && @@ -437,7 +438,7 @@ bool PrecompiledPreamble::CanReuse(const CompilerInvocation &Invocation, // remapping or unsaved_files. std::map 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. @@ -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; @@ -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; @@ -485,14 +486,14 @@ bool PrecompiledPreamble::CanReuse(const CompilerInvocation &Invocation, } void PrecompiledPreamble::AddImplicitPreamble( - CompilerInvocation &CI, IntrusiveRefCntPtr &VFS, + CompilerInvocation &CI, IntrusiveRefCntPtr &VFS, llvm::MemoryBuffer *MainFileBuffer) const { PreambleBounds Bounds(PreambleBytes.size(), PreambleEndsAtStartOfLine); configurePreamble(Bounds, CI, VFS, MainFileBuffer); } void PrecompiledPreamble::OverridePreamble( - CompilerInvocation &CI, IntrusiveRefCntPtr &VFS, + CompilerInvocation &CI, IntrusiveRefCntPtr &VFS, llvm::MemoryBuffer *MainFileBuffer) const { auto Bounds = ComputePreambleBounds(*CI.getLangOpts(), MainFileBuffer, 0); configurePreamble(Bounds, CI, VFS, MainFileBuffer); @@ -680,7 +681,7 @@ PrecompiledPreamble::PreambleFileHash::createForMemoryBuffer( void PrecompiledPreamble::configurePreamble( PreambleBounds Bounds, CompilerInvocation &CI, - IntrusiveRefCntPtr &VFS, + IntrusiveRefCntPtr &VFS, llvm::MemoryBuffer *MainFileBuffer) const { assert(VFS); @@ -701,13 +702,14 @@ void PrecompiledPreamble::configurePreamble( void PrecompiledPreamble::setupPreambleStorage( const PCHStorage &Storage, PreprocessorOptions &PreprocessorOpts, - IntrusiveRefCntPtr &VFS) { + IntrusiveRefCntPtr &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 RealFS = vfs::getRealFileSystem(); + IntrusiveRefCntPtr RealFS = + llvm::vfs::getRealFileSystem(); auto PCHPath = PCHFile.getFilePath(); if (VFS == RealFS || VFS->exists(PCHPath)) return; diff --git a/clang/lib/Index/SimpleFormatContext.h b/clang/lib/Index/SimpleFormatContext.h index 9c6d29b..24adcac 100644 --- a/clang/lib/Index/SimpleFormatContext.h +++ b/clang/lib/Index/SimpleFormatContext.h @@ -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); } @@ -63,7 +61,7 @@ public: IntrusiveRefCntPtr DiagOpts; IntrusiveRefCntPtr Diagnostics; - IntrusiveRefCntPtr InMemoryFileSystem; + IntrusiveRefCntPtr InMemoryFileSystem; FileManager Files; SourceManager Sources; Rewriter Rewrite; diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index c475336..27eca0a 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -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" @@ -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 #include #include @@ -1571,8 +1571,9 @@ void HeaderSearch::collectAllModules(SmallVectorImpl &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; @@ -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()) diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index b6a6e26..d44bf12 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -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" @@ -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 #include @@ -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; @@ -2394,8 +2395,9 @@ void ModuleMapParser::parseUmbrellaDirDecl(SourceLocation UmbrellaLoc) { // uncommonly used Tcl module on Darwin platforms. std::error_code EC; SmallVector 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())) { diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp index 2ec075f..76ccfb7 100644 --- a/clang/lib/Lex/PPLexerChange.cpp +++ b/clang/lib/Lex/PPLexerChange.cpp @@ -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; diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp index 45cff56..74c7c5e 100644 --- a/clang/lib/Lex/PTHLexer.cpp +++ b/clang/lib/Lex/PTHLexer.cpp @@ -715,8 +715,8 @@ public: FL.getBase()) {} LookupResult getStat(StringRef Path, FileData &Data, bool isFile, - std::unique_ptr *F, - vfs::FileSystem &FS) override { + std::unique_ptr *F, + llvm::vfs::FileSystem &FS) override { // Do the lookup for the file's data in the PTH file. CacheTy::iterator I = Cache.find(Path); diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index bdf538b..70b43a6 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -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()); diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp index fccfa88..683ba8f 100644 --- a/clang/lib/Serialization/ModuleManager.cpp +++ b/clang/lib/Serialization/ModuleManager.cpp @@ -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" @@ -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 #include #include @@ -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 = diff --git a/clang/lib/Tooling/Core/Replacement.cpp b/clang/lib/Tooling/Core/Replacement.cpp index f97bdbf..3b7e398 100644 --- a/clang/lib/Tooling/Core/Replacement.cpp +++ b/clang/lib/Tooling/Core/Replacement.cpp @@ -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" @@ -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 #include @@ -583,8 +583,8 @@ llvm::Expected applyAllReplacements(StringRef Code, if (Replaces.empty()) return Code.str(); - IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); FileManager Files(FileSystemOptions(), InMemoryFileSystem); DiagnosticsEngine Diagnostics( IntrusiveRefCntPtr(new DiagnosticIDs), diff --git a/clang/lib/Tooling/StandaloneExecution.cpp b/clang/lib/Tooling/StandaloneExecution.cpp index 7312baf..1daf792f 100644 --- a/clang/lib/Tooling/StandaloneExecution.cpp +++ b/clang/lib/Tooling/StandaloneExecution.cpp @@ -30,7 +30,7 @@ static ArgumentsAdjuster getDefaultArgumentsAdjusters() { StandaloneToolExecutor::StandaloneToolExecutor( const CompilationDatabase &Compilations, llvm::ArrayRef SourcePaths, - IntrusiveRefCntPtr BaseFS, + IntrusiveRefCntPtr BaseFS, std::shared_ptr PCHContainerOps) : Tool(Compilations, SourcePaths, std::move(PCHContainerOps), std::move(BaseFS)), diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp index 395d2d7..eb9451d 100644 --- a/clang/lib/Tooling/Tooling.cpp +++ b/clang/lib/Tooling/Tooling.cpp @@ -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" @@ -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 #include @@ -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) { +static driver::Driver * +newDriver(DiagnosticsEngine *Diagnostics, const char *BinaryName, + IntrusiveRefCntPtr VFS) { driver::Driver *CompilerDriver = new driver::Driver(BinaryName, llvm::sys::getDefaultTargetTriple(), *Diagnostics, std::move(VFS)); @@ -155,7 +155,7 @@ namespace tooling { bool runToolOnCodeWithArgs( FrontendAction *ToolAction, const Twine &Code, - llvm::IntrusiveRefCntPtr VFS, + llvm::IntrusiveRefCntPtr VFS, const std::vector &Args, const Twine &FileName, const Twine &ToolName, std::shared_ptr PCHContainerOps) { @@ -178,10 +178,10 @@ bool runToolOnCodeWithArgs( const Twine &ToolName, std::shared_ptr PCHContainerOps, const FileContentMappings &VirtualMappedFiles) { - llvm::IntrusiveRefCntPtr OverlayFileSystem( - new vfs::OverlayFileSystem(vfs::getRealFileSystem())); - llvm::IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + llvm::IntrusiveRefCntPtr OverlayFileSystem( + new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem())); + llvm::IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); OverlayFileSystem->pushOverlay(InMemoryFileSystem); SmallString<1024> CodeStorage; @@ -199,7 +199,7 @@ bool runToolOnCodeWithArgs( FileName, ToolName); } -llvm::Expected getAbsolutePath(vfs::FileSystem &FS, +llvm::Expected getAbsolutePath(llvm::vfs::FileSystem &FS, StringRef File) { StringRef RelativePath(File); // FIXME: Should '.\\' be accepted on Win32? @@ -215,7 +215,7 @@ llvm::Expected 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 &CommandLine, @@ -372,11 +372,11 @@ bool FrontendActionFactory::runInvocation( ClangTool::ClangTool(const CompilationDatabase &Compilations, ArrayRef SourcePaths, std::shared_ptr PCHContainerOps, - IntrusiveRefCntPtr BaseFS) + IntrusiveRefCntPtr 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()); @@ -586,10 +586,10 @@ std::unique_ptr buildASTFromCodeWithArgs( std::vector> ASTs; ASTBuilderAction Action(ASTs); - llvm::IntrusiveRefCntPtr OverlayFileSystem( - new vfs::OverlayFileSystem(vfs::getRealFileSystem())); - llvm::IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + llvm::IntrusiveRefCntPtr OverlayFileSystem( + new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem())); + llvm::IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); OverlayFileSystem->pushOverlay(InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( new FileManager(FileSystemOptions(), OverlayFileSystem)); diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index de2f9d7..49162d0 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -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); @@ -133,8 +133,8 @@ static bool parseLineRange(StringRef Input, unsigned &FromLine, static bool fillRanges(MemoryBuffer *Code, std::vector &Ranges) { - IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); FileManager Files(FileSystemOptions(), InMemoryFileSystem); DiagnosticsEngine Diagnostics( IntrusiveRefCntPtr(new DiagnosticIDs), @@ -301,8 +301,8 @@ static bool format(StringRef FileName) { outputReplacementsXML(Replaces); outs() << "\n"; } else { - IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); FileManager Files(FileSystemOptions(), InMemoryFileSystem); DiagnosticsEngine Diagnostics( IntrusiveRefCntPtr(new DiagnosticIDs), diff --git a/clang/tools/driver/cc1gen_reproducer_main.cpp b/clang/tools/driver/cc1gen_reproducer_main.cpp index a4c034d..2d7ea86 100644 --- a/clang/tools/driver/cc1gen_reproducer_main.cpp +++ b/clang/tools/driver/cc1gen_reproducer_main.cpp @@ -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" diff --git a/clang/tools/libclang/BuildSystem.cpp b/clang/tools/libclang/BuildSystem.cpp index 79fa69c..6c1f2c1 100644 --- a/clang/tools/libclang/BuildSystem.cpp +++ b/clang/tools/libclang/BuildSystem.cpp @@ -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; @@ -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 diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 366ff7f..ecfdeb0 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -37,10 +37,10 @@ createVirtualFileIfNeeded(ASTUnit *ToAST, StringRef FileName, std::unique_ptr &&Buffer) { assert(ToAST); ASTContext &ToCtx = ToAST->getASTContext(); - auto *OFS = static_cast( + auto *OFS = static_cast( ToCtx.getSourceManager().getFileManager().getVirtualFileSystem().get()); - auto *MFS = - static_cast(OFS->overlays_begin()->get()); + auto *MFS = static_cast( + OFS->overlays_begin()->get()); MFS->addFile(FileName, 0, std::move(Buffer)); } @@ -2482,7 +2482,7 @@ TEST_P(ImportFriendFunctions, ImportFriendChangesLookup) { LookupRes = ToTU->noload_lookup(ToName); EXPECT_EQ(LookupRes.size(), 1u); EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u); - + auto *ToFriendF = cast(Import(FromFriendF, Lang_CXX)); LookupRes = ToTU->noload_lookup(ToName); EXPECT_EQ(LookupRes.size(), 1u); @@ -2758,7 +2758,7 @@ TEST_P(ASTImporterTestBase, ImportOfEquivalentRecord) { ToR2 = Import(FromR, Lang_CXX); } - + EXPECT_EQ(ToR1, ToR2); } diff --git a/clang/unittests/AST/CommentTextTest.cpp b/clang/unittests/AST/CommentTextTest.cpp index 04475f1c..5fb7795 100644 --- a/clang/unittests/AST/CommentTextTest.cpp +++ b/clang/unittests/AST/CommentTextTest.cpp @@ -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 namespace clang { diff --git a/clang/unittests/Basic/CMakeLists.txt b/clang/unittests/Basic/CMakeLists.txt index f5c96bb..537f3ba 100644 --- a/clang/unittests/Basic/CMakeLists.txt +++ b/clang/unittests/Basic/CMakeLists.txt @@ -9,7 +9,6 @@ add_clang_unittest(BasicTests FixedPointTest.cpp MemoryBufferCacheTest.cpp SourceManagerTest.cpp - VirtualFileSystemTest.cpp ) target_link_libraries(BasicTests diff --git a/clang/unittests/Basic/FileManagerTest.cpp b/clang/unittests/Basic/FileManagerTest.cpp index 52cb5b2..309de47 100644 --- a/clang/unittests/Basic/FileManagerTest.cpp +++ b/clang/unittests/Basic/FileManagerTest.cpp @@ -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; @@ -60,8 +60,8 @@ public: // Implement FileSystemStatCache::getStat(). LookupResult getStat(StringRef Path, FileData &Data, bool isFile, - std::unique_ptr *F, - vfs::FileSystem &FS) override { + std::unique_ptr *F, + llvm::vfs::FileSystem &FS) override { #ifndef _WIN32 SmallString<128> NormalizedPath(Path); llvm::sys::path::native(NormalizedPath); @@ -305,8 +305,8 @@ TEST_F(FileManagerTest, makeAbsoluteUsesVFS) { #endif llvm::sys::path::append(CustomWorkingDir, "some", "weird", "path"); - auto FS = - IntrusiveRefCntPtr(new vfs::InMemoryFileSystem); + auto FS = IntrusiveRefCntPtr( + new llvm::vfs::InMemoryFileSystem); // setCurrentworkingdirectory must finish without error. ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir)); diff --git a/clang/unittests/Driver/DistroTest.cpp b/clang/unittests/Driver/DistroTest.cpp index e3686e4..5a23392 100644 --- a/clang/unittests/Driver/DistroTest.cpp +++ b/clang/unittests/Driver/DistroTest.cpp @@ -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; @@ -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")); @@ -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, @@ -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. @@ -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. @@ -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" @@ -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" @@ -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" @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/clang/unittests/Driver/ToolChainTest.cpp b/clang/unittests/Driver/ToolChainTest.cpp index 0d4c545..f118107 100644 --- a/clang/unittests/Driver/ToolChainTest.cpp +++ b/clang/unittests/Driver/ToolChainTest.cpp @@ -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; @@ -33,8 +33,8 @@ TEST(ToolChainTest, VFSGCCInstallation) { IntrusiveRefCntPtr DiagID(new DiagnosticIDs()); struct TestDiagnosticConsumer : public DiagnosticConsumer {}; DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer); - IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); Driver TheDriver("/bin/clang", "arm-linux-gnueabihf", Diags, InMemoryFileSystem); @@ -87,8 +87,8 @@ TEST(ToolChainTest, VFSGCCInstallationRelativeDir) { IntrusiveRefCntPtr DiagID(new DiagnosticIDs()); struct TestDiagnosticConsumer : public DiagnosticConsumer {}; DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer); - IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); Driver TheDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags, InMemoryFileSystem); @@ -127,8 +127,8 @@ TEST(ToolChainTest, DefaultDriverMode) { IntrusiveRefCntPtr DiagID(new DiagnosticIDs()); struct TestDiagnosticConsumer : public DiagnosticConsumer {}; DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer); - IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags, InMemoryFileSystem); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index b29f67a..86b1ca2 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -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, diff --git a/clang/unittests/Index/IndexTests.cpp b/clang/unittests/Index/IndexTests.cpp index e438537..2d4463d 100644 --- a/clang/unittests/Index/IndexTests.cpp +++ b/clang/unittests/Index/IndexTests.cpp @@ -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" @@ -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 diff --git a/clang/unittests/Lex/HeaderSearchTest.cpp b/clang/unittests/Lex/HeaderSearchTest.cpp index c2794f5..060135b 100644 --- a/clang/unittests/Lex/HeaderSearchTest.cpp +++ b/clang/unittests/Lex/HeaderSearchTest.cpp @@ -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), @@ -46,7 +46,7 @@ protected: Search.AddSearchPath(DL, /*isAngled=*/false); } - IntrusiveRefCntPtr VFS; + IntrusiveRefCntPtr VFS; FileSystemOptions FileMgrOpts; FileManager FileMgr; IntrusiveRefCntPtr DiagID; diff --git a/clang/unittests/Lex/PPCallbacksTest.cpp b/clang/unittests/Lex/PPCallbacksTest.cpp index 0fa6286..d0ff45e 100644 --- a/clang/unittests/Lex/PPCallbacksTest.cpp +++ b/clang/unittests/Lex/PPCallbacksTest.cpp @@ -95,7 +95,7 @@ public: 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()), @@ -104,7 +104,7 @@ protected: Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts); } - IntrusiveRefCntPtr InMemoryFileSystem; + IntrusiveRefCntPtr InMemoryFileSystem; FileManager FileMgr; IntrusiveRefCntPtr DiagID; IntrusiveRefCntPtr DiagOpts; @@ -116,17 +116,17 @@ protected: // 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. @@ -139,8 +139,9 @@ protected: // 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 Buf = llvm::MemoryBuffer::getMemBuffer(SourceText); SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf))); @@ -198,8 +199,8 @@ protected: return Callbacks; } - PragmaOpenCLExtensionCallbacks::CallbackParameters - PragmaOpenCLExtensionCall(const char* SourceText) { + PragmaOpenCLExtensionCallbacks::CallbackParameters + PragmaOpenCLExtensionCall(const char *SourceText) { LangOptions OpenCLLangOpts; OpenCLLangOpts.OpenCL = 1; @@ -221,9 +222,8 @@ protected: // 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; @@ -245,7 +245,7 @@ protected: Callbacks->Name, Callbacks->State }; - return RetVal; + return RetVal; } }; diff --git a/clang/unittests/Rename/ClangRenameTest.h b/clang/unittests/Rename/ClangRenameTest.h index e0f3367..13906d1 100644 --- a/clang/unittests/Rename/ClangRenameTest.h +++ b/clang/unittests/Rename/ClangRenameTest.h @@ -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" @@ -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 #include diff --git a/clang/unittests/Tooling/RefactoringTest.cpp b/clang/unittests/Tooling/RefactoringTest.cpp index fcd2aa5..d618c0f 100644 --- a/clang/unittests/Tooling/RefactoringTest.cpp +++ b/clang/unittests/Tooling/RefactoringTest.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "clang/Tooling/Refactoring.h" #include "ReplacementTest.h" #include "RewriterTestContext.h" #include "clang/AST/ASTConsumer.h" @@ -19,16 +20,15 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/SourceManager.h" -#include "clang/Basic/VirtualFileSystem.h" #include "clang/Format/Format.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendAction.h" #include "clang/Frontend/TextDiagnosticPrinter.h" #include "clang/Rewrite/Core/Rewriter.h" -#include "clang/Tooling/Refactoring.h" #include "clang/Tooling/Refactoring/AtomicChange.h" #include "clang/Tooling/Tooling.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Support/VirtualFileSystem.h" #include "gtest/gtest.h" namespace clang { @@ -1032,8 +1032,8 @@ TEST_F(MergeReplacementsTest, OverlappingRanges) { TEST(DeduplicateByFileTest, PathsWithDots) { std::map FileToReplaces; - llvm::IntrusiveRefCntPtr VFS( - new vfs::InMemoryFileSystem()); + llvm::IntrusiveRefCntPtr VFS( + new llvm::vfs::InMemoryFileSystem()); FileManager FileMgr(FileSystemOptions(), VFS); #if !defined(_WIN32) StringRef Path1 = "a/b/.././c.h"; @@ -1053,8 +1053,8 @@ TEST(DeduplicateByFileTest, PathsWithDots) { TEST(DeduplicateByFileTest, PathWithDotSlash) { std::map FileToReplaces; - llvm::IntrusiveRefCntPtr VFS( - new vfs::InMemoryFileSystem()); + llvm::IntrusiveRefCntPtr VFS( + new llvm::vfs::InMemoryFileSystem()); FileManager FileMgr(FileSystemOptions(), VFS); #if !defined(_WIN32) StringRef Path1 = "./a/b/c.h"; @@ -1074,8 +1074,8 @@ TEST(DeduplicateByFileTest, PathWithDotSlash) { TEST(DeduplicateByFileTest, NonExistingFilePath) { std::map FileToReplaces; - llvm::IntrusiveRefCntPtr VFS( - new vfs::InMemoryFileSystem()); + llvm::IntrusiveRefCntPtr VFS( + new llvm::vfs::InMemoryFileSystem()); FileManager FileMgr(FileSystemOptions(), VFS); #if !defined(_WIN32) StringRef Path1 = "./a/b/c.h"; diff --git a/clang/unittests/Tooling/RewriterTestContext.h b/clang/unittests/Tooling/RewriterTestContext.h index eee7ea1..9e66484 100644 --- a/clang/unittests/Tooling/RewriterTestContext.h +++ b/clang/unittests/Tooling/RewriterTestContext.h @@ -39,15 +39,15 @@ class RewriterTestContext { Diagnostics(IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts), DiagnosticPrinter(llvm::outs(), &*DiagOpts), - InMemoryFileSystem(new vfs::InMemoryFileSystem), + InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem), OverlayFileSystem( - new vfs::OverlayFileSystem(vfs::getRealFileSystem())), + new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem())), Files(FileSystemOptions(), OverlayFileSystem), Sources(Diagnostics, Files), Rewrite(Sources, Options) { - Diagnostics.setClient(&DiagnosticPrinter, false); - // FIXME: To make these tests truly in-memory, we need to overlay the - // builtin headers. - OverlayFileSystem->pushOverlay(InMemoryFileSystem); + Diagnostics.setClient(&DiagnosticPrinter, false); + // FIXME: To make these tests truly in-memory, we need to overlay the + // builtin headers. + OverlayFileSystem->pushOverlay(InMemoryFileSystem); } ~RewriterTestContext() {} @@ -114,8 +114,8 @@ class RewriterTestContext { IntrusiveRefCntPtr DiagOpts; DiagnosticsEngine Diagnostics; TextDiagnosticPrinter DiagnosticPrinter; - IntrusiveRefCntPtr InMemoryFileSystem; - IntrusiveRefCntPtr OverlayFileSystem; + IntrusiveRefCntPtr InMemoryFileSystem; + IntrusiveRefCntPtr OverlayFileSystem; FileManager Files; SourceManager Sources; LangOptions Options; diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp index 0a5150a..186463f 100644 --- a/clang/unittests/Tooling/ToolingTest.cpp +++ b/clang/unittests/Tooling/ToolingTest.cpp @@ -149,10 +149,10 @@ TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromFactoryType) { } TEST(ToolInvocation, TestMapVirtualFile) { - llvm::IntrusiveRefCntPtr OverlayFileSystem( - new vfs::OverlayFileSystem(vfs::getRealFileSystem())); - llvm::IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + llvm::IntrusiveRefCntPtr OverlayFileSystem( + new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem())); + llvm::IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); OverlayFileSystem->pushOverlay(InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( new FileManager(FileSystemOptions(), OverlayFileSystem)); @@ -175,10 +175,10 @@ TEST(ToolInvocation, TestVirtualModulesCompilation) { // mapped module.map is found on the include path. In the future, expand this // test to run a full modules enabled compilation, so we make sure we can // rerun modules compilations with a virtual file system. - llvm::IntrusiveRefCntPtr OverlayFileSystem( - new vfs::OverlayFileSystem(vfs::getRealFileSystem())); - llvm::IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + llvm::IntrusiveRefCntPtr OverlayFileSystem( + new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem())); + llvm::IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); OverlayFileSystem->pushOverlay(InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( new FileManager(FileSystemOptions(), OverlayFileSystem)); @@ -403,10 +403,10 @@ TEST(ClangToolTest, ArgumentAdjusters) { TEST(ClangToolTest, BaseVirtualFileSystemUsage) { FixedCompilationDatabase Compilations("/", std::vector()); - llvm::IntrusiveRefCntPtr OverlayFileSystem( - new vfs::OverlayFileSystem(vfs::getRealFileSystem())); - llvm::IntrusiveRefCntPtr InMemoryFileSystem( - new vfs::InMemoryFileSystem); + llvm::IntrusiveRefCntPtr OverlayFileSystem( + new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem())); + llvm::IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); OverlayFileSystem->pushOverlay(InMemoryFileSystem); InMemoryFileSystem->addFile( diff --git a/clang/include/clang/Basic/VirtualFileSystem.h b/llvm/include/llvm/Support/VirtualFileSystem.h similarity index 96% rename from clang/include/clang/Basic/VirtualFileSystem.h rename to llvm/include/llvm/Support/VirtualFileSystem.h index 97e2941..f2f8ffa 100644 --- a/clang/include/clang/Basic/VirtualFileSystem.h +++ b/llvm/include/llvm/Support/VirtualFileSystem.h @@ -12,10 +12,9 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_BASIC_VIRTUALFILESYSTEM_H -#define LLVM_CLANG_BASIC_VIRTUALFILESYSTEM_H +#ifndef LLVM_SUPPORT_VIRTUALFILESYSTEM_H +#define LLVM_SUPPORT_VIRTUALFILESYSTEM_H -#include "clang/Basic/LLVM.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" @@ -40,9 +39,6 @@ namespace llvm { class MemoryBuffer; -} // namespace llvm - -namespace clang { namespace vfs { /// The result of a \p status operation. @@ -57,7 +53,7 @@ class Status { llvm::sys::fs::perms Perms; public: - // FIXME: remove when files support multiple names + // FIXME: remove when files support multiple names bool IsVFSMapped = false; Status() = default; @@ -229,7 +225,7 @@ public: /// Gets the current level. Starting path is at level 0. int level() const { assert(!State->empty() && "Cannot get level without any iteration state"); - return State->size()-1; + return State->size() - 1; } }; @@ -430,8 +426,7 @@ public: /// false if the file or directory already exists in the file system with /// different contents. bool addFileNoOwn(const Twine &Path, time_t ModificationTime, - llvm::MemoryBuffer *Buffer, - Optional User = None, + llvm::MemoryBuffer *Buffer, Optional User = None, Optional Group = None, Optional Type = None, Optional Perms = None); @@ -469,12 +464,12 @@ llvm::sys::fs::UniqueID getNextVirtualUniqueID(); IntrusiveRefCntPtr getVFSFromYAML(std::unique_ptr Buffer, llvm::SourceMgr::DiagHandlerTy DiagHandler, - StringRef YAMLFilePath, - void *DiagContext = nullptr, + StringRef YAMLFilePath, void *DiagContext = nullptr, IntrusiveRefCntPtr ExternalFS = getRealFileSystem()); struct YAMLVFSEntry { - template YAMLVFSEntry(T1 &&VPath, T2 &&RPath) + template + YAMLVFSEntry(T1 &&VPath, T2 &&RPath) : VPath(std::forward(VPath)), RPath(std::forward(RPath)) {} std::string VPath; std::string RPath; @@ -507,9 +502,7 @@ public: IsCaseSensitive = CaseSensitive; } - void setUseExternalNames(bool UseExtNames) { - UseExternalNames = UseExtNames; - } + void setUseExternalNames(bool UseExtNames) { UseExternalNames = UseExtNames; } void setIgnoreNonExistentContents(bool IgnoreContents) { IgnoreNonExistentContents = IgnoreContents; @@ -524,6 +517,6 @@ public: }; } // namespace vfs -} // namespace clang +} // namespace llvm -#endif // LLVM_CLANG_BASIC_VIRTUALFILESYSTEM_H +#endif // LLVM_SUPPORT_VIRTUALFILESYSTEM_H diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt index 88129b0..1446359 100644 --- a/llvm/lib/Support/CMakeLists.txt +++ b/llvm/lib/Support/CMakeLists.txt @@ -135,6 +135,7 @@ add_llvm_library(LLVMSupport Unicode.cpp UnicodeCaseFold.cpp VersionTuple.cpp + VirtualFileSystem.cpp WithColor.cpp YAMLParser.cpp YAMLTraits.cpp diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp similarity index 96% rename from clang/lib/Basic/VirtualFileSystem.cpp rename to llvm/lib/Support/VirtualFileSystem.cpp index 6d96f16a..23b5fbc 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -11,8 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "clang/Basic/VirtualFileSystem.h" -#include "clang/Basic/LLVM.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" @@ -55,9 +54,8 @@ #include #include -using namespace clang; -using namespace vfs; using namespace llvm; +using namespace llvm::vfs; using llvm::sys::fs::file_status; using llvm::sys::fs::file_type; @@ -67,7 +65,7 @@ using llvm::sys::fs::UniqueID; Status::Status(const file_status &Status) : UID(Status.getUniqueID()), MTime(Status.getLastModificationTime()), User(Status.getUser()), Group(Status.getGroup()), Size(Status.getSize()), - Type(Status.type()), Perms(Status.permissions()) {} + Type(Status.type()), Perms(Status.permissions()) {} Status::Status(StringRef Name, UniqueID UID, sys::TimePoint<> MTime, uint32_t User, uint32_t Group, uint64_t Size, file_type Type, @@ -92,25 +90,17 @@ bool Status::equivalent(const Status &Other) const { return getUniqueID() == Other.getUniqueID(); } -bool Status::isDirectory() const { - return Type == file_type::directory_file; -} +bool Status::isDirectory() const { return Type == file_type::directory_file; } -bool Status::isRegularFile() const { - return Type == file_type::regular_file; -} +bool Status::isRegularFile() const { return Type == file_type::regular_file; } bool Status::isOther() const { return exists() && !isRegularFile() && !isDirectory() && !isSymlink(); } -bool Status::isSymlink() const { - return Type == file_type::symlink_file; -} +bool Status::isSymlink() const { return Type == file_type::symlink_file; } -bool Status::isStatusKnown() const { - return Type != file_type::status_error; -} +bool Status::isStatusKnown() const { return Type != file_type::status_error; } bool Status::exists() const { return isStatusKnown() && Type != file_type::file_not_found; @@ -245,6 +235,7 @@ public: std::error_code setCurrentWorkingDirectory(const Twine &Path) override; std::error_code getRealPath(const Twine &Path, SmallVectorImpl &Output) const override; + private: mutable std::mutex CWDMutex; mutable std::string CWDCache; @@ -310,7 +301,7 @@ IntrusiveRefCntPtr vfs::getRealFileSystem() { namespace { -class RealFSDirIter : public clang::vfs::detail::DirIterImpl { +class RealFSDirIter : public llvm::vfs::detail::DirIterImpl { llvm::sys::fs::directory_iterator Iter; public: @@ -395,11 +386,11 @@ OverlayFileSystem::getRealPath(const Twine &Path, return errc::no_such_file_or_directory; } -clang::vfs::detail::DirIterImpl::~DirIterImpl() = default; +llvm::vfs::detail::DirIterImpl::~DirIterImpl() = default; namespace { -class OverlayFSDirIterImpl : public clang::vfs::detail::DirIterImpl { +class OverlayFSDirIterImpl : public llvm::vfs::detail::DirIterImpl { OverlayFileSystem &Overlays; std::string Path; OverlayFileSystem::iterator CurrentFS; @@ -465,7 +456,7 @@ directory_iterator OverlayFileSystem::dir_begin(const Twine &Dir, std::make_shared(Dir, *this, EC)); } -namespace clang { +namespace llvm { namespace vfs { namespace detail { @@ -830,7 +821,7 @@ InMemoryFileSystem::openFileForRead(const Twine &Path) { namespace { /// Adaptor from InMemoryDir::iterator to directory_iterator. -class InMemoryDirIterator : public clang::vfs::detail::DirIterImpl { +class InMemoryDirIterator : public llvm::vfs::detail::DirIterImpl { detail::InMemoryDirectory::const_iterator I; detail::InMemoryDirectory::const_iterator E; std::string RequestedDirName; @@ -841,13 +832,13 @@ class InMemoryDirIterator : public clang::vfs::detail::DirIterImpl { llvm::sys::path::append(Path, I->second->getFileName()); sys::fs::file_type Type; switch (I->second->getKind()) { - case detail::IME_File: - case detail::IME_HardLink: - Type = sys::fs::file_type::regular_file; - break; - case detail::IME_Directory: - Type = sys::fs::file_type::directory_file; - break; + case detail::IME_File: + case detail::IME_HardLink: + Type = sys::fs::file_type::regular_file; + break; + case detail::IME_Directory: + Type = sys::fs::file_type::directory_file; + break; } CurrentEntry = directory_entry(Path.str(), Type); } else { @@ -923,7 +914,7 @@ InMemoryFileSystem::getRealPath(const Twine &Path, } } // namespace vfs -} // namespace clang +} // namespace llvm //===-----------------------------------------------------------------------===/ // RedirectingFileSystem implementation @@ -931,10 +922,7 @@ InMemoryFileSystem::getRealPath(const Twine &Path, namespace { -enum EntryKind { - EK_Directory, - EK_File -}; +enum EntryKind { EK_Directory, EK_File }; /// A single file or directory in the VFS. class Entry { @@ -980,11 +968,7 @@ public: class RedirectingFileEntry : public Entry { public: - enum NameKind { - NK_NotSet, - NK_External, - NK_Virtual - }; + enum NameKind { NK_NotSet, NK_External, NK_Virtual }; private: std::string ExternalContentsPath; @@ -1009,7 +993,7 @@ public: static bool classof(const Entry *E) { return E->getKind() == EK_File; } }; -class VFSFromYamlDirIterImpl : public clang::vfs::detail::DirIterImpl { +class VFSFromYamlDirIterImpl : public llvm::vfs::detail::DirIterImpl { std::string Dir; RedirectingDirectoryEntry::iterator Current, End; @@ -1162,7 +1146,7 @@ public: return ExternalFS->setCurrentWorkingDirectory(Path); } - directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override{ + directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override { ErrorOr E = lookupPath(Dir); if (!E) { EC = E.getError(); @@ -1192,21 +1176,20 @@ public: return ExternalContentsPrefixDir; } - bool ignoreNonExistentContents() const { - return IgnoreNonExistentContents; - } + bool ignoreNonExistentContents() const { return IgnoreNonExistentContents; } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) -LLVM_DUMP_METHOD void dump() const { + LLVM_DUMP_METHOD void dump() const { for (const auto &Root : Roots) dumpEntry(Root.get()); } -LLVM_DUMP_METHOD void dumpEntry(Entry *E, int NumSpaces = 0) const { + LLVM_DUMP_METHOD void dumpEntry(Entry *E, int NumSpaces = 0) const { StringRef Name = E->getName(); for (int i = 0, e = NumSpaces; i < e; ++i) dbgs() << " "; - dbgs() << "'" << Name.str().c_str() << "'" << "\n"; + dbgs() << "'" << Name.str().c_str() << "'" + << "\n"; if (E->getKind() == EK_Directory) { auto *DE = dyn_cast(E); @@ -1214,7 +1197,7 @@ LLVM_DUMP_METHOD void dumpEntry(Entry *E, int NumSpaces = 0) const { for (std::unique_ptr &SubEntry : llvm::make_range(DE->contents_begin(), DE->contents_end())) - dumpEntry(SubEntry.get(), NumSpaces+2); + dumpEntry(SubEntry.get(), NumSpaces + 2); } } #endif @@ -1224,9 +1207,7 @@ LLVM_DUMP_METHOD void dumpEntry(Entry *E, int NumSpaces = 0) const { class RedirectingFileSystemParser { yaml::Stream &Stream; - void error(yaml::Node *N, const Twine &Msg) { - Stream.printError(N, Msg); - } + void error(yaml::Node *N, const Twine &Msg) { Stream.printError(N, Msg); } // false on error bool parseScalarString(yaml::Node *N, StringRef &Result, @@ -1372,11 +1353,11 @@ class RedirectingFileSystemParser { } KeyStatusPair Fields[] = { - KeyStatusPair("name", true), - KeyStatusPair("type", true), - KeyStatusPair("contents", false), - KeyStatusPair("external-contents", false), - KeyStatusPair("use-external-name", false), + KeyStatusPair("name", true), + KeyStatusPair("type", true), + KeyStatusPair("contents", false), + KeyStatusPair("external-contents", false), + KeyStatusPair("use-external-name", false), }; DenseMap Keys(std::begin(Fields), std::end(Fields)); @@ -1516,7 +1497,7 @@ class RedirectingFileSystemParser { size_t RootPathLen = sys::path::root_path(Trimmed).size(); while (Trimmed.size() > RootPathLen && sys::path::is_separator(Trimmed.back())) - Trimmed = Trimmed.slice(0, Trimmed.size()-1); + Trimmed = Trimmed.slice(0, Trimmed.size() - 1); // Get the last component StringRef LastComponent = sys::path::filename(Trimmed); @@ -1564,12 +1545,12 @@ public: } KeyStatusPair Fields[] = { - KeyStatusPair("version", true), - KeyStatusPair("case-sensitive", false), - KeyStatusPair("use-external-names", false), - KeyStatusPair("overlay-relative", false), - KeyStatusPair("ignore-non-existent-contents", false), - KeyStatusPair("roots", true), + KeyStatusPair("version", true), + KeyStatusPair("case-sensitive", false), + KeyStatusPair("use-external-names", false), + KeyStatusPair("overlay-relative", false), + KeyStatusPair("ignore-non-existent-contents", false), + KeyStatusPair("roots", true), }; DenseMap Keys(std::begin(Fields), std::end(Fields)); @@ -1852,8 +1833,7 @@ RedirectingFileSystem::openFileForRead(const Twine &Path) { IntrusiveRefCntPtr vfs::getVFSFromYAML(std::unique_ptr Buffer, SourceMgr::DiagHandlerTy DiagHandler, - StringRef YAMLFilePath, - void *DiagContext, + StringRef YAMLFilePath, void *DiagContext, IntrusiveRefCntPtr ExternalFS) { return RedirectingFileSystem::create(std::move(Buffer), DiagHandler, YAMLFilePath, DiagContext, @@ -2008,8 +1988,8 @@ void JSONWriter::write(ArrayRef Entries, bool UseOverlayRelative = false; if (IsOverlayRelative.hasValue()) { UseOverlayRelative = IsOverlayRelative.getValue(); - OS << " 'overlay-relative': '" - << (UseOverlayRelative ? "true" : "false") << "',\n"; + OS << " 'overlay-relative': '" << (UseOverlayRelative ? "true" : "false") + << "',\n"; } if (IgnoreNonExistentContents.hasValue()) OS << " 'ignore-non-existent-contents': '" @@ -2092,12 +2072,12 @@ std::error_code VFSFromYamlDirIterImpl::incrementImpl() { llvm::sys::path::append(PathStr, (*Current)->getName()); sys::fs::file_type Type; switch ((*Current)->getKind()) { - case EK_Directory: - Type = sys::fs::file_type::directory_file; - break; - case EK_File: - Type = sys::fs::file_type::regular_file; - break; + case EK_Directory: + Type = sys::fs::file_type::directory_file; + break; + case EK_File: + Type = sys::fs::file_type::regular_file; + break; } CurrentEntry = directory_entry(PathStr.str(), Type); break; @@ -2108,9 +2088,8 @@ std::error_code VFSFromYamlDirIterImpl::incrementImpl() { return {}; } -vfs::recursive_directory_iterator::recursive_directory_iterator(FileSystem &FS_, - const Twine &Path, - std::error_code &EC) +vfs::recursive_directory_iterator::recursive_directory_iterator( + FileSystem &FS_, const Twine &Path, std::error_code &EC) : FS(&FS_) { directory_iterator I = FS->dir_begin(Path, EC); if (I != directory_iterator()) { diff --git a/llvm/unittests/Support/CMakeLists.txt b/llvm/unittests/Support/CMakeLists.txt index 2353e15..f9c877f 100644 --- a/llvm/unittests/Support/CMakeLists.txt +++ b/llvm/unittests/Support/CMakeLists.txt @@ -68,6 +68,7 @@ add_llvm_unittest(SupportTests TrigramIndexTest.cpp UnicodeTest.cpp VersionTupleTest.cpp + VirtualFileSystemTest.cpp YAMLIOTest.cpp YAMLParserTest.cpp formatted_raw_ostream_test.cpp diff --git a/clang/unittests/Basic/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp similarity index 89% rename from clang/unittests/Basic/VirtualFileSystemTest.cpp rename to llvm/unittests/Support/VirtualFileSystemTest.cpp index 8bc8736..58d9285 100644 --- a/clang/unittests/Basic/VirtualFileSystemTest.cpp +++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp @@ -1,4 +1,4 @@ -//===- unittests/Basic/VirtualFileSystem.cpp ---------------- VFS tests ---===// +//===- unittests/Support/VirtualFileSystem.cpp -------------- VFS tests ---===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "clang/Basic/VirtualFileSystem.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/ADT/Triple.h" #include "llvm/Config/llvm-config.h" #include "llvm/Support/Errc.h" @@ -20,7 +20,6 @@ #include #include -using namespace clang; using namespace llvm; using llvm::sys::fs::UniqueID; using testing::ElementsAre; @@ -89,14 +88,14 @@ public: return std::error_code(); } - struct DirIterImpl : public clang::vfs::detail::DirIterImpl { + struct DirIterImpl : public llvm::vfs::detail::DirIterImpl { std::map &FilesAndDirs; std::map::iterator I; std::string Path; bool isInPath(StringRef S) { if (Path.size() < S.size() && S.find(Path) == 0) { auto LastSep = S.find_last_of('/'); - if (LastSep == Path.size() || LastSep == Path.size()-1) + if (LastSep == Path.size() || LastSep == Path.size() - 1) return true; } return false; @@ -105,7 +104,7 @@ public: const Twine &_Path) : FilesAndDirs(FilesAndDirs), I(FilesAndDirs.begin()), Path(_Path.str()) { - for ( ; I != FilesAndDirs.end(); ++I) { + for (; I != FilesAndDirs.end(); ++I) { if (isInPath(I->first)) { CurrentEntry = vfs::directory_entry(I->second.getName(), I->second.getType()); @@ -115,7 +114,7 @@ public: } std::error_code increment() override { ++I; - for ( ; I != FilesAndDirs.end(); ++I) { + for (; I != FilesAndDirs.end(); ++I) { if (isInPath(I->first)) { CurrentEntry = vfs::directory_entry(I->second.getName(), I->second.getType()); @@ -337,7 +336,7 @@ TEST(VirtualFileSystemTest, MergedDirPermissions) { Lower->addRegularFile("/both/foo", sys::fs::owner_read); Upper->addRegularFile("/both/bar", sys::fs::owner_write); Status = O->status("/both/foo"); - ASSERT_FALSE( Status.getError()); + ASSERT_FALSE(Status.getError()); EXPECT_EQ(0400, Status->getPermissions()); Status = O->status("/both/bar"); ASSERT_FALSE(Status.getError()); @@ -347,10 +346,10 @@ TEST(VirtualFileSystemTest, MergedDirPermissions) { namespace { struct ScopedDir { SmallString<128> Path; - ScopedDir(const Twine &Name, bool Unique=false) { + ScopedDir(const Twine &Name, bool Unique = false) { std::error_code EC; if (Unique) { - EC = llvm::sys::fs::createUniqueDirectory(Name, Path); + EC = llvm::sys::fs::createUniqueDirectory(Name, Path); } else { Path = Name.str(); EC = llvm::sys::fs::create_directory(Twine(Path)); @@ -386,7 +385,7 @@ struct ScopedLink { } // end anonymous namespace TEST(VirtualFileSystemTest, BasicRealFSIteration) { - ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); + ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); std::error_code EC; @@ -394,10 +393,10 @@ TEST(VirtualFileSystemTest, BasicRealFSIteration) { ASSERT_FALSE(EC); EXPECT_EQ(vfs::directory_iterator(), I); // empty directory is empty - ScopedDir _a(TestDirectory+"/a"); - ScopedDir _ab(TestDirectory+"/a/b"); - ScopedDir _c(TestDirectory+"/c"); - ScopedDir _cd(TestDirectory+"/c/d"); + ScopedDir _a(TestDirectory + "/a"); + ScopedDir _ab(TestDirectory + "/a/b"); + ScopedDir _c(TestDirectory + "/c"); + ScopedDir _cd(TestDirectory + "/c/d"); I = FS->dir_begin(Twine(TestDirectory), EC); ASSERT_FALSE(EC); @@ -441,7 +440,7 @@ TEST(VirtualFileSystemTest, BrokenSymlinkRealFSIteration) { #endif TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) { - ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); + ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); std::error_code EC; @@ -449,10 +448,10 @@ TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) { ASSERT_FALSE(EC); EXPECT_EQ(vfs::recursive_directory_iterator(), I); // empty directory is empty - ScopedDir _a(TestDirectory+"/a"); - ScopedDir _ab(TestDirectory+"/a/b"); - ScopedDir _c(TestDirectory+"/c"); - ScopedDir _cd(TestDirectory+"/c/d"); + ScopedDir _a(TestDirectory + "/a"); + ScopedDir _ab(TestDirectory + "/a/b"); + ScopedDir _c(TestDirectory + "/c"); + ScopedDir _cd(TestDirectory + "/c/d"); I = vfs::recursive_directory_iterator(*FS, Twine(TestDirectory), EC); ASSERT_FALSE(EC); @@ -466,10 +465,10 @@ TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) { // Check contents, which may be in any order EXPECT_EQ(4U, Contents.size()); - int Counts[4] = { 0, 0, 0, 0 }; + int Counts[4] = {0, 0, 0, 0}; for (const std::string &Name : Contents) { ASSERT_FALSE(Name.empty()); - int Index = Name[Name.size()-1] - 'a'; + int Index = Name[Name.size() - 1] - 'a'; ASSERT_TRUE(Index >= 0 && Index < 4); Counts[Index]++; } @@ -648,7 +647,7 @@ TEST(VirtualFileSystemTest, HiddenInIteration) { { std::error_code EC; vfs::directory_iterator I = O->dir_begin("/", EC), E; - for ( ; !EC && I != E; I.increment(EC)) + for (; !EC && I != E; I.increment(EC)) if (I->path() == "/hiddenByUp") break; ASSERT_NE(E, I); @@ -657,7 +656,7 @@ TEST(VirtualFileSystemTest, HiddenInIteration) { { std::error_code EC; vfs::directory_iterator I = O->dir_begin("/", EC), E; - for ( ; !EC && I != E; I.increment(EC)) + for (; !EC && I != E; I.increment(EC)) if (I->path() == "/hiddenByMid") break; ASSERT_NE(E, I); @@ -667,8 +666,8 @@ TEST(VirtualFileSystemTest, HiddenInIteration) { class InMemoryFileSystemTest : public ::testing::Test { protected: - clang::vfs::InMemoryFileSystem FS; - clang::vfs::InMemoryFileSystem NormalizedFS; + llvm::vfs::InMemoryFileSystem FS; + llvm::vfs::InMemoryFileSystem NormalizedFS; InMemoryFileSystemTest() : FS(/*UseNormalizedPaths=*/false), @@ -687,7 +686,7 @@ MATCHER_P2(IsHardLinkTo, FS, Target, "") { TEST_F(InMemoryFileSystemTest, IsEmpty) { auto Stat = FS.status("/a"); - ASSERT_EQ(Stat.getError(),errc::no_such_file_or_directory) << FS.toString(); + ASSERT_EQ(Stat.getError(), errc::no_such_file_or_directory) << FS.toString(); Stat = FS.status("/"); ASSERT_EQ(Stat.getError(), errc::no_such_file_or_directory) << FS.toString(); } @@ -881,18 +880,20 @@ TEST_F(InMemoryFileSystemTest, AddFileWithFileType) { } TEST_F(InMemoryFileSystemTest, AddFileWithPerms) { - FS.addFile("/a/b/c", 0, MemoryBuffer::getMemBuffer("abc"), None, None, - None, sys::fs::perms::owner_read | sys::fs::perms::owner_write); + FS.addFile("/a/b/c", 0, MemoryBuffer::getMemBuffer("abc"), None, None, None, + sys::fs::perms::owner_read | sys::fs::perms::owner_write); auto Stat = FS.status("/a"); ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString(); ASSERT_TRUE(Stat->isDirectory()); ASSERT_EQ(sys::fs::perms::owner_read | sys::fs::perms::owner_write | - sys::fs::perms::owner_exe, Stat->getPermissions()); + sys::fs::perms::owner_exe, + Stat->getPermissions()); Stat = FS.status("/a/b"); ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString(); ASSERT_TRUE(Stat->isDirectory()); ASSERT_EQ(sys::fs::perms::owner_read | sys::fs::perms::owner_write | - sys::fs::perms::owner_exe, Stat->getPermissions()); + sys::fs::perms::owner_exe, + Stat->getPermissions()); Stat = FS.status("/a/b/c"); ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString(); ASSERT_TRUE(Stat->isRegularFile()); @@ -940,7 +941,7 @@ TEST_F(InMemoryFileSystemTest, StatusName) { // Access using a directory iterator. std::error_code EC; - clang::vfs::directory_iterator It = NormalizedFS.dir_begin("../b", EC); + llvm::vfs::directory_iterator It = NormalizedFS.dir_begin("../b", EC); // When on Windows, we end up with "../b\\c" as the name. Convert to Posix // path for the sake of the comparison. ASSERT_EQ("../b/c", getPosixPath(It->path())); @@ -1098,26 +1099,26 @@ TEST_F(VFSFromYAMLTest, BasicVFSFromYAML) { TEST_F(VFSFromYAMLTest, MappedFiles) { IntrusiveRefCntPtr Lower(new DummyFileSystem()); Lower->addRegularFile("//root/foo/bar/a"); - IntrusiveRefCntPtr FS = - getFromYAMLString("{ 'roots': [\n" - "{\n" - " 'type': 'directory',\n" - " 'name': '//root/',\n" - " 'contents': [ {\n" - " 'type': 'file',\n" - " 'name': 'file1',\n" - " 'external-contents': '//root/foo/bar/a'\n" - " },\n" - " {\n" - " 'type': 'file',\n" - " 'name': 'file2',\n" - " 'external-contents': '//root/foo/b'\n" - " }\n" - " ]\n" - "}\n" - "]\n" - "}", - Lower); + IntrusiveRefCntPtr FS = getFromYAMLString( + "{ 'roots': [\n" + "{\n" + " 'type': 'directory',\n" + " 'name': '//root/',\n" + " 'contents': [ {\n" + " 'type': 'file',\n" + " 'name': 'file1',\n" + " 'external-contents': '//root/foo/bar/a'\n" + " },\n" + " {\n" + " 'type': 'file',\n" + " 'name': 'file2',\n" + " 'external-contents': '//root/foo/b'\n" + " }\n" + " ]\n" + "}\n" + "]\n" + "}", + Lower); ASSERT_TRUE(FS.get() != nullptr); IntrusiveRefCntPtr O( @@ -1158,20 +1159,20 @@ TEST_F(VFSFromYAMLTest, MappedFiles) { TEST_F(VFSFromYAMLTest, CaseInsensitive) { IntrusiveRefCntPtr Lower(new DummyFileSystem()); Lower->addRegularFile("//root/foo/bar/a"); - IntrusiveRefCntPtr FS = - getFromYAMLString("{ 'case-sensitive': 'false',\n" - " 'roots': [\n" - "{\n" - " 'type': 'directory',\n" - " 'name': '//root/',\n" - " 'contents': [ {\n" - " 'type': 'file',\n" - " 'name': 'XX',\n" - " 'external-contents': '//root/foo/bar/a'\n" - " }\n" - " ]\n" - "}]}", - Lower); + IntrusiveRefCntPtr FS = getFromYAMLString( + "{ 'case-sensitive': 'false',\n" + " 'roots': [\n" + "{\n" + " 'type': 'directory',\n" + " 'name': '//root/',\n" + " 'contents': [ {\n" + " 'type': 'file',\n" + " 'name': 'XX',\n" + " 'external-contents': '//root/foo/bar/a'\n" + " }\n" + " ]\n" + "}]}", + Lower); ASSERT_TRUE(FS.get() != nullptr); IntrusiveRefCntPtr O( @@ -1194,20 +1195,20 @@ TEST_F(VFSFromYAMLTest, CaseInsensitive) { TEST_F(VFSFromYAMLTest, CaseSensitive) { IntrusiveRefCntPtr Lower(new DummyFileSystem()); Lower->addRegularFile("//root/foo/bar/a"); - IntrusiveRefCntPtr FS = - getFromYAMLString("{ 'case-sensitive': 'true',\n" - " 'roots': [\n" - "{\n" - " 'type': 'directory',\n" - " 'name': '//root/',\n" - " 'contents': [ {\n" - " 'type': 'file',\n" - " 'name': 'XX',\n" - " 'external-contents': '//root/foo/bar/a'\n" - " }\n" - " ]\n" - "}]}", - Lower); + IntrusiveRefCntPtr FS = getFromYAMLString( + "{ 'case-sensitive': 'true',\n" + " 'roots': [\n" + "{\n" + " 'type': 'directory',\n" + " 'name': '//root/',\n" + " 'contents': [ {\n" + " 'type': 'file',\n" + " 'name': 'XX',\n" + " 'external-contents': '//root/foo/bar/a'\n" + " }\n" + " ]\n" + "}]}", + Lower); ASSERT_TRUE(FS.get() != nullptr); IntrusiveRefCntPtr O( @@ -1318,20 +1319,21 @@ TEST_F(VFSFromYAMLTest, UseExternalName) { IntrusiveRefCntPtr Lower(new DummyFileSystem()); Lower->addRegularFile("//root/external/file"); - IntrusiveRefCntPtr FS = getFromYAMLString( - "{ 'roots': [\n" - " { 'type': 'file', 'name': '//root/A',\n" - " 'external-contents': '//root/external/file'\n" - " },\n" - " { 'type': 'file', 'name': '//root/B',\n" - " 'use-external-name': true,\n" - " 'external-contents': '//root/external/file'\n" - " },\n" - " { 'type': 'file', 'name': '//root/C',\n" - " 'use-external-name': false,\n" - " 'external-contents': '//root/external/file'\n" - " }\n" - "] }", Lower); + IntrusiveRefCntPtr FS = + getFromYAMLString("{ 'roots': [\n" + " { 'type': 'file', 'name': '//root/A',\n" + " 'external-contents': '//root/external/file'\n" + " },\n" + " { 'type': 'file', 'name': '//root/B',\n" + " 'use-external-name': true,\n" + " 'external-contents': '//root/external/file'\n" + " },\n" + " { 'type': 'file', 'name': '//root/C',\n" + " 'use-external-name': false,\n" + " 'external-contents': '//root/external/file'\n" + " }\n" + "] }", + Lower); ASSERT_TRUE(nullptr != FS.get()); // default true @@ -1341,21 +1343,21 @@ TEST_F(VFSFromYAMLTest, UseExternalName) { EXPECT_EQ("//root/C", FS->status("//root/C")->getName()); // global configuration - FS = getFromYAMLString( - "{ 'use-external-names': false,\n" - " 'roots': [\n" - " { 'type': 'file', 'name': '//root/A',\n" - " 'external-contents': '//root/external/file'\n" - " },\n" - " { 'type': 'file', 'name': '//root/B',\n" - " 'use-external-name': true,\n" - " 'external-contents': '//root/external/file'\n" - " },\n" - " { 'type': 'file', 'name': '//root/C',\n" - " 'use-external-name': false,\n" - " 'external-contents': '//root/external/file'\n" - " }\n" - "] }", Lower); + FS = getFromYAMLString("{ 'use-external-names': false,\n" + " 'roots': [\n" + " { 'type': 'file', 'name': '//root/A',\n" + " 'external-contents': '//root/external/file'\n" + " },\n" + " { 'type': 'file', 'name': '//root/B',\n" + " 'use-external-name': true,\n" + " 'external-contents': '//root/external/file'\n" + " },\n" + " { 'type': 'file', 'name': '//root/C',\n" + " 'use-external-name': false,\n" + " 'external-contents': '//root/external/file'\n" + " }\n" + "] }", + Lower); ASSERT_TRUE(nullptr != FS.get()); // default @@ -1370,11 +1372,12 @@ TEST_F(VFSFromYAMLTest, MultiComponentPath) { Lower->addRegularFile("//root/other"); // file in roots - IntrusiveRefCntPtr FS = getFromYAMLString( - "{ 'roots': [\n" - " { 'type': 'file', 'name': '//root/path/to/file',\n" - " 'external-contents': '//root/other' }]\n" - "}", Lower); + IntrusiveRefCntPtr FS = + getFromYAMLString("{ 'roots': [\n" + " { 'type': 'file', 'name': '//root/path/to/file',\n" + " 'external-contents': '//root/other' }]\n" + "}", + Lower); ASSERT_TRUE(nullptr != FS.get()); EXPECT_FALSE(FS->status("//root/path/to/file").getError()); EXPECT_FALSE(FS->status("//root/path/to").getError()); @@ -1387,7 +1390,8 @@ TEST_F(VFSFromYAMLTest, MultiComponentPath) { " { 'type': 'directory', 'name': '//root/path/to',\n" " 'contents': [ { 'type': 'file', 'name': 'file',\n" " 'external-contents': '//root/other' }]}]\n" - "}", Lower); + "}", + Lower); ASSERT_TRUE(nullptr != FS.get()); EXPECT_FALSE(FS->status("//root/path/to/file").getError()); EXPECT_FALSE(FS->status("//root/path/to").getError()); @@ -1400,7 +1404,8 @@ TEST_F(VFSFromYAMLTest, MultiComponentPath) { " { 'type': 'directory', 'name': '//root/',\n" " 'contents': [ { 'type': 'file', 'name': 'path/to/file',\n" " 'external-contents': '//root/other' }]}]\n" - "}", Lower); + "}", + Lower); ASSERT_TRUE(nullptr != FS.get()); EXPECT_FALSE(FS->status("//root/path/to/file").getError()); EXPECT_FALSE(FS->status("//root/path/to").getError()); @@ -1418,7 +1423,8 @@ TEST_F(VFSFromYAMLTest, TrailingSlashes) { " { 'type': 'directory', 'name': '//root/path/to////',\n" " 'contents': [ { 'type': 'file', 'name': 'file',\n" " 'external-contents': '//root/other' }]}]\n" - "}", Lower); + "}", + Lower); ASSERT_TRUE(nullptr != FS.get()); EXPECT_FALSE(FS->status("//root/path/to/file").getError()); EXPECT_FALSE(FS->status("//root/path/to").getError()); @@ -1434,27 +1440,27 @@ TEST_F(VFSFromYAMLTest, DirectoryIteration) { Lower->addRegularFile("//root/foo/bar/a"); Lower->addRegularFile("//root/foo/bar/b"); Lower->addRegularFile("//root/file3"); - IntrusiveRefCntPtr FS = - getFromYAMLString("{ 'use-external-names': false,\n" - " 'roots': [\n" - "{\n" - " 'type': 'directory',\n" - " 'name': '//root/',\n" - " 'contents': [ {\n" - " 'type': 'file',\n" - " 'name': 'file1',\n" - " 'external-contents': '//root/foo/bar/a'\n" - " },\n" - " {\n" - " 'type': 'file',\n" - " 'name': 'file2',\n" - " 'external-contents': '//root/foo/bar/b'\n" - " }\n" - " ]\n" - "}\n" - "]\n" - "}", - Lower); + IntrusiveRefCntPtr FS = getFromYAMLString( + "{ 'use-external-names': false,\n" + " 'roots': [\n" + "{\n" + " 'type': 'directory',\n" + " 'name': '//root/',\n" + " 'contents': [ {\n" + " 'type': 'file',\n" + " 'name': 'file1',\n" + " 'external-contents': '//root/foo/bar/a'\n" + " },\n" + " {\n" + " 'type': 'file',\n" + " 'name': 'file2',\n" + " 'external-contents': '//root/foo/bar/b'\n" + " }\n" + " ]\n" + "}\n" + "]\n" + "}", + Lower); ASSERT_TRUE(FS.get() != nullptr); IntrusiveRefCntPtr O( @@ -1550,7 +1556,8 @@ TEST_F(VFSFromYAMLTest, RecursiveDirectoryIterationLevel) { // Test recursive_directory_iterator level() vfs::recursive_directory_iterator I = vfs::recursive_directory_iterator( - *O, "//root", EC), E; + *O, "//root", EC), + E; ASSERT_FALSE(EC); for (int l = 0; I != E; I.increment(EC), ++l) { ASSERT_FALSE(EC); @@ -1567,25 +1574,27 @@ TEST_F(VFSFromYAMLTest, RelativePaths) { " { 'type': 'file', 'name': 'file-not-in-directory.h',\n" " 'external-contents': '//root/external/file'\n" " }\n" - "] }", Lower); + "] }", + Lower); EXPECT_EQ(nullptr, FS.get()); // Relative file path. - FS = getFromYAMLString( - "{ 'roots': [\n" - " { 'type': 'file', 'name': 'relative/file/path.h',\n" - " 'external-contents': '//root/external/file'\n" - " }\n" - "] }", Lower); + FS = getFromYAMLString("{ 'roots': [\n" + " { 'type': 'file', 'name': 'relative/file/path.h',\n" + " 'external-contents': '//root/external/file'\n" + " }\n" + "] }", + Lower); EXPECT_EQ(nullptr, FS.get()); // Relative directory path. FS = getFromYAMLString( - "{ 'roots': [\n" - " { 'type': 'directory', 'name': 'relative/directory/path.h',\n" - " 'contents': []\n" - " }\n" - "] }", Lower); + "{ 'roots': [\n" + " { 'type': 'directory', 'name': 'relative/directory/path.h',\n" + " 'contents': []\n" + " }\n" + "] }", + Lower); EXPECT_EQ(nullptr, FS.get()); EXPECT_EQ(3, NumDiagnostics); -- 2.7.4