clang 8.0.0

FileRemapper.h
Go to the documentation of this file.
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/DenseMap.h"
15 #include "llvm/ADT/PointerUnion.h"
16 #include "llvm/ADT/StringRef.h"
17 #include <memory>
18
19 namespace llvm {
20 class MemoryBuffer;
21 }
22
23 namespace clang {
24 class FileManager;
25 class FileEntry;
26 class DiagnosticsEngine;
27 class PreprocessorOptions;
28
29 namespace arcmt {
30
31 class FileRemapper {
32 // FIXME: Reuse the same FileManager for multiple ASTContexts.
33 std::unique_ptr<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, DiagnosticsEngine &Diag,
46 bool ignoreIfFilesChanged);
47 bool initFromFile(StringRef filePath, DiagnosticsEngine &Diag,
48 bool ignoreIfFilesChanged);
49 bool flushToDisk(StringRef outputDir, DiagnosticsEngine &Diag);
50 bool flushToFile(StringRef outputPath, DiagnosticsEngine &Diag);
51
52 bool overwriteOriginal(DiagnosticsEngine &Diag,
53 StringRef outputDir = StringRef());
54
55 void remap(StringRef filePath, std::unique_ptr<llvm::MemoryBuffer> memBuf);
56
57 void applyMappings(PreprocessorOptions &PPOpts) const;
58
59 void clear(StringRef outputDir = StringRef());
60
61 private:
62 void remap(const FileEntry *file, std::unique_ptr<llvm::MemoryBuffer> memBuf);
63 void remap(const FileEntry *file, const FileEntry *newfile);
64
65 const FileEntry *getOriginalFile(StringRef filePath);
66 void resetTarget(Target &targ);
67
68 bool report(const Twine &err, DiagnosticsEngine &Diag);
69
70 std::string getRemapInfoFile(StringRef outputDir);
71 };
72
73 } // end namespace arcmt
74
75 } // end namespace clang
76
77 #endif
Diag
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Definition: LiteralSupport.cpp:78
llvm
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:30
clang::CodeGen::clear
virtual void clear()
clang::PreprocessorOptions
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
Definition: PreprocessorOptions.h:43
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
clang::DiagnosticsEngine
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:149
clang::arcmt::FileRemapper
Definition: FileRemapper.h:31
clang::FileEntry
Cached information about one file (either on disk or in the virtual file system). ...
Definition: FileManager.h:60
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22