OLD | NEW |
(Empty) | |
| 1 //===-- FileRemapper.h - File Remapping Helper ------------------*- C++ -*-===// |
| 2 // |
| 3 // The LLVM Compiler Infrastructure |
| 4 // |
| 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. |
| 7 // |
| 8 //===----------------------------------------------------------------------===// |
| 9 |
| 10 #ifndef LLVM_CLANG_ARCMIGRATE_FILEREMAPPER_H |
| 11 #define LLVM_CLANG_ARCMIGRATE_FILEREMAPPER_H |
| 12 |
| 13 #include "clang/Basic/LLVM.h" |
| 14 #include "llvm/ADT/OwningPtr.h" |
| 15 #include "llvm/ADT/PointerUnion.h" |
| 16 #include "llvm/ADT/DenseMap.h" |
| 17 #include "llvm/ADT/StringRef.h" |
| 18 |
| 19 namespace llvm { |
| 20 class MemoryBuffer; |
| 21 } |
| 22 |
| 23 namespace clang { |
| 24 class FileManager; |
| 25 class FileEntry; |
| 26 class Diagnostic; |
| 27 class CompilerInvocation; |
| 28 |
| 29 namespace arcmt_hack { |
| 30 |
| 31 class FileRemapper { |
| 32 // FIXME: Reuse the same FileManager for multiple ASTContexts. |
| 33 llvm::OwningPtr<FileManager> FileMgr; |
| 34 |
| 35 typedef llvm::PointerUnion<const FileEntry *, llvm::MemoryBuffer *> Target; |
| 36 typedef llvm::DenseMap<const FileEntry *, Target> MappingsTy; |
| 37 MappingsTy FromToMappings; |
| 38 |
| 39 llvm::DenseMap<const FileEntry *, const FileEntry *> ToFromMappings; |
| 40 |
| 41 public: |
| 42 FileRemapper(); |
| 43 ~FileRemapper(); |
| 44 |
| 45 bool initFromDisk(StringRef outputDir, Diagnostic &Diag, |
| 46 bool ignoreIfFilesChanged); |
| 47 bool flushToDisk(StringRef outputDir, Diagnostic &Diag); |
| 48 |
| 49 bool overwriteOriginal(Diagnostic &Diag, |
| 50 StringRef outputDir = StringRef()); |
| 51 |
| 52 bool writeParallelTree(StringRef outputDir, |
| 53 Diagnostic& Diag); |
| 54 |
| 55 void remap(StringRef filePath, llvm::MemoryBuffer *memBuf); |
| 56 void remap(StringRef filePath, StringRef newPath); |
| 57 |
| 58 void applyMappings(CompilerInvocation &CI) const; |
| 59 |
| 60 void transferMappingsAndClear(CompilerInvocation &CI); |
| 61 |
| 62 void clear(StringRef outputDir = StringRef()); |
| 63 |
| 64 private: |
| 65 void remap(const FileEntry *file, llvm::MemoryBuffer *memBuf); |
| 66 void remap(const FileEntry *file, const FileEntry *newfile); |
| 67 |
| 68 const FileEntry *getOriginalFile(StringRef filePath); |
| 69 void resetTarget(Target &targ); |
| 70 |
| 71 bool report(const Twine &err, Diagnostic &Diag); |
| 72 |
| 73 std::string getRemapInfoFile(StringRef outputDir); |
| 74 }; |
| 75 |
| 76 } // end namespace arcmt |
| 77 |
| 78 } // end namespace clang |
| 79 |
| 80 #endif |
OLD | NEW |