Chris Lattner | 8bd12b8 | 2007-09-15 22:21:22 +0000 | [diff] [blame] | 1 | //===--- Rewriter.cpp - Code rewriting interface --------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Chris Lattner and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the Rewriter class, which is used for code |
| 11 | // transformations. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "clang/Rewrite/Rewriter.h" |
Chris Lattner | 8a12c27 | 2007-10-11 18:38:32 +0000 | [diff] [blame^] | 16 | #include "clang/Basic/SourceManager.h" |
Chris Lattner | 8bd12b8 | 2007-09-15 22:21:22 +0000 | [diff] [blame] | 17 | using namespace clang; |
| 18 | |
| 19 | |
| 20 | void RewriteBuffer::RemoveText(unsigned OrigOffset, unsigned Size) { |
| 21 | // FIXME: |
| 22 | } |
| 23 | |
| 24 | void RewriteBuffer::InsertText(unsigned OrigOffset, |
| 25 | const char *StrData, unsigned StrLen) { |
| 26 | // FIXME: |
| 27 | } |
Chris Lattner | 8a12c27 | 2007-10-11 18:38:32 +0000 | [diff] [blame^] | 28 | |
| 29 | |
| 30 | |
| 31 | //===----------------------------------------------------------------------===// |
| 32 | // Rewriter class |
| 33 | //===----------------------------------------------------------------------===// |
| 34 | |
| 35 | /// getEditBuffer - Get or create a RewriteBuffer for the specified FileID. |
| 36 | /// |
| 37 | RewriteBuffer &Rewriter::getEditBuffer(unsigned FileID) { |
| 38 | std::map<unsigned, RewriteBuffer>::iterator I = |
| 39 | RewriteBuffers.lower_bound(FileID); |
| 40 | if (I != RewriteBuffers.end() && I->first == FileID) |
| 41 | return I->second; |
| 42 | I = RewriteBuffers.insert(I, std::make_pair(FileID, RewriteBuffer())); |
| 43 | |
| 44 | std::pair<const char*, const char*> MB = SourceMgr.getBufferData(FileID); |
| 45 | I->second.Initialize(MB.first, MB.second); |
| 46 | |
| 47 | return I->second; |
| 48 | } |
| 49 | |
| 50 | |
| 51 | void Rewriter::ReplaceText(SourceLocation Start, unsigned OrigLength, |
| 52 | const char *NewStr, unsigned NewLength) { |
| 53 | assert(isRewritable(Start) && "Not a rewritable location!"); |
| 54 | |
| 55 | } |