summaryrefslogtreecommitdiffstats
path: root/clang/lib/Rewrite/Rewriter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-15/+10
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Automatic Reference Counting.John McCall2011-06-151-26/+47
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Use S.str() to force a flush.Fariborz Jahanian2011-04-201-3/+1
| | | | llvm-svn: 129856
* Be sure to flush raw_string_ostream objects in the Objective-CDouglas Gregor2011-04-201-0/+2
| | | | | | rewriter, from Eric Niebler! llvm-svn: 129849
* Introduce Rewriter::IncreaseIndentation() which increase indentations for ↵Argyrios Kyrtzidis2011-04-161-0/+83
| | | | | | | | | the lines between the given source range. To determine what the indentation should be, a SourceLocation 'parentIndent' parameter is used that should be at a source location with an indentation one degree lower than the given range. llvm-svn: 129628
* Collect the options applicable to the Rewriter methods into a ↵Argyrios Kyrtzidis2011-04-131-8/+10
| | | | | | RewriterOptions struct. llvm-svn: 129430
* Fixup more objc rwriter bug having to do withFariborz Jahanian2011-04-111-0/+7
| | | | | | | rewriting of blocks which have objective-c stuff which need be rewritten as well. // rdar://9254348 llvm-svn: 129300
* Enhance the Rewriter.Argyrios Kyrtzidis2011-04-071-7/+76
| | | | | | | -Allow removing a line completely if it ends up empty -Provide more control on what should be removed. llvm-svn: 129085
* Pass StringRefs by value.Benjamin Kramer2010-07-141-4/+4
| | | | llvm-svn: 108375
* introduce a new CharSourceRange class, and enhance the diagnostics routinesChris Lattner2010-06-181-3/+9
| | | | | | | | | | | | | | | to use them instead of SourceRange. CharSourceRange is just a SourceRange plus a bool that indicates whether the range has the end character resolved or whether the end location is the start of the end token. While most of the compiler wants to think of ranges that have ends that are the start of the end token, the printf diagnostic stuff wants to highlight ranges within tokens. This is transparent to the diagnostic stuff. To start taking advantage of the new capabilities, you can do something like this: Diag(..) << CharSourceRange::getCharRange(Begin,End) llvm-svn: 106338
* Add a write(raw_ostream&) method to RewriteBuffer. This uses an inefficientNick Lewycky2010-04-161-2/+6
| | | | | | | implementation today but is the right place if we want to make it faster some day. llvm-svn: 101521
* Let SourceManager::getBufferData return StringRef instead of a pair of two ↵Benjamin Kramer2010-03-161-2/+2
| | | | | | const char*. llvm-svn: 98630
* Give SourceManager a Diagnostic object with which to report errors,Douglas Gregor2010-03-161-12/+1
| | | | | | and start simplifying the interfaces in SourceManager that can fail. llvm-svn: 98594
* Add some <cstdio> includes to unbreak the buildbotsDouglas Gregor2010-03-151-0/+1
| | | | llvm-svn: 98591
* Introduce a new BufferResult class to act as the return type ofDouglas Gregor2010-03-151-1/+11
| | | | | | | | | | | | | | SourceManager's getBuffer() (and similar) operations. This abstract can be used to force callers to cope with errors in getBuffer(), such as missing files and changed files. Fix a bunch of callers to use the new interface. Add some very basic checks for file consistency (file size, modification time) into ContentCache::getBuffer(), although these checks don't help much until we've updated the main callers (e.g., SourceManager::getSpelling()). llvm-svn: 98585
* Some clean up of replacement text API no longer needed byFariborz Jahanian2010-02-051-3/+2
| | | | | | my recent changes. llvm-svn: 95391
* Fixes a rewrite bug rewriting nested ivars reference.Fariborz Jahanian2010-01-281-2/+3
| | | | | | (Radar 7583971). llvm-svn: 94724
* Fix typo: rename Rewriter::getRewritenText() -> Rewriter::getRewrittenText().Ted Kremenek2010-01-071-2/+2
| | | | llvm-svn: 92922
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-22/+22
| | | | llvm-svn: 81346
* Convert parts of Rewriter to StringRef based API.Daniel Dunbar2009-08-191-16/+14
| | | | | | | - Please accept my sincere apologies for the gratuitous elimination of code duplication, manual string length counting, unnecessary strlen calls, etc. llvm-svn: 79448
* Key decisions about 'bool' vs '_Bool' to be based on a new flag in langoptions.Chris Lattner2009-06-301-1/+1
| | | | | | | | | | | | This is simple enough, but then I thought it would be nice to make PrintingPolicy get a LangOptions so that various things can key off "bool" and "C++" independently. This spiraled out of control. There are many fixme's, but I think things are slightly better than they were before. One thing that can be improved: CFG should probably have an ASTContext pointer in it, which would simplify its clients. llvm-svn: 74493
* Fix for PR2386: distinguish between insertion and replacements in the Eli Friedman2009-05-181-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 72000
* Change Lexer::MeasureTokenLength to take a LangOptions reference.Chris Lattner2009-04-141-3/+3
| | | | | | | | | | | | | | | | | | This allows it to accurately measure tokens, so that we get: t.cpp:8:13: error: unknown type name 'X' static foo::X P; ~~~~~^ instead of the woefully inferior: t.cpp:8:13: error: unknown type name 'X' static foo::X P; ~~~~ ^ Most of this is just plumbing to push the reference around. llvm-svn: 69099
* Check in the long promised SourceLocation rewrite. This lays theChris Lattner2009-01-261-1/+1
| | | | | | | | | | ground work for implementing #line, and fixes the "out of macro ID's" problem. There is nothing particularly tricky about the code, other than the very performance sensitive SourceManager::getFileID() method. llvm-svn: 62978
* this massive patch introduces a simple new abstraction: it makesChris Lattner2009-01-171-22/+22
| | | | | | | | | | | | | | | "FileID" a concept that is now enforced by the compiler's type checker instead of yet-another-random-unsigned floating around. This is an important distinction from the "FileID" currently tracked by SourceLocation. *That* FileID may refer to the start of a file or to a chunk within it. The new FileID *only* refers to the file (and its #include stack and eventually #line data), it cannot refer to a chunk. FileID is a completely opaque datatype to all clients, only SourceManager is allowed to poke and prod it. llvm-svn: 62407
* Add #include (introduced by dependence on DeclGroup)Ted Kremenek2008-10-071-0/+1
| | | | llvm-svn: 57274
* add a new Rewriter::getRewritenText method that returns the text for a rangeChris Lattner2008-10-031-0/+49
| | | | | | that includes any edits in the range. llvm-svn: 57037
* Patch by Csaba Hruska!Ted Kremenek2008-09-131-2/+3
| | | | | | | "Here is a patch what replaces std::ostream with llvm::raw_ostream. This patch covers the AST library, but ignores Analysis lib." llvm-svn: 56185
* add an assertionChris Lattner2008-05-281-0/+1
| | | | llvm-svn: 51645
* fix an inconsistency computing offsets that caused a crash on rewrite-nest.mChris Lattner2008-05-231-1/+1
| | | | llvm-svn: 51514
* remove ifdefsChris Lattner2008-04-141-35/+0
| | | | llvm-svn: 49651
* Change the RewriteRope::Chunks data structure from an std::list intoChris Lattner2008-04-141-3/+18
| | | | | | | | | | | | a nice shiny B+ Tree variant. This fixes the last of the known algorithmic issues with the rewriter, allowing a significant speedup. For example, -emit-html on Ted's 500K .i file speeds up from 26.8s -> 0.64s in a debug build (41x!) and 5.475s -> 0.132s (41x!) in an optimized build. This code is functional but needs to be cleaned up, ifdefs removed, better commented, and moved to a .cpp file. I plan to do this tomorrow. llvm-svn: 49635
* remove ifdefsChris Lattner2008-04-121-77/+0
| | | | llvm-svn: 49587
* Do an initial hack at replacing one of the incredibly inefficient Chris Lattner2008-04-121-2/+13
| | | | | | | | | | | | | | | (but simple!) datastructures in the rewriter with a more complex but more efficient one. This replaces the Deltas vector with a specialized BTree that makes delta lookups much more efficient. This speeds up -emit-html on a 500K .i file from 157.154 to 27.127 seconds on my machine (5.8x). While this code is functional, it isn't very pretty, I have much refactoring planned for it, and will remove the USE_VECTOR ifdef. Stay tuned. llvm-svn: 49586
* Added variant of "InsertText" in the Rewriter to support inserting text bothTed Kremenek2008-03-181-5/+7
| | | | | | *before* and after a specific location. llvm-svn: 48504
* Bug fix in RewriteBuffer::getMappedOffset: potentially multiple deltas Ted Kremenek2008-03-181-4/+6
| | | | | | | need to be skipped over when AfterInserts == true, as multiple deltas may share the same FileLoc. llvm-svn: 48503
* Make a major restructuring of the clang tree: introduce a top-levelChris Lattner2008-03-151-0/+258
lib dir and move all the libraries into it. This follows the main llvm tree, and allows the libraries to be built in parallel. The top level now enforces that all the libs are built before Driver, but we don't care what order the libs are built in. This speeds up parallel builds, particularly incremental ones. llvm-svn: 48402
OpenPOWER on IntegriCloud