summaryrefslogtreecommitdiffstats
path: root/clang/lib/Rewrite/Rewriter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bugJoel E. Denny2019-08-151-0/+11
| | | | | | | | | | | | | | | | | | | | I'd like to add these comments to warn others of problems I encountered when trying to use `RemoveLineIfEmpty`. I originally tried to fix the problem, but I realized I could implement the functionality more easily and efficiently in my calling code where I can make the simplifying assumption that there are no prior edits to the line from which text is being removed. While I've lost the motivation to write a fix, which doesn't look easy, I figure a warning to others is better than silence. I've added a unit test to demonstrate the problem. I don't know how to mark it as an expected failure, so I just marked it disabled. Reviewed By: jkorous Differential Revision: https://reviews.llvm.org/D61466 llvm-svn: 369049
* [Rewrite] Extend to further accept CharSourceRangeJoel E. Denny2019-07-061-3/+6
| | | | | | | | | | | | | Some Rewrite functions are already overloaded to accept CharSourceRange, and this extends others in the same manner. I'm calling these in code that's not ready to upstream, but I figure they might be useful to others in the meantime. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D61467 llvm-svn: 365258
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Remove trailing spaceFangrui Song2018-07-301-3/+3
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-1/+1
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* [Edit, Rewrite] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko2018-03-271-17/+23
| | | | | | warnings; other minor fixes (NFC). llvm-svn: 328597
* Make local function isWhitespaceExceptNL static instead of in anonymous ↵Yaron Keren2015-07-281-3/+1
| | | | | | | | namespace per the coding standard. Thanks Craig Tooper for noticing this. llvm-svn: 243381
* Rename highly-confusing isWhitespace that returns false on \n toYaron Keren2015-07-271-17/+13
| | | | | | | | | isWhitespaceExceptNL. If that's wasn't bad enough, we have an identically named function in Basic/CharInfo.h. While at it, remove unnecessary includes, .str() calls and #ifdef. llvm-svn: 243260
* [Rewrite] Make RewriteBuffer accessible on its own, and add a unit test for it.Argyrios Kyrtzidis2015-03-081-1/+1
| | | | llvm-svn: 231588
* Trim some includes. NFC.Hans Wennborg2014-10-291-2/+1
| | | | llvm-svn: 220877
* Delete unused method and clangAST dependency it required.Daniel Jasper2014-10-261-9/+0
| | | | llvm-svn: 220640
* Remove code duplication and cut dependency from clangRewrite onDaniel Jasper2014-10-231-21/+0
| | | | | | clangAST. llvm-svn: 220502
* Make clang's rewrite engine a core featureAlp Toker2014-07-161-0/+495
| | | | | | | | | | | | | | | The rewrite facility's footprint is small so it's not worth going to these lengths to support disabling at configure time, particularly since key compiler features now depend on it. Meanwhile the Objective-C rewriters have been moved under the ENABLE_CLANG_ARCMT umbrella for now as they're comparatively heavy and still potentially worth excluding from lightweight builds. Tests are now passing with any combination of feature flags. The flags historically haven't been tested by LLVM's build servers so caveat emptor. llvm-svn: 213171
* Split library clangRewrite into clangRewriteCore and clangRewriteFrontend.Ted Kremenek2012-09-011-486/+0
| | | | | | | This is similar to how we divide up the StaticAnalyzer libraries to separate core functionality to what is clearly associated with Frontend actions. llvm-svn: 163050
* Documentation cleanup: Escaped backslashes in Doxygen comments.James Dennett2012-06-151-1/+1
| | | | llvm-svn: 158567
* clang/lib/Rewrite/Rewriter.cpp: Don't try to rename opened files on Win32. ↵NAKAMURA Takumi2012-05-271-0/+4
| | | | | | Win32 doesn't allow rename/removing opened files. llvm-svn: 157528
* Adds a method overwriteChangedFiles to the Rewriter. This is implemented byManuel Klimek2012-05-221-1/+69
| | | | | | | | | first writing the changed files to a temporary location and then overwriting the original files atomically. Also adds a RewriterTestContext to aid unit testing rewrting logic in general. llvm-svn: 157260
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-0/+1
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
* 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
OpenPOWER on IntegriCloud