summaryrefslogtreecommitdiffstats
path: root/clang/test/FixIt/fixit.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Replace remaining user-visible mentions of C++1z with C++17.Richard Smith2017-08-131-1/+1
| | | | llvm-svn: 310804
* [Sema] Improve the error diagnostic for dot destructor calls on pointer objectsAlex Lorenz2017-01-201-0/+11
| | | | | | | | | | | | | This commit improves the mismatched destructor type error by detecting when the destructor call has used a '.' instead of a '->' on a pointer to the destructed type. The diagnostic now suggests to use '->' instead of '.', and adds a fixit where appropriate. rdar://28766702 Differential Revision: https://reviews.llvm.org/D25817 llvm-svn: 292615
* Make some diagnostic tests C++11 clean.Paul Robinson2016-12-211-4/+18
| | | | | | Differential Revision: http://reviews.llvm.org/D27794 llvm-svn: 290262
* Undo accidental comitPaul Robinson2016-12-191-17/+4
| | | | llvm-svn: 290121
* Make a few OpenMP tests "C++11 clean."Paul Robinson2016-12-191-4/+17
| | | | | | Reviewed by abataev (in D27794) llvm-svn: 290120
* Promote a warning on ill-formed code (redeclaration missing an exceptionRichard Smith2015-09-301-1/+1
| | | | | | | | | | | | | | | | | specification) to an error. No compiler other than Clang seems to allow this, and it doesn't seem like a useful thing to accept as an extension in general. The current behavior was added for PR5957, where the problem was specifically related to mismatches of the exception specification on the implicitly-declared global operator new and delete. To retain that workaround, we downgrade the error to an ExtWarn when the declaration is of a replaceable global allocation function. Now that this is an error, stop trying (and failing) to recover from a missing computed noexcept specification. That recovery didn't work, and led to crashes in code like the added testcase. llvm-svn: 248867
* Move fixit for const init from note to diag, weaken to warning in MS mode.Nico Weber2015-04-171-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r235046 turned "extern __declspec(selectany) int a;" from a declaration into a definition to fix PR23242 (required for compatibility with mc.exe output). However, this broke parsing Windows headers: A d3d11 headers contain something like struct SomeStruct {}; extern const __declspec(selectany) SomeStruct some_struct; This is now a definition, and const objects either need an explicit default ctor or an initializer so this errors out with d3d11.h(1065,48) : error: default initialization of an object of const type 'const CD3D11_DEFAULT' without a user-provided default constructor (cl.exe just doesn't implement this rule, independent of selectany.) To work around this, weaken this error into a warning for selectany decls in microsoft mode, and recover with zero-initialization. Doing this is a bit hairy since it adds a fixit on an error emitted by InitializationSequence – this means it needs to build a correct AST, which in turn means InitializationSequence::Failed() cannot return true when this fixit is applied. As a workaround, the patch adds a fixit member to InitializationSequence, and InitializationSequence::Perform() prints the diagnostic if the fixit member is set right after its call to Diagnose. That function is usually called when InitializationSequences are used – InitListChecker::PerformEmptyInit() doesn't call it, but the InitListChecker case never performs default-initialization, so this is technically OK. This is the alternative, original fix for PR20208 that got reviewed in the thread "[patch] Improve diagnostic on default-initializing const variables (PR20208)". This change basically reverts r213725, adds the original fix for PR20208, and makes the error a warning in Microsoft mode. llvm-svn: 235166
* Unify warnings/errors from "maybe you meant" to "did you mean".Eric Christopher2015-04-021-1/+1
| | | | llvm-svn: 233981
* PR21969: Improve diagnostics for a conversion function that has any pieces of aRichard Smith2014-12-191-0/+6
| | | | | | declared return type (including a trailing-return-type in C++14). llvm-svn: 224561
* Suggest fix-it for missing '{' after base-clauseIsmail Pazarbasi2014-09-251-1/+35
| | | | llvm-svn: 218468
* Add error, recovery and fixit for "~A::A() {...}".Richard Smith2014-09-061-0/+7
| | | | llvm-svn: 217302
* [C++1z] Implement N4051: 'typename' is permitted instead of 'class' when ↵Richard Smith2014-06-161-1/+1
| | | | | | declaring a template template parameter. llvm-svn: 211031
* Refactor all the checking for missing 'template<>'s when a declaration has aRichard Smith2014-04-171-1/+3
| | | | | | template-id after its scope specifier into a single place. llvm-svn: 206442
* A few small cleanups to r187504. Thanks to dblaikie for the assist.Kaelyn Uhrain2013-07-311-0/+12
| | | | llvm-svn: 187521
* Move the "->" to "." fixit from r186128 into a separate note sinceKaelyn Uhrain2013-07-151-12/+0
| | | | | | | | recovery is not attempted with the fixit. Also move the associated test case from FixIt/fixit.cpp to SemaCXX/member-expr.cpp since the fixit is no longer automatically applied. llvm-svn: 186342
* Provide a better diagnostic and a fixit for a '.' or '->' before the left parenKaelyn Uhrain2013-07-121-0/+14
| | | | | | | | of a function call. This fixes PR5898 and means we now have a better diagnostic here than GCC. llvm-svn: 186208
* Provide a fixit hint for changing '->' to '.' if there is no operator->Kaelyn Uhrain2013-07-111-0/+12
| | | | | | defined for a class. llvm-svn: 186128
* PR5066: If a declarator cannot have an identifier, and cannot possibly beRichard Smith2013-07-111-0/+5
| | | | | | | | | followed by an identifier, then diagnose an identifier as being a bogus part of the declarator instead of tripping over it. Improves diagnostics for cases like std::vector<const int *p> my_vec; llvm-svn: 186061
* Add 'not' to commands that are expected to fail.Rafael Espindola2013-07-041-1/+1
| | | | | | | This is at least good documentation, but also opens the possibility of using pipefail. llvm-svn: 185652
* PR7256: Provide a fixit for incorrect destructor declarationsDavid Blaikie2013-03-201-0/+8
| | | | | | Fix by Ismail Pazarbasi (ismail.pazarbasi@gmail.com), review by Dmitri Gribenko. llvm-svn: 177546
* Provide a fixit when taking the address of an unqualified member function.David Blaikie2012-10-111-0/+7
| | | | | | | | | | | | | 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
* 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
* 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
* 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
* 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
* Add note to help explain why a tag such as 'struct' is needed to referKaelyn Uhrain2012-04-261-1/+1
| | | | | | | to a given type, when the reason is that there is a non-type decl with the same name. llvm-svn: 155677
* Add an error message with fixit hint for changing '.' to '->'.Kaelyn Uhrain2012-04-251-0/+23
| | | | | | | | | This is mainly for attempting to recover in cases where a class provides a custom operator-> and a '.' was accidentally used instead of '->' when accessing a member of the object returned by the current object's operator->. llvm-svn: 155580
* Re-add the closing '}' for the namespace I accidentally deleted whenKaelyn Uhrain2012-04-191-0/+1
| | | | | | | removing a (new) duplicate test whose only difference was the tag type being an enum instead of a struct. llvm-svn: 155165
* In Parser::isCXXDeclarationSpecifier, consider a non-type identifierKaelyn Uhrain2012-04-191-0/+12
| | | | | | | | | | | | | | | followed by an identifier as declaration specificer (except for ObjC). This allows e.g. an out-of-line C++ member function definitions to be recognized as functions and not as variable declarations if the type name for the first parameter is not recognized as a type--say, when there is a function name shadowing an enum type name and the parameter is missing the "enum" keyword needed to distinguish the two. Note that returning TPResult::Error() instead of TPResult::True() appears to have the same end result, while TPResult::Ambiguous() results in a crash. llvm-svn: 155163
* Fix diagnostic text for r154163.David Blaikie2012-04-061-3/+3
| | | | llvm-svn: 154164
* Restrict fixit for missing 'class' in template template parameters.David Blaikie2012-04-061-3/+3
| | | | | | | | | | | Based on Doug's feedback to r153887 this omits the FixIt if the following token isn't syntactically valid for the context. (not a comma, '...', identifier, '>', or '>>') There's a bunch of work to handle the '>>' case, but it makes for a much more pleasant diagnostic in this case. llvm-svn: 154163
* Improve & simplify diagnostic for missing 'class' in template template ↵David Blaikie2012-04-051-3/+3
| | | | | | | | parameter. Change suggested by Sebastian Redl on review feedback from r153887. llvm-svn: 154102
* Correct error recovery when missing 'class' in a template template parameter.David Blaikie2012-04-021-0/+5
| | | | | | | | | | | | | | | | | The diagnostic message correctly informs the user that they have omitted the 'class' keyword, but neither suggests this insertion as a fixit, nor attempts to recover as if they had provided the keyword. This fixes the recovery, adds the fixit, and adds a separate diagnostic and corresponding replacement fixit for cases where the user wrote 'struct' or 'typename' instead of 'class' (suggested by Richard Smith as a possible common mistake). I'm not sure the diagnostic message for either the original or new cases feel very Clang-esque, so I'm open to suggestions there. The fixit hints make it fairly easy to see what's required, though. llvm-svn: 153887
* PR11684, core issue 1417:Richard Smith2012-02-101-3/+3
| | | | | | | | | | | | | | o Correct the handling of the restrictions on usage of cv-qualified and ref-qualified function types. o Fix a bug where such types were rejected in template type parameter default arguments, due to such arguments not being treated as a template type arg context. o Remove the ExtWarn for usage of such types as template arguments; that was a standard defect, not a GCC extension. o Improve the wording and unify the code for diagnosing cv-qualifiers with the code for diagnosing ref-qualifiers. llvm-svn: 150244
* Extend the error of invalid token after declarations to include fixits for Richard Trieu2012-01-191-11/+59
| | | | | | !=, %=, ^=, &=, *=, -=, |=, /=, <<=, <=, >=, and >>= to =. llvm-svn: 148499
* Change the error when a '+=' follows a declaration to suggest a fixit to '=' ↵Richard Trieu2012-01-181-0/+6
| | | | | | | | | | | | | | | | | | | instead of just suggesting a ';'. Old error: plusequaldeclare1.cc:3:8: error: expected ';' at end of declaration int x += 6; ^ ; New error: plusequaldeclare1.cc:3:9: error: invalid '+=' at end of declaration; did you mean '='? int x += 6; ^~ = llvm-svn: 148433
* Extend the diagnostic for a ',' at the end of a declaration where a ';' wasRichard Smith2012-01-091-0/+13
| | | | | | intended to cover C++ class definitions. llvm-svn: 147808
* Revert most of r145372 for now. Lookahead beyond the ';' in a functionRichard Smith2011-11-301-10/+0
| | | | | | | | | declaration tickles a bug in the way we handle visibility pragmas. The improvement to error recovery for template function definitions declared with the 'typedef' specifier in r145372 is unrelated and not reverted here. llvm-svn: 145541
* Add fix-it to remove 'typedef' from function template definitions. Such a tokenRichard Smith2011-11-291-3/+10
| | | | | | | was probably meant to be 'typename', which we will have already suggested if it is appropriate. llvm-svn: 145395
* PR10101: Recover better from a common copy-paste error: if a functionRichard Smith2011-11-291-0/+10
| | | | | | | | declaration at namespace scope is followed by a semicolon and an open-brace (or in C++, a 'try', ':' or '='), then the error is probably a function definition with a spurious ';', rather than a mysterious '{'. llvm-svn: 145372
* Make the -verify bits in this test actually test something, and fix a few casesRichard Smith2011-10-201-11/+12
| | | | | | where the test didn't work. llvm-svn: 142563
* Improve the diagnostic when a comma ends up at the end of a declarator groupRichard Smith2011-10-191-0/+13
| | | | | | | | | instead of a semicolon (as sometimes happens during refactorings). When such a comma is seen at the end of a line, and is followed by something which can't possibly be a declarator (or even something which might be a plausible typo for a declarator), suggest that a semicolon was intended. llvm-svn: 142544
* Improve the warning for cv-qualifiers on free functions, from Ahmed Charles!Douglas Gregor2011-10-191-0/+3
| | | | llvm-svn: 142478
* PR10867: Work around a bug in lit. Multiple RUN: lines are joined with &&, so:Richard Smith2011-09-061-1/+1
| | | | | | | | | | | | | | | | | RUN: foo RUN: bar || true is equivalent to: RUN: foo && bar || true which is equivalent to: RUN: (foo && bar) || true This resulted in several of the fixit tests not really testing anything. llvm-svn: 139132
* Add */& mismatch fixit generation to the Sema::DiagnoseAssignmentResult().Anna Zaks2011-07-281-0/+11
| | | | llvm-svn: 136379
* Improve recovery (error + fix-it) when parsing type dependent template name ↵Francois Pichet2011-03-271-0/+19
| | | | | | | | | | | without the "template" keyword. For example: typename C1<T>:: /*template*/ Iterator<0> pos; Also the error is downgraded to an ExtWarn in Microsoft mode. llvm-svn: 128387
* Remove the Fix-It for "main must return 'int'", which is not alwaysDouglas Gregor2011-02-191-5/+0
| | | | | | correct and is not worth fixing. Fixes PR8396. llvm-svn: 126035
OpenPOWER on IntegriCloud