Граф коммитов

26 Коммитов

Автор SHA1 Сообщение Дата
Chris Lattner aadaf78d65 add some helper methods for removing and replacing text, this makes the
rewriter more robust.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46622 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 19:51:04 +00:00
Chris Lattner dcbc5b0b07 Make rewriter::inserttext return a bool to indicate if it failed.
Add a RewriteTest::ReplaceStmt method to factor the 'checking for
rewrite failed + emitting diagnostic if so' code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46619 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-31 19:37:57 +00:00
Chris Lattner d3c25ddb59 add some assertions so that the rewriter dies violently with a useful
error instead of subtly with a mysterious one.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46287 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-23 23:37:15 +00:00
Chris Lattner 6298b8c021 remove attribution from makefiles.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45412 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 20:02:25 +00:00
Chris Lattner 0bc735ffcf Don't attribute in file headers anymore. See llvmdev for the
discussion of this change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45410 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 19:59:25 +00:00
Chris Lattner 21d1aedfcf remove some temporary code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43906 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-08 20:53:07 +00:00
Chris Lattner fab21b6d73 add a getAtOffset() member to simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43905 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-08 20:51:02 +00:00
Chris Lattner 8b0c2f659d Add a new RewriteRope data structure which is a smarter way to represent the text
backing a rewrite buffer than using an std::vector<char>.  This class was hacked
together very quickly and needs to be cleaned up, but it seems to work.  It speeds
up rewriting a a 7M file from 6.43s to 0.24s on my machine.  The impl could also
be made to be a lot more algorithmically sound.

This produces identical output to using vector on this testcase, if it causes a
problems or bugs are encountered, it can be disabled by changing the 
RewriteBuffer::Buffer typedef back.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43884 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-08 07:35:14 +00:00
Chris Lattner d425a27cd0 minor cleanups
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43881 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-08 04:41:04 +00:00
Chris Lattner 74a0c77ce6 use std::copy instead of memcpy for abstraction.
Disable rewrite-tabs.  This speeds up processing of the commentified huge
crazy testcase steve gave me from 20s to 6.6s in a release build.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43880 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-08 04:27:23 +00:00
Chris Lattner 116c089384 Fix a rewriter bug that fariborz hit, when an @interface was the very very very
first thing in the file.

The trick is that text replacement should go after the insert point, 
not before it, because it will be replacing text after the point, not before 
it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43879 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-08 04:09:59 +00:00
Fariborz Jahanian 24abb10c42 Fix an inverted conditional,
--chris


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43789 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-06 23:06:16 +00:00
Chris Lattner 54a2f071a3 Expose InsertText, fixing an oversight.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43643 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-02 17:26:47 +00:00
Chris Lattner d6690b20b3 simplify change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43348 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-25 17:18:59 +00:00
Chris Lattner 075eb6eae0 Fix a bug steve noticed when handling nested rewrites. We now turn this:
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

into:

    NSAutoreleasePool * pool = objc_msgSend(objc_msgSend(objc_getClass("NSAutoreleasePool"), sel_getUid("alloc")), sel_getUid("init"));

instead of:

    NSAutoreleasePool * pool = objc_msgSend(objc_msgSend(objc_getClass("NSAutoreleasePool"), sel_getUid("alloc")), sel_getUid("init"))utoreleasePool"), sel_getUid("alloc")) init];



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43347 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-25 17:17:34 +00:00
Chris Lattner 01c5748c29 Add new API to rewrite one stmt/expr with another.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43101 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 22:35:30 +00:00
Chris Lattner 9d62a5b31e The size returned by Rewriter::getRangeSize should include
the size of the last token.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43092 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 21:23:07 +00:00
Chris Lattner 674af95412 Fix location processing of @encode: the range should include the @ sign.
@selector probably gets this wrong also.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43048 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 22:51:17 +00:00
Chris Lattner 311ff02fae Add a new Rewriter::getRangeSize method.
Rename SourceRange::Begin()/End() to getBegin()/getEnd() for
consistency with other code.
Start building the rewriter towards handling @encode.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43047 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 22:36:42 +00:00
Chris Lattner 2c64b7b938 Push the rewriter forward a bit more. Now it rewrites
#import to #include's as a test.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43041 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 21:07:07 +00:00
Chris Lattner 57c337d9ab haha, my devious plot is complete:
$ clang rewrite.c -rewrite-test
prints:

int foo() {
        b:      foo();
f:      foo();
    foo();
}

for:

int foo() {
	b:	foo();
f:	foo();
    foo();
}

amazing.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42944 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-13 00:46:29 +00:00
Chris Lattner 03b0710435 With this I can now insert stuff before tabs, woo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42942 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-13 00:21:23 +00:00
Chris Lattner 88d0ed0c58 Woo, tab deletion now works. Next lets see if we can
insert stuff.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42941 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-13 00:17:04 +00:00
Chris Lattner 7c239606f3 another step forward in rewriter stuff. This still has
some incredibly subtle details that I'm working on getting
right.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42940 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-13 00:11:23 +00:00
Chris Lattner 8a12c2777c Push the rewriting APIs along. Build a trivial client that replaces tabs
with x's for now.  The APIs are all unimplemented, so it doesn't do 
anything yet! :)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42868 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-11 18:38:32 +00:00
Chris Lattner 8bd12b848b Initial checkin of rewriter interface. It is just stubbed out for now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41990 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-15 22:21:22 +00:00