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

215 Коммитов

Автор SHA1 Сообщение Дата
Dmitri Gribenko 3d115cfd1b Remove useless 'XPASS: *' from tests
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173511 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-25 22:20:24 +00:00
Dmitri Gribenko d08606817a This test actually passes, just add the missing expected-error
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173504 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-25 22:08:24 +00:00
Dmitri Gribenko ff3e102bc9 Migrate test from grep to -fdiagnostics-parseable-fixits
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173496 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-25 21:41:29 +00:00
Jordan Rose dcceacb7f0 Test fix-it ranges for Unicode characters.
Also, remove stray -fdiagnostics-parseable-fixits from ucn-pp-identifier.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173373 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-24 21:19:51 +00:00
Jordan Rose c7629d9415 Handle universal character names and Unicode characters outside of literals.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173369 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-24 20:50:46 +00:00
Jordan Rose cdbe1e0d85 Format strings: don't ever convert %+d to %lu.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172762 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-17 22:34:10 +00:00
Jordan Rose 242ae3d680 Format strings: correct signedness if already correcting width (%d,%u).
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172739 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-17 18:47:16 +00:00
Jordan Rose c8145bbab0 Convert test/FixIt/format-darwin.m to use relative line numbers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172738 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-17 18:47:12 +00:00
Michael Han 07fc1ba755 Add fixit hints for misplaced C++11 attributes around class specifiers.
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.
 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171757 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-07 16:57:11 +00:00
Argyrios Kyrtzidis 5964df144c Use some heuristics so that when a fixit removes a source range, we try
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170764 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-20 21:05:53 +00:00
Jordan Rose 2cd3440369 Format strings: offer a cast to 'unichar' for %C in Objective-C contexts.
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>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169400 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 18:44:49 +00:00
Jordan Rose 17ddc54b8b Format strings: add more expression types that don't need parens to cast.
No functionality change (the test change is a comment only, and the new
functionality can't be tested using the current test).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169399 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 18:44:44 +00:00
Jordan Rose 448ac3e6d1 Format strings: a character literal should be printed with %c, not %d.
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>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169398 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 18:44:40 +00:00
Jordan Rose ff7be48165 Format strings: the correct conversion for 'char' is %c, not %d or %hhd.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169397 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 18:44:37 +00:00
Eli Friedman 35a2b798ef Fix an assertion failure printing the unused-label fixit in files using CRLF line endings. <rdar://problem/12639047>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167900 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-14 01:28:38 +00:00
Richard Smith aa9a8ce5d3 DR1473: Do not require a space between operator"" and the ud-suffix in a
literal-operator-id.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166373 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-20 08:41:10 +00:00
David Blaikie 6952c01831 Fix typo correction of one qualified name to another.
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 ).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165817 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-12 20:00:44 +00:00
David Blaikie abeadfb11f Provide a fixit when taking the address of an unqualified member function.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165763 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11 22:55:07 +00:00
Fariborz Jahanian 3f001ff471 objective-C arc: Warn under arc about a use of an ivar inside a block
that doesn't have a 'self' as this implicitly captures 'self' and could
create retain cycles. Provide fixit. // rdar://11194874


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165133 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-03 17:55:29 +00:00
Argyrios Kyrtzidis da31359244 Per discussion in 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164743 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-27 01:42:07 +00:00
Fariborz Jahanian 59ed9e40bb objective-C: remove use of 'ivar' in favor of
'instance variable' in text of all diagnostics
for objective-C: // rdar://12352442


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164559 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-24 22:00:36 +00:00
Richard Smith 4b0824229b If a comma operator is followed by a token which unambiguously indicates the
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164085 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-18 00:52:05 +00:00
Douglas Gregor 75379455fc Promote the warning about extra qualification on a declaration from a
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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163831 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-13 20:16:20 +00:00
Jordan Rose 670941c28c Format strings: offer a fixit for Darwin's %D/%U/%O to ISO %d/%u/%o.
<rdar://problem/12061922>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163772 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-13 02:11:15 +00:00
Jordan Rose 275b6f52c7 Format strings: %D, %U, and %O are valid on Darwin (same as %d, %u, %o).
These will warn under -Wformat-non-iso, and will still be rejected
outright on other platforms.

<rdar://problem/12061922>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163771 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-13 02:11:03 +00:00
Jordan Rose ec08735e1b Format strings: suggest casts for NS(U)Integer and [SU]Int32 on Darwin.
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>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163266 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-05 22:56:26 +00:00
Richard Smith b9c6261d02 Improvements to vexing-parse warnings. Make the no-parameters case more
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'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160998 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-30 21:30:52 +00:00
Jordan Rose bbe0175255 Re-apply r160319 "Don't crash when emitting fixits following Unicode chars"
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>)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160561 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-20 18:50:51 +00:00
Nico Weber 4397289861 Revert r160319, it caused PR13417. Add a test for PR13417.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160542 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-20 06:44:52 +00:00
Chandler Carruth 0ccd98dff0 Remove dos line endings. Please remember to configure your windows SVN
clients to default text files to 'eol-native'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160534 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-20 00:49:51 +00:00
Aaron Ballman a52f5a3ee2 Adding a fixit for includes that cannot be found with angle brackets, but can be found with quoted strings instead. Implements PR13201.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160406 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-17 23:19:16 +00:00
Jordan Rose 8d872ca7f1 Now that -Wobjc-literal-compare is a warning, put the fixit on a note.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160377 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-17 17:46:40 +00:00
Jordan Rose b04a45720b Weaken Unicode fixit test to work even if the character is printed escaped.
This should fix the failure on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160324 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-16 22:18:33 +00:00
Ted Kremenek ee07db7d91 This test appears to fail on win32.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160322 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-16 21:43:16 +00:00
Jordan Rose 6f977c3e79 Don't crash when emitting fixits following Unicode characters.
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>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160319 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-16 20:52:12 +00:00
Benjamin Kramer c7bd9fbecd Be lax about trailing whitespace when checking fixit formatting, this 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160113 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-12 08:34:31 +00:00
Benjamin Kramer af082c3b16 PR13312: Don't crash when printing a fixit that ends in a unicode character.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160112 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-12 08:20:49 +00:00
Fariborz Jahanian 6749ae1dbc objective-c: provide fixit hint for @autoreleasepool
and similar other keywords. // rdar://10723084


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159956 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-09 20:00:35 +00:00
Jordan Rose 6deae7cc8d Downgrade the "direct comparison" error for ObjC literals to a warning.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159939 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-09 16:54:44 +00:00
Richard Smith c9f3517007 Extend the "expected ';' after struct" logic to also apply to enums, and to
struct and enum forward-declarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159164 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-25 21:37:02 +00:00
David Blaikie b26331b4ff Enable -Wnull-conversion for non-integral target types (eg: double).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158744 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19 21:19:06 +00:00
Richard Smith 19a2702042 Extend the error recovery for a template-argument-list terminated by '>>' to
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158652 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-18 06:11:04 +00:00
Benjamin Kramer f5485125ae Enable -Wunused-private-field with -Wunused.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158317 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-11 16:06:57 +00:00
Jordan Rose 1fdda369d3 Add a test for r158229 (overlapping fixits). This was PR10696!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158238 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-08 22:46:04 +00:00
Jordan Rose 9f63a451b1 Disallow using ObjC literals in direct comparisons (== and friends).
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158230 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-08 21:14:25 +00:00
Kaelyn Uhrain b7fe579968 Teach the FixIt in DiagnoseInvalidRedeclaration how to replace the written
nested name specifiers in addition to the function's identifier when the
correction has a different nested name specifier.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158178 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-07 23:57:12 +00:00
Jordan Rose 033a9c0804 Make suggestions for mismatched enum arguments to printf/scanf.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157962 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04 22:49:02 +00:00
Jordan Rose 2a53189a51 Add a test for '%@' suggestion for classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157718 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-30 22:41:32 +00:00
Jordan Rose 153acdb731 Suggest '%@' for Objective-C objects in ObjC format strings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157716 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-30 21:53:13 +00:00
Fariborz Jahanian 6d1de1b866 objc: position of 'fixit' was off by one.
This patch fixes it. // rdar://11488351


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157646 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-29 21:52:45 +00:00