summaryrefslogtreecommitdiffstats
path: root/include/clang/Rewrite/Rewriter.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Rewrite/Rewriter.h')
-rw-r--r--include/clang/Rewrite/Rewriter.h30
1 files changed, 20 insertions, 10 deletions
diff --git a/include/clang/Rewrite/Rewriter.h b/include/clang/Rewrite/Rewriter.h
index 1692180..adda866 100644
--- a/include/clang/Rewrite/Rewriter.h
+++ b/include/clang/Rewrite/Rewriter.h
@@ -16,18 +16,20 @@
#define LLVM_CLANG_REWRITER_H
#include "clang/Basic/SourceLocation.h"
+#include "clang/Rewrite/DeltaTree.h"
#include "clang/Rewrite/RewriteRope.h"
-#include <map>
-#include <vector>
+#include "llvm/ADT/StringRef.h"
#include <cstring>
+#include <map>
#include <string>
-#include "clang/Rewrite/DeltaTree.h"
-#include "llvm/ADT/StringRef.h"
+#include <vector>
+
+namespace llvm { class raw_ostream; }
namespace clang {
- class SourceManager;
class LangOptions;
class Rewriter;
+ class SourceManager;
class Stmt;
/// RewriteBuffer - As code is rewritten, SourceBuffer's from the original
@@ -53,6 +55,8 @@ public:
iterator end() const { return Buffer.end(); }
unsigned size() const { return Buffer.size(); }
+ llvm::raw_ostream &write(llvm::raw_ostream &) const;
+
/// RemoveText - Remove the specified text.
void RemoveText(unsigned OrigOffset, unsigned Size);
@@ -125,6 +129,8 @@ class Rewriter {
const LangOptions *LangOpts;
std::map<FileID, RewriteBuffer> RewriteBuffers;
public:
+ typedef std::map<FileID, RewriteBuffer>::iterator buffer_iterator;
+
explicit Rewriter(SourceManager &SM, const LangOptions &LO)
: SourceMgr(&SM), LangOpts(&LO) {}
explicit Rewriter() : SourceMgr(0), LangOpts(0) {}
@@ -192,6 +198,12 @@ public:
/// could not be rewritten, or false if successful.
bool ReplaceStmt(Stmt *From, Stmt *To);
+ /// getEditBuffer - This is like getRewriteBufferFor, but always returns a
+ /// buffer, and allows you to write on it directly. This is useful if you
+ /// want efficient low-level access to apis for scribbling on one specific
+ /// FileID's buffer.
+ RewriteBuffer &getEditBuffer(FileID FID);
+
/// getRewriteBufferFor - Return the rewrite buffer for the specified FileID.
/// If no modification has been made to it, return null.
const RewriteBuffer *getRewriteBufferFor(FileID FID) const {
@@ -200,11 +212,9 @@ public:
return I == RewriteBuffers.end() ? 0 : &I->second;
}
- /// getEditBuffer - This is like getRewriteBufferFor, but always returns a
- /// buffer, and allows you to write on it directly. This is useful if you
- /// want efficient low-level access to apis for scribbling on one specific
- /// FileID's buffer.
- RewriteBuffer &getEditBuffer(FileID FID);
+ // Iterators over rewrite buffers.
+ buffer_iterator buffer_begin() { return RewriteBuffers.begin(); }
+ buffer_iterator buffer_end() { return RewriteBuffers.end(); }
private:
unsigned getLocationOffsetAndFileID(SourceLocation Loc, FileID &FID) const;
OpenPOWER on IntegriCloud