Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: tools/clang/BindMigrate/FileRemapper.h

Issue 7886056: Clang plugin that rewrites PostTask(_, NewRunnableMethod(...)) to PostTask(_, base::Bind(...)); (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: break into files and make saner Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/clang/BindMigrate/FileRemapper.h
diff --git a/tools/clang/BindMigrate/FileRemapper.h b/tools/clang/BindMigrate/FileRemapper.h
new file mode 100644
index 0000000000000000000000000000000000000000..bebd389dbb3e4512828836df9eafdcac6e1486ee
--- /dev/null
+++ b/tools/clang/BindMigrate/FileRemapper.h
@@ -0,0 +1,80 @@
+//===-- FileRemapper.h - File Remapping Helper ------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_ARCMIGRATE_FILEREMAPPER_H
+#define LLVM_CLANG_ARCMIGRATE_FILEREMAPPER_H
+
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/OwningPtr.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace llvm {
+ class MemoryBuffer;
+}
+
+namespace clang {
+ class FileManager;
+ class FileEntry;
+ class Diagnostic;
+ class CompilerInvocation;
+
+namespace arcmt_hack {
+
+class FileRemapper {
+ // FIXME: Reuse the same FileManager for multiple ASTContexts.
+ llvm::OwningPtr<FileManager> FileMgr;
+
+ typedef llvm::PointerUnion<const FileEntry *, llvm::MemoryBuffer *> Target;
+ typedef llvm::DenseMap<const FileEntry *, Target> MappingsTy;
+ MappingsTy FromToMappings;
+
+ llvm::DenseMap<const FileEntry *, const FileEntry *> ToFromMappings;
+
+public:
+ FileRemapper();
+ ~FileRemapper();
+
+ bool initFromDisk(StringRef outputDir, Diagnostic &Diag,
+ bool ignoreIfFilesChanged);
+ bool flushToDisk(StringRef outputDir, Diagnostic &Diag);
+
+ bool overwriteOriginal(Diagnostic &Diag,
+ StringRef outputDir = StringRef());
+
+ bool writeParallelTree(StringRef outputDir,
+ Diagnostic& Diag);
+
+ void remap(StringRef filePath, llvm::MemoryBuffer *memBuf);
+ void remap(StringRef filePath, StringRef newPath);
+
+ void applyMappings(CompilerInvocation &CI) const;
+
+ void transferMappingsAndClear(CompilerInvocation &CI);
+
+ void clear(StringRef outputDir = StringRef());
+
+private:
+ void remap(const FileEntry *file, llvm::MemoryBuffer *memBuf);
+ void remap(const FileEntry *file, const FileEntry *newfile);
+
+ const FileEntry *getOriginalFile(StringRef filePath);
+ void resetTarget(Target &targ);
+
+ bool report(const Twine &err, Diagnostic &Diag);
+
+ std::string getRemapInfoFile(StringRef outputDir);
+};
+
+} // end namespace arcmt
+
+} // end namespace clang
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698