clang-1/lib/Rewrite
Eli Friedman a0978c2482 Fix for PR2386: distinguish between insertion and replacements in the
delta tree.

The issue is roughly a conflict in ReplaceText between two kinds of 
uses. One, it should be possible to replace a replacement: for example, the
ObjC rewriter calls ReplaceStmt for an expression, then replaces the resulting
expression with another expression.  Two, it should be possible to 
replace text that already has text inserted before it: for example, the 
HTML rewriter inserts a bunch of tags at the beginning of the line, then 
tries to escape the first character on the line.  This patch 
distinguishes the two cases by storing the deltas separately; 
essentially, replacements and insertions no longer interfere with 
each other.

Another possibility would be to add some sort of flag to ReplaceText, but
this seems a bit more intuitive and flexible.

There are a few downsides to the current solution: one is that there isn't
any way to remove/replace an insertion without touching additional
surrounding text; if such an operation turns out to be useful, an
additional method or flag can be added.  Another is that an insertion 
and replacing a string of length zero are distinct operations; I'm not 
sure how to resolve this, or whether it will be confusing in practice.

This is relatively sensitive code, so please test and tell me if 
anything breaks.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72000 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 13:56:52 +00:00
..
CMakeLists.txt CMake: Builds and installs clang binary and libs (no docs yet). It 2008-10-26 00:56:18 +00:00
DeltaTree.cpp Fix a corner case that ted hit in -emit-html, rdar://5863212 2008-04-15 02:26:21 +00:00
HTMLRewrite.cpp Change Lexer::MeasureTokenLength to take a LangOptions reference. 2009-04-14 23:22:57 +00:00
Makefile Build system changes to use TableGen to generate the various 2009-03-16 23:06:59 +00:00
RewriteRope.cpp Fixed an offset calculation error. 2008-09-16 07:58:21 +00:00
Rewriter.cpp Fix for PR2386: distinguish between insertion and replacements in the 2009-05-18 13:56:52 +00:00
TokenRewriter.cpp This change refactors some of the low-level lexer interfaces a bit. 2009-01-26 19:29:26 +00:00