summaryrefslogtreecommitdiffstats
path: root/clang/test/FixIt
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Implement support for null non-type template arguments for non-typeDouglas Gregor2012-04-061-0/+4
| | | | | | | template parameters of pointer, pointer-to-member, or nullptr_t type in C++11. Fixes PR9700 / <rdar://problem/11193097>. llvm-svn: 154219
* Added a new attribute, objc_root_class, which informs the compiler when a ↵Patrick Beard2012-04-062-7/+7
| | | | | | | | | root class is intentionally declared. The warning this inhibits, -Wobjc-root-class, is opt-in for now. However, all clang unit tests that would trigger the warning have been updated to use -Wno-objc-root-class. <rdar://problem/7446698> llvm-svn: 154187
* Fix diagnostic text for r154163.David Blaikie2012-04-062-5/+5
| | | | llvm-svn: 154164
* Restrict fixit for missing 'class' in template template parameters.David Blaikie2012-04-063-3/+14
| | | | | | | | | | | 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
* Replace the workaround from r153445 with a proper fix.Kaelyn Uhrain2012-04-031-2/+2
| | | | | | | | | | | | | Infinite recursion was happening when DiagnoseInvalidRedeclaration called ActOnFunctionDeclarator to check if a typo correction works when the correction was just to the nested-name-specifier because the wrong DeclContext was being passed in. Unlike a number of functions surrounding typo correction, the DeclContext passed in for a function is the context of the function name after applying any nested name specifiers, not the lexical DeclContext where the function+nested-name-specifier appears. llvm-svn: 153962
* 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
* Reject 'template<typename...Ts> void f(Ts ...(x));'. Add a special-caseRichard Smith2012-03-291-0/+23
| | | | | | | diagnostic and a fix-it to explain to the user where the ellipsis is supposed to go. llvm-svn: 153622
* When diagnosing an invalid out-of-line redeclaration, don't permitDouglas Gregor2012-03-261-0/+17
| | | | | | | typo correction to introduce a nested-name-specifier; we aren't prepared to handle it here. Fixes PR12297 / <rdar://problem/11075219>. llvm-svn: 153445
* Use character literals for vexing initialization fixit hints.David Blaikie2012-03-182-0/+30
| | | | | | | | | | | | | | | Instead of suggesting " = 0" for "char c();", suggest " = '\0'", and similarly for other char types (wide, 16, and 32). Add tests for all these, and since this means testing such hints under C++0x, add tests for some untested C++0x hint cases in the existing code, including suggesting nullptr for pointer initialization. This sets up the initialization helper to provide better type fidelity that will be especially helpful for non-assignment cases (such as fixit-correcting NULL usage in function calls (eg: foo(char) + foo(NULL) => foo('\0') instead of the less informative foo(0))) llvm-svn: 153008
* Fix a couple of issues with literal-operator-id parsing, and provide recoveryRichard Smith2012-03-081-0/+12
| | | | | | | | | | | | for a few kinds of error. Specifically: Since we're after translation phase 6, the "" token might be formed by multiple source-level string literals. Checking the token width is not a correct way of detecting empty string literals, due to escaped newlines. Diagnose and recover from a missing space between "" and suffix, and from string literals other than "", which are followed by a suffix. llvm-svn: 152348
* Implement C++11 [lex.ext]p10 for string and character literals: a ud-suffix notRichard Smith2012-03-082-1/+8
| | | | | | | | | | | | | | | | | | starting with an underscore is ill-formed. Since this rule rejects programs that were using <inttypes.h>'s macros, recover from this error by treating the ud-suffix as a separate preprocessing-token, with a DefaultError ExtWarn. The approach of treating such cases as two tokens is under discussion for standardization, but is in any case a conforming extension and allows existing codebases to keep building while the committee makes up its mind. Reword the warning on the definition of literal operators not starting with underscores (which are, strangely, legal) to more explicitly state that such operators can't be called by literals. Remove the special-case diagnostic for hexfloats, since it was both triggering in the wrong cases and incorrect. llvm-svn: 152287
* improve on diagnostic when block captures uninitializedFariborz Jahanian2012-03-081-1/+1
| | | | | | block variable. // rdar://10817031 llvm-svn: 152273
* improve on diagnostic and provide a fixit hint whenFariborz Jahanian2012-03-081-0/+12
| | | | | | | an uninitialized block variable is being called inside the block literal. // rdar://10817031 llvm-svn: 152271
* Test fix-it added in r152198.Richard Smith2012-03-071-0/+9
| | | | llvm-svn: 152199
* And libclang cursor/indexing support for new Objective-C ↵Ted Kremenek2012-03-061-0/+44
| | | | | | NSArray/NSDictionary/NSNumber literals. llvm-svn: 152138
* Test for my last patch. // rdar://10267155.Fariborz Jahanian2012-02-291-0/+29
| | | | llvm-svn: 151767
* Tests for the fixits which Doug added in r150727.Richard Smith2012-02-171-0/+2
| | | | llvm-svn: 150777
* Reject continue/break statements within members of local functions nested withinRichard Smith2012-02-171-19/+42
| | | | | | | | | | | | | | | loop and switch statements, by teaching Scope that a function scope never has a continue/break parent for the purposes of control flow. Remove the hack in block and lambda expressions which worked around this by pretending that such expressions were continue/break scopes. Remove Scope::ControlParent, since it's unused. In passing, teach default statements to recover properly from a missing ';', and add a fixit for same to both default and case labels (the latter already recovered correctly). llvm-svn: 150776
* Allow implicit capture of 'this' in a lambda even when the captureDouglas Gregor2012-02-101-0/+12
| | | | | | | | | | | | default is '=', and reword the warning about explicitly capturing 'this' in such lambdas to indicate that only explicit capture is banned. Introduce Fix-Its for this and other "save the programmer from themself" rules regarding what can be explicitly captured and what must be implicitly captured. llvm-svn: 150256
* 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
* Introduce 3 new fixit options:Argyrios Kyrtzidis2012-01-261-0/+6
| | | | | | | | | | | | | | -fixit-recompile applies fixits and recompiles the result -fixit-to-temporary applies fixits to temporary files -fix-only-warnings">, applies fixits for warnings only, not errors Combining "-fixit-recompile -fixit-to-temporary" allows testing the result of fixits without touching the original sources. llvm-svn: 149027
* 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
* Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:Richard Smith2012-01-121-0/+80
| | | | | | | | | | | | | | | | | | | | | | | - If the declarator is at the start of a line, and the previous line contained another declarator and ended with a comma, then that comma was probably a typo for a semicolon: int n = 0, m = 1, l = 2, // k = 5; myImportantFunctionCall(); // oops! - If removing the parentheses would correctly initialize the object, then produce a note suggesting that fix. - Otherwise, if there is a simple initializer we can suggest which performs value-initialization, then provide a note suggesting a correction to that initializer. Sema::Declarator now tracks the location of the comma prior to the declarator in the declaration, if there is one, to facilitate providing the note. The code to determine an appropriate initializer from the -Wuninitialized warning has been factored out to allow use in both that and -Wvexing-parse. llvm-svn: 148072
* Update C++11 scoped enumeration support to match the final proposal:Richard Smith2012-01-101-0/+9
| | | | | | | | - reject definitions of enums within friend declarations - require 'enum', not 'enum class', for non-declaring references to scoped enumerations llvm-svn: 147824
* Extend the diagnostic for a ',' at the end of a declaration where a ';' wasRichard Smith2012-01-092-0/+27
| | | | | | intended to cover C++ class definitions. llvm-svn: 147808
* Fix constexpr handling to allow 'extern constexpr' variable declarations. We noRichard Smith2011-12-251-35/+0
| | | | | | | longer have access to the source locations we need to produce the 'replace constexpr with const' fixits, so they're gone for now. llvm-svn: 147273
* Modify how the -verify flag works. Currently, the verification string andRichard Trieu2011-12-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostic message are compared. If either is a substring of the other, then no error is given. This gives rise to an unexpected case: // expect-error{{candidate function has different number of parameters}} will match the following error messages from Clang: candidate function has different number of parameters (expected 1 but has 2) candidate function has different number of parameters It will also match these other error messages: candidate function function has different number of parameters number of parameters This patch will change so that the verification string must be a substring of the diagnostic message before accepting. Also, all the failing tests from this change have been corrected. Some stats from this cleanup: 87 - removed extra spaces around verification strings 70 - wording updates to diagnostics 40 - extra leading or trailing characters (typos, unmatched parens or quotes) 35 - diagnostic level was included (error:, warning:, or note:) 18 - flag name put in the warning (-Wprotocol) llvm-svn: 146619
* Revert most of r145372 for now. Lookahead beyond the ';' in a functionRichard Smith2011-11-303-41/+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-293-0/+41
| | | | | | | | 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-193-0/+26
| | | | | | | | | 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
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-131-3/+3
| | | | | | -std=c++0x. Patch by Ahmed Charles! llvm-svn: 141900
* Catch placeholder types in DefaultLvalueConversionJohn McCall2011-10-111-2/+2
| | | | | | | | | | | and DefaultFunctionArrayLvalueConversion. To prevent significant regression for should-this-be-a-call fixits, and to repair some such regression from the introduction of bound member placeholders, make those placeholder checks try to build calls appropriately. Harden the build-a-call logic while we're at it. llvm-svn: 141738
* Remove FIXME obsoleted by change r141279 for PR11067.Richard Smith2011-10-071-5/+0
| | | | llvm-svn: 141351
* Make -fobjc-nonfragile-abi the -cc1 default, since it's theJohn McCall2011-10-021-3/+3
| | | | | | | | | | | | | | | | | | | increasingly prevailing case to the point that new features like ARC don't even support the fragile ABI anymore. This required a little bit of reshuffling with exceptions because a check was assuming that ObjCNonFragileABI was only being set in ObjC mode, and that's actually a bit obnoxious to do. Most, though, it involved a perl script to translate a ton of test cases. Mostly no functionality change for driver users, although there are corner cases with disabling language-specific exceptions that we should handle more correctly now. llvm-svn: 140957
* Mark the ExtWarn for in-class initialization of static const float members ↵Richard Smith2011-09-291-4/+2
| | | | | | as a GNU extension. Don't extend the scope of this extension to all literal types in C++0x mode. llvm-svn: 140820
* constexpr: semantic checking for constexpr variables.Richard Smith2011-09-291-1/+43
| | | | | | We had an extension which allowed const static class members of floating-point type to have in-class initializers, 'as a C++0x extension'. However, C++0x does not allow this. The extension has been kept, and extended to all literal types in C++0x mode (with a fixit to add the 'constexpr' specifier). llvm-svn: 140801
* PR10867: Work around a bug in lit. Multiple RUN: lines are joined with &&, so:Richard Smith2011-09-068-11/+11
| | | | | | | | | | | | | | | | | 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
* Improve overloaded function handling in the typo correction code.Kaelyn Uhrain2011-08-031-5/+6
| | | | | | | | Change TypoCorrection to store a set of NamedDecls instead of a single NamedDecl. Also add initial support for performing function overload resolution to Sema::DiagnoseEmptyLookup. llvm-svn: 136807
* Introduce a Fix-It for the "missing sentinel" warning, adding anDouglas Gregor2011-07-301-0/+14
| | | | | | | appropriate sentinel at the end of the argument list. Also, put the sentinel warnings under -Wsentinel. Fixes <rdar://problem/8764236>. llvm-svn: 136566
* Add a fixit for removal of unused label.Anna Zaks2011-07-281-2/+13
| | | | llvm-svn: 136389
* Another test case for the &/* mismatch fixit.Anna Zaks2011-07-281-1/+15
| | | | llvm-svn: 136380
OpenPOWER on IntegriCloud