diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-10-10 13:27:25 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-10-10 13:27:25 +0000 |
commit | fc51490baf1d6ad5796d8cb8bb0792de13ce8fce (patch) | |
tree | bae0cfa9002258ffad07524d654245ed3b918cb1 /clang/unittests/Lex/PPCallbacksTest.cpp | |
parent | c616a7236c83994cacdbc13e37269bbc9598093d (diff) | |
download | bcm5719-llvm-fc51490baf1d6ad5796d8cb8bb0792de13ce8fce.tar.gz bcm5719-llvm-fc51490baf1d6ad5796d8cb8bb0792de13ce8fce.zip |
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
Diffstat (limited to 'clang/unittests/Lex/PPCallbacksTest.cpp')
-rw-r--r-- | clang/unittests/Lex/PPCallbacksTest.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/clang/unittests/Lex/PPCallbacksTest.cpp b/clang/unittests/Lex/PPCallbacksTest.cpp index 0fa6286cc04..d0ff45ec7cc 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<vfs::InMemoryFileSystem> InMemoryFileSystem; + IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem; FileManager FileMgr; IntrusiveRefCntPtr<DiagnosticIDs> DiagID; IntrusiveRefCntPtr<DiagnosticOptions> 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<llvm::MemoryBuffer> 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; } }; |