aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Edit/EditedSource.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-06-20[clang] Fix format specifiers fixits for nested macrosAlexander Shaposhnikov1-11/+16
ExpansionLoc was previously calculated incorrectly in the case of nested macros expansions. In this diff we build the stack of expansions where the last one is the actual expansion which should be used for grouping together the edits. The definition of MacroArgUse is adjusted accordingly. Test plan: make check-all Differential revision: https://reviews.llvm.org/D34268 llvm-svn: 305845
2017-06-08[clang] Fix format specifiers fixitsAlexander Shaposhnikov1-18/+19
This diff fixes printf "fixits" in the case when there is a wrapping macro and the format string needs multiple replacements. In the presence of a macro there is an extra logic in EditedSource.cpp to handle multiple uses of the same macro argument (see the old comment inside EditedSource::canInsertInOffset) which was mistriggerred when the argument was used only once but required multiple adjustments), as a result the "fixit" was breaking down the format string by dropping the second format specifier, i.e. Log1("test 4: %s %s", getNSInteger(), getNSInteger()) was getting replaced with Log1("test 4: %ld ", (long)getNSInteger(), (long)getNSInteger()) (if one removed the macro and used printf directly it would work fine). In this diff we track the location where the macro argument is used and (as it was before) the modifications originating from all the locations except the first one are rejected, but multiple changes are allowed. Test plan: make check-all Differential revision: https://reviews.llvm.org/D33976 llvm-svn: 305018
2017-04-28[ARCMigrate] When applying changes from remap files, disable the ↵Argyrios Kyrtzidis1-5/+9
'adjustRemovals' functionality of EditedSource 'adjustRemovals' is used to avoid situation when removing a range inadvertently causes 2 separate identifiers to get joined into one. But it is not useful when the edits are character precise, as is the case with the remap files. llvm-svn: 301602
2015-10-03Replace double negation of !FileID.isInvalid() with FileID.isValid().Yaron Keren1-1/+1
+couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. llvm-svn: 249235
2015-09-11[Edit] Fix issue with tracking what macro argument inputs have been edited.Argyrios Kyrtzidis1-14/+66
This was not working correctly, leading to erroneously rejecting valid edits. llvm-svn: 247462
2015-03-29[edit] Don't hit an assert when trying to delete a trailing space at EOFBenjamin Kramer1-1/+3
The buffer is guaranteed to be zero-terminated so we can just circumvent the check. Found by afl-fuzz. llvm-svn: 233496
2015-03-18Remove many superfluous SmallString::str() calls.Yaron Keren1-3/+3
Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. llvm-svn: 232622
2014-09-15Edit: Do not extend a removal to include trailing whitespace if we're at the endBenjamin Kramer1-0/+6
of the file. This would run past the end of the buffer. Sadly I don't have a great way to test it, the only way to trigger the bug is having a removal fix it at the end of the file, which none of our current warnings can generate. llvm-svn: 217766
2014-05-09[C++11] Use 'nullptr'.Craig Topper1-1/+1
llvm-svn: 208392
2014-03-29Avoid a local Twine variable.Benjamin Kramer1-4/+2
Harmless in this case but potentially dangerous if it gets extended some day. llvm-svn: 205107
2013-04-06[objcmt] Fix a mishandled conversion to objc directory literal.Argyrios Kyrtzidis1-0/+2
rdar://13181413 llvm-svn: 178942
2013-02-08Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.Jordan Rose1-9/+5
Nearly all of these changes are one-to-one replacements; the few that aren't have to do with custom identifier validation. llvm-svn: 174768
2013-01-12Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko1-3/+3
brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
2012-12-21EditedSource.cpp: Appease msvc, to add <cctype>.NAKAMURA Takumi1-0/+1
llvm-svn: 170817
2012-12-20Use some heuristics so that when a fixit removes a source range, we tryArgyrios Kyrtzidis1-3/+72
to also remove a trailing space if possible. For example, removing '__bridge' from: i = (__bridge I*)p; should result in: i = (I*)p; not: i = ( I*)p; rdar://11314821 llvm-svn: 170764
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth1-1/+1
uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
2012-05-14[objcmt] When rewriting to array/dictionary literals, add an explicitArgyrios Kyrtzidis1-1/+4
cast to 'id' for any argument that requires it. Part of rdar://11438360. llvm-svn: 156782
2012-03-06Add new code migrator support for migrating existing Objective-C code to useTed Kremenek1-0/+329
the new Objective-C NSArray/NSDictionary/NSNumber literal syntax. This introduces a new library, libEdit, which provides a new way to support migration of code that improves on the original ARC migrator. We now believe that most of its functionality can be refactored into the existing libraries, and thus this new library may shortly disappear. llvm-svn: 152141