On Feb 19, 2014, at 2:03 AM, Dmitri Gribenko <[email protected]> wrote:
> On Wed, Feb 19, 2014 at 3:29 AM, Ben Langmuir <[email protected]> wrote: >> Author: benlangmuir >> Date: Tue Feb 18 21:29:17 2014 >> New Revision: 201635 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=201635&view=rev >> Log: >> Add an OverlayFileSystem class >> >> Provides a way to merge multiple vfs::FileSystem objects into a single >> filesystem. >> >> Added: >> cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp >> Modified: >> cfe/trunk/include/clang/Basic/VirtualFileSystem.h >> cfe/trunk/lib/Basic/VirtualFileSystem.cpp >> cfe/trunk/unittests/Basic/CMakeLists.txt >> >> Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=201635&r1=201634&r2=201635&view=diff >> ============================================================================== >> --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original) >> +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Tue Feb 18 21:29:17 >> 2014 >> @@ -122,6 +122,42 @@ public: >> /// the operating system. >> llvm::IntrusiveRefCntPtr<FileSystem> getRealFileSystem(); >> >> +/// \brief A file system that allows overlaying one \p AbstractFileSystem >> on top >> +/// of another. >> +/// >> +/// Consists of a stack of >=1 \p FileSytem objects, which are treated as >> being >> +/// one merged file system. When there is a directory that exists in more >> than >> +/// one file system, the \p OverlayFileSystem contains a directory >> containing >> +/// the union of their contents. The attributes (permissions, etc.) of the >> +/// top-most (most recently added) directory are used. When there is a file >> +/// that exists in more than one file system, the file in the top-most file >> +/// system overrides the other(s). >> +class OverlayFileSystem : public FileSystem { >> + typedef llvm::SmallVector<llvm::IntrusiveRefCntPtr<FileSystem>, 1> >> + FileSystemList; >> + typedef FileSystemList::reverse_iterator iterator; >> + >> + /// \brief The stack of file systems, implemented as a list in order of >> + /// their addition. >> + FileSystemList FSList; >> + >> + /// \brief Get an iterator pointing to the most recently added file >> system. >> + iterator overlays_begin() { return FSList.rbegin(); } >> + >> + /// \brief Get an iterator pointing one-past the least recently added file >> + /// system. >> + iterator overlays_end() { return FSList.rend(); } >> + >> +public: >> + OverlayFileSystem(llvm::IntrusiveRefCntPtr<FileSystem> Base); >> + /// \brief Pushes a file system on top of the stack. >> + void pushOverlay(llvm::IntrusiveRefCntPtr<FileSystem> FS); >> + >> + llvm::ErrorOr<Status> status(const llvm::Twine &Path) LLVM_OVERRIDE; >> + llvm::error_code openFileForRead(const llvm::Twine &Path, >> + llvm::OwningPtr<File> &Result) >> LLVM_OVERRIDE; > > You can drop qualifiers on SmallVector, OwningPtr, Twine and > IntrusiveRefCntPtr if you #include "clang/Basic/LLVM.h”. I have a patch to do exactly that :) I should get that in this morning. > >> +TEST(VirtualFileSystemTest, status_queries) { > > We usually name gtest test cases in camel case as well. Will do. Thanks, Ben > > Dmitri > > -- > main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if > (j){printf("%d\n",i);}}} /*Dmitri Gribenko <[email protected]>*/ _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
