summaryrefslogtreecommitdiff
path: root/include/clang/Basic/VirtualFileSystem.h
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-05-20 21:43:27 +0000
committerJustin Bogner <mail@justinbogner.com>2014-05-20 21:43:27 +0000
commit99b5a85324c758f15a72fdf084240f3c2af8ce35 (patch)
tree9b59cdee6b4f29aa96613de81b9ef74ae98d0b1c /include/clang/Basic/VirtualFileSystem.h
parentaddbfc942181c163fe2fb2e436dcbcf0594ded1d (diff)
downloadclang-99b5a85324c758f15a72fdf084240f3c2af8ce35.tar.gz
clang-99b5a85324c758f15a72fdf084240f3c2af8ce35.tar.bz2
clang-99b5a85324c758f15a72fdf084240f3c2af8ce35.tar.xz
VirtualFileSystem: Add YAMLVFSWriter to generate VFS mapping files
This moves the logic to write a JSON VFS mapping from the C api into VirtualFileSystem, so that we can use it internally. No functional change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209241 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/VirtualFileSystem.h')
-rw-r--r--include/clang/Basic/VirtualFileSystem.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/clang/Basic/VirtualFileSystem.h b/include/clang/Basic/VirtualFileSystem.h
index ec2ca7050a..e4582c8028 100644
--- a/include/clang/Basic/VirtualFileSystem.h
+++ b/include/clang/Basic/VirtualFileSystem.h
@@ -15,8 +15,10 @@
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/SourceMgr.h"
namespace llvm {
@@ -166,6 +168,34 @@ getVFSFromYAML(llvm::MemoryBuffer *Buffer,
void *DiagContext = nullptr,
IntrusiveRefCntPtr<FileSystem> ExternalFS = getRealFileSystem());
+class YAMLVFSWriter {
+ struct MapEntry {
+ template <typename T1, typename T2> MapEntry(T1 &&VPath, T2 &&RPath)
+ : VPath(std::forward<T1>(VPath)), RPath(std::forward<T2>(RPath)) {}
+ std::string VPath;
+ std::string RPath;
+ };
+ std::vector<MapEntry> Mappings;
+ Optional<bool> IsCaseSensitive;
+
+ llvm::ArrayRef<MapEntry> printDirNodes(llvm::raw_ostream &OS,
+ llvm::ArrayRef<MapEntry> Entries,
+ StringRef ParentPath, unsigned Indent);
+ llvm::ArrayRef<MapEntry> printContents(llvm::raw_ostream &OS,
+ llvm::ArrayRef<MapEntry> Entries,
+ unsigned Indent);
+ bool containedIn(StringRef Parent, StringRef Path);
+ StringRef containedPart(StringRef Parent, StringRef Path);
+
+public:
+ YAMLVFSWriter() {}
+ void addFileMapping(StringRef VirtualPath, StringRef RealPath);
+ void setCaseSensitivity(bool CaseSensitive) {
+ IsCaseSensitive = CaseSensitive;
+ }
+ void write(llvm::raw_ostream &OS);
+};
+
} // end namespace vfs
} // end namespace clang
#endif // LLVM_CLANG_BASIC_VIRTUAL_FILE_SYSTEM_H