summaryrefslogtreecommitdiffstats
path: root/clang/test/FixIt
Commit message (Collapse)AuthorAgeFilesLines
...
* Handle universal character names and Unicode characters outside of literals.Jordan Rose2013-01-241-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | This is a missing piece for C99 conformance. This patch handles UCNs by adding a '\\' case to LexTokenInternal and LexIdentifier -- if we see a backslash, we tentatively try to read in a UCN. If the UCN is not syntactically well-formed, we fall back to the old treatment: a backslash followed by an identifier beginning with 'u' (or 'U'). Because the spelling of an identifier with UCNs still has the UCN in it, we need to convert that to UTF-8 in Preprocessor::LookUpIdentifierInfo. Of course, valid code that does *not* use UCNs will see only a very minimal performance hit (checks after each identifier for non-ASCII characters, checks when converting raw_identifiers to identifiers that they do not contain UCNs, and checks when getting the spelling of an identifier that it does not contain a UCN). This patch also adds basic support for actual UTF-8 in the source. This is treated almost exactly the same as UCNs except that we consider stray Unicode characters to be mistakes and offer a fixit to remove them. llvm-svn: 173369
* Format strings: don't ever convert %+d to %lu.Jordan Rose2013-01-171-0/+4
| | | | | | | | | | Presumably, if the printf format has the sign explicitly requested, the user wants to treat the data as signed. This is a fix-up for r172739, and also includes several test changes that didn't make it into that commit. llvm-svn: 172762
* Format strings: correct signedness if already correcting width (%d,%u).Jordan Rose2013-01-172-0/+29
| | | | | | | | | | | | It is valid to do this: printf("%u", (int)x); But if we see this: printf("%lu", (int)x); ...our fixit should suggest %d, not %u. llvm-svn: 172739
* Convert test/FixIt/format-darwin.m to use relative line numbers.Jordan Rose2013-01-171-46/+42
| | | | llvm-svn: 172738
* Add fixit hints for misplaced C++11 attributes around class specifiers.Michael Han2013-01-071-0/+34
| | | | | | | | | | Following r168626, in class declaration or definition, there are a combination of syntactic locations where C++11 attributes could appear, and among those the only valid location permitted by standard is between class-key and class-name. So for those attributes appear at wrong locations, fixit is used to move them to expected location and we recover by applying them to the class specifier. llvm-svn: 171757
* Use some heuristics so that when a fixit removes a source range, we tryArgyrios Kyrtzidis2012-12-201-0/+12
| | | | | | | | | | | | | | | | | | | | 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
* Format strings: offer a cast to 'unichar' for %C in Objective-C contexts.Jordan Rose2012-12-052-0/+63
| | | | | | | | | | | | | | | | | | | For most cases where a conversion specifier doesn't match an argument, we usually guess that the conversion specifier is wrong. However, if the argument is an integer type and the specifier is %C, it's likely the user really did mean to print the integer as a character. (This is more common than %c because there is no way to specify a unichar literal -- you have to write an integer literal, such as '0x2603', and then cast it to unichar.) This does not change the behavior of %S, since there are fewer cases where printing a literal Unicode *string* is necessary, but this could easily be changed in the future. <rdar://problem/11982013> llvm-svn: 169400
* Format strings: add more expression types that don't need parens to cast.Jordan Rose2012-12-051-1/+1
| | | | | | | No functionality change (the test change is a comment only, and the new functionality can't be tested using the current test). llvm-svn: 169399
* Format strings: a character literal should be printed with %c, not %d.Jordan Rose2012-12-051-0/+33
| | | | | | | | | | | | | | | | | | The type of a character literal is 'int' in C, but if the user writes a character /as/ a literal, we should assume they meant it to be a character and not a numeric value, and thus offer %c as a correction rather than %d. There's a special case for multi-character literals (like 'MooV'), which have implementation-defined value and usually cannot be printed with %c. These still use %d as the suggestion. In C++, the type of a character literal is 'char', and so this problem doesn't exist. <rdar://problem/12282316> llvm-svn: 169398
* Format strings: the correct conversion for 'char' is %c, not %d or %hhd.Jordan Rose2012-12-051-0/+54
| | | | | | | We tried to account for 'uint8_t' by saying that /typedefs/ of 'char' should be corrected as %hhd rather than %c, but the condition was wrong. llvm-svn: 169397
* Fix an assertion failure printing the unused-label fixit in files using CRLF ↵Eli Friedman2012-11-141-0/+11
| | | | | | line endings. <rdar://problem/12639047>. llvm-svn: 167900
* DR1473: Do not require a space between operator"" and the ud-suffix in aRichard Smith2012-10-201-2/+0
| | | | | | literal-operator-id. llvm-svn: 166373
* Fix typo correction of one qualified name to another.David Blaikie2012-10-121-2/+40
| | | | | | | | | | | | | | When suggesting "foo::bar" as a correction for "fob::bar" we mistakenly replaced only "bar" with "foo::bar" producing "fob::foo::bar" which was broken. This corrects that replacement in as many places as I could find & provides test cases for all those cases I could find a test case for. There are a couple that don't seem to be reachable (one looks entirely dead, the other just doesn't seem to ever get called with a namespace to namespace change). Review by Richard Smith ( http://llvm-reviews.chandlerc.com/D57 ). llvm-svn: 165817
* Provide a fixit when taking the address of an unqualified member function.David Blaikie2012-10-112-0/+13
| | | | | | | | | | | | | This only applies if the type has a name. (we could potentially do something crazy with decltype in C++11 to qualify members of unnamed types but that seems excessive) It might be nice to also suggest a fixit for "&this->i", "&foo->i", and "&foo.i" but those expressions produce 'bound' member functions that have a different AST representation & make error recovery a little trickier. Left as future work. llvm-svn: 165763
* objective-C arc: Warn under arc about a use of an ivar inside a blockFariborz Jahanian2012-10-031-0/+20
| | | | | | | that doesn't have a 'self' as this implicitly captures 'self' and could create retain cycles. Provide fixit. // rdar://11194874 llvm-svn: 165133
* Per discussion in ↵Argyrios Kyrtzidis2012-09-271-0/+2
| | | | | | | | | | http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120917/064551.html have PPCallbacks::InclusionDirective pass the character range for the filename quotes or brackets. rdar://11113134 & http://llvm.org/PR13880 llvm-svn: 164743
* objective-C: remove use of 'ivar' in favor ofFariborz Jahanian2012-09-241-1/+1
| | | | | | | 'instance variable' in text of all diagnostics for objective-C: // rdar://12352442 llvm-svn: 164559
* If a comma operator is followed by a token which unambiguously indicates theRichard Smith2012-09-181-0/+7
| | | | | | | | start of a statement or the end of a compound-statement, diagnose the comma as a typo for a semicolon. Patch by Ahmed Bougacha! Additional test cases and minor refactoring by me. llvm-svn: 164085
* Promote the warning about extra qualification on a declaration from aDouglas Gregor2012-09-131-1/+1
| | | | | | | | warning to an error. C++ bans it, and both GCC and EDG diagnose it as an error. Microsoft allows it, so we still warn in Microsoft mode. Fixes <rdar://problem/11135644>. llvm-svn: 163831
* Format strings: offer a fixit for Darwin's %D/%U/%O to ISO %d/%u/%o.Jordan Rose2012-09-131-11/+18
| | | | | | <rdar://problem/12061922> llvm-svn: 163772
* Format strings: %D, %U, and %O are valid on Darwin (same as %d, %u, %o).Jordan Rose2012-09-131-0/+10
| | | | | | | | | These will warn under -Wformat-non-iso, and will still be rejected outright on other platforms. <rdar://problem/12061922> llvm-svn: 163771
* Format strings: suggest casts for NS(U)Integer and [SU]Int32 on Darwin.Jordan Rose2012-09-051-0/+181
| | | | | | | | | | | | | | | These types are defined differently on 32-bit and 64-bit platforms, and trying to offer a fixit for one platform would only mess up the format string for the other. The Apple-recommended solution is to cast to a type that is known to be large enough and always use that to print the value. This should only have an impact on compile time if the format string is incorrect; in cases where the format string matches the definition on the current platform, no warning will be emitted. <rdar://problem/9135072&12164284> llvm-svn: 163266
* Improvements to vexing-parse warnings. Make the no-parameters case moreRichard Smith2012-07-301-16/+35
| | | | | | | | | | | | | accurate by asking the parser whether there was an ambiguity rather than trying to reverse-engineer it from the DeclSpec. Make the with-parameters case have better diagnostics by using semantic information to drive the warning, improving the diagnostics and adding a fixit. Patch by Nikola Smiljanic. Some minor changes by me to suppress diagnostics for declarations of the form 'T (*x)(...)', which seem to have a very high false positive rate, and to reduce indentation in 'warnAboutAmbiguousFunction'. llvm-svn: 160998
* Re-apply r160319 "Don't crash when emitting fixits following Unicode chars"Jordan Rose2012-07-201-1/+19
| | | | | | | | | This time, make sure we don't try to print fixits with newline characters, since they don't have a valid column width, and they don't look good anyway. PR13417 (and originally <rdar://problem/11877454>) llvm-svn: 160561
* Revert r160319, it caused PR13417. Add a test for PR13417.Nico Weber2012-07-201-19/+1
| | | | llvm-svn: 160542
* Remove dos line endings. Please remember to configure your windows SVNChandler Carruth2012-07-201-13/+13
| | | | | | clients to default text files to 'eol-native'. llvm-svn: 160534
* Adding a fixit for includes that cannot be found with angle brackets, but ↵Aaron Ballman2012-07-172-0/+14
| | | | | | can be found with quoted strings instead. Implements PR13201. llvm-svn: 160406
* Now that -Wobjc-literal-compare is a warning, put the fixit on a note.Jordan Rose2012-07-171-22/+0
| | | | | | | | Recovering as if the user had actually called -isEqual: is a bit too far from the semantics of the program as written, /even though/ it's probably what they intended. llvm-svn: 160377
* Weaken Unicode fixit test to work even if the character is printed escaped.Jordan Rose2012-07-161-4/+5
| | | | | | This should fix the failure on Windows. llvm-svn: 160324
* This test appears to fail on win32.Ted Kremenek2012-07-161-0/+1
| | | | llvm-svn: 160322
* Don't crash when emitting fixits following Unicode characters.Jordan Rose2012-07-161-1/+17
| | | | | | | | | | | | | | | This code is very sensitive to the difference between "columns" as printed and "bytes" (SourceManager columns). All variables are now named explicitly and our assumptions are (hopefully) documented as both comment and assertion. Whether parseable fixits should use byte offsets or Unicode character counts is pending discussion on the mailing list; currently the implementation uses bytes (and has no problems on lines containing multibyte characters). This has been added to the user manual. <rdar://problem/11877454> llvm-svn: 160319
* Be lax about trailing whitespace when checking fixit formatting, this ↵Benjamin Kramer2012-07-121-2/+2
| | | | | | | | | | depends on locale settings. If a non-unicode locale is used, the unicode character is escaped and any byte that is in the escaped representation but not the semicolon will become whitespace. llvm-svn: 160113
* PR13312: Don't crash when printing a fixit that ends in a unicode character.Benjamin Kramer2012-07-121-0/+15
| | | | llvm-svn: 160112
* objective-c: provide fixit hint for @autoreleasepoolFariborz Jahanian2012-07-091-0/+9
| | | | | | and similar other keywords. // rdar://10723084 llvm-svn: 159956
* Downgrade the "direct comparison" error for ObjC literals to a warning.Jordan Rose2012-07-091-9/+9
| | | | | | | | | | | Chris pointed out that while the comparison is certainly problematic and does not have well-defined behavior, it isn't any worse than some of the other abuses that we merely warn about and doesn't need to make the compilation fail. Revert the release notes change (r159766) now that this is just a new warning. llvm-svn: 159939
* Extend the "expected ';' after struct" logic to also apply to enums, and toRichard Smith2012-06-252-0/+22
| | | | | | struct and enum forward-declarations. llvm-svn: 159164
* Enable -Wnull-conversion for non-integral target types (eg: double).David Blaikie2012-06-191-0/+1
| | | | llvm-svn: 158744
* Extend the error recovery for a template-argument-list terminated by '>>' toRichard Smith2012-06-181-0/+31
| | | | | | | | | also deal with '>>>' (in CUDA), '>=', and '>>='. Fix the FixItHints logic to deal with cases where the token is followed by an adjacent '=', '==', '>=', '>>=', or '>>>' token, where a naive fix-it would result in a differing token stream on a re-lex. llvm-svn: 158652
* Enable -Wunused-private-field with -Wunused.Benjamin Kramer2012-06-111-1/+1
| | | | | | | It found a lot of cruft in LLVM that I removed last week and I couldn't find any false positives. Time to give it more testing. llvm-svn: 158317
* Add a test for r158229 (overlapping fixits). This was PR10696!Jordan Rose2012-06-081-0/+13
| | | | llvm-svn: 158238
* Disallow using ObjC literals in direct comparisons (== and friends).Jordan Rose2012-06-081-8/+30
| | | | | | | | | | | | | | | Objective-C literals conceptually always create new objects, but may be optimized by the compiler or runtime (constant folding, singletons, etc). Comparing addresses of these objects is relying on this optimization behavior, which is really an implementation detail. In the case of == and !=, offer a fixit to a call to -isEqual:, if the method is available. This fixit is directly on the error so that it is automatically applied. Most of the time, this is really a newbie mistake, hence the fixit. llvm-svn: 158230
* Teach the FixIt in DiagnoseInvalidRedeclaration how to replace the writtenKaelyn Uhrain2012-06-071-0/+18
| | | | | | | nested name specifiers in addition to the function's identifier when the correction has a different nested name specifier. llvm-svn: 158178
* Make suggestions for mismatched enum arguments to printf/scanf.Jordan Rose2012-06-041-0/+14
| | | | llvm-svn: 157962
* Add a test for '%@' suggestion for classes.Jordan Rose2012-05-301-0/+11
| | | | llvm-svn: 157718
* Suggest '%@' for Objective-C objects in ObjC format strings.Jordan Rose2012-05-302-0/+100
| | | | llvm-svn: 157716
* objc: position of 'fixit' was off by one.Fariborz Jahanian2012-05-291-1/+1
| | | | | | This patch fixes it. // rdar://11488351 llvm-svn: 157646
* objective-c: provide a useful 'fixit' suggestion whenFariborz Jahanian2012-05-211-0/+17
| | | | | | | errornously using commas to separate ObjC message arguments. // rdar://11376372 llvm-svn: 157216
* objective-c. Fixes a 'fixit' where location ofFariborz Jahanian2012-05-091-0/+11
| | | | | | | '*' on objective-c class name was misplaced. // rdar://11311333 llvm-svn: 156517
* Add FixItHint for -Wnull-conversion to initialize with an appropriate literal.David Blaikie2012-04-301-1/+3
| | | | | | Reviewed by Doug Gregor. llvm-svn: 155839
* Imrpove the note text for when a non-type decl hides a tag typeKaelyn Uhrain2012-04-271-1/+1
| | | | llvm-svn: 155723
OpenPOWER on IntegriCloud