summaryrefslogtreecommitdiffstats
path: root/clang/test/FixIt
Commit message (Collapse)AuthorAgeFilesLines
* [c++20] P1143R2: Add support for the C++20 'constinit' keyword.Richard Smith2019-09-041-2/+36
| | | | | | | | | | | | | This is mostly the same as the [[clang::require_constant_initialization]] attribute, but has a couple of additional syntactic and semantic restrictions. In passing, I added a warning for the attribute form being added after we have already seen the initialization of the variable (but before we see the definition); that case previously slipped between the cracks and the attribute was silently ignored. llvm-svn: 370972
* [Sema] Don't warn on printf('%hd', [char]) (PR41467)Nathan Huckleberry2019-08-231-3/+1
| | | | | | | | | | | | | | | | Summary: Link: https://bugs.llvm.org/show_bug.cgi?id=41467 Reviewers: rsmith, nickdesaulniers, aaron.ballman, lebedev.ri Reviewed By: nickdesaulniers, aaron.ballman, lebedev.ri Subscribers: lebedev.ri, nickdesaulniers, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66186 llvm-svn: 369791
* [c++20] P0780R2: Support pack-expansion of init-captures.Richard Smith2019-05-211-0/+15
| | | | | | | | | | | This permits an init-capture to introduce a new pack: template<typename ...T> auto x = [...a = T()] { /* a is a pack */ }; To support this, the mechanism for allowing ParmVarDecls to be packs has been extended to support arbitrary local VarDecls. llvm-svn: 361300
* Give 'fixit-cxx0x.cpp' a more modern name.Richard Smith2019-05-201-0/+0
| | | | llvm-svn: 361208
* Added a better diagnostic when using the delete operator with lambdasNicolas Lesser2019-05-191-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This adds a new error for missing parentheses around lambdas in delete operators. ``` int main() { delete []() { return new int(); }(); } ``` This will result in: ``` test.cpp:2:3: error: '[]' after delete interpreted as 'delete[]' delete []() { return new int(); }(); ^~~~~~~~~ test.cpp:2:9: note: add parentheses around the lambda delete []() { return new int(); }(); ^ ( ) ``` Reviewers: rsmith Reviewed By: rsmith Subscribers: riccibruno, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D36357 llvm-svn: 361119
* [c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whoseRichard Smith2019-05-091-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | template name is not visible to unqualified lookup. In order to support this without a severe degradation in our ability to diagnose typos in template names, this change significantly restructures the way we handle template-id-shaped syntax for which lookup of the template name finds nothing. Instead of eagerly diagnosing an undeclared template name, we now form a placeholder template-name representing a name that is known to not find any templates. When the parser sees such a name, it attempts to disambiguate whether we have a less-than comparison or a template-id. Any diagnostics or typo-correction for the name are delayed until its point of use. The upshot should be a small improvement of our diagostic quality overall: we now take more syntactic context into account when trying to resolve an undeclared identifier on the left hand side of a '<'. In fact, this works well enough that the backwards-compatible portion (for an undeclared identifier rather than a lookup that finds functions but no function templates) is enabled in all language modes. llvm-svn: 360308
* When typo-correcting a function name, consider correcting to a type nameRichard Smith2019-05-091-0/+7
| | | | | | for a function-style cast. llvm-svn: 360302
* Improve -Wuninitialized warning under ARC for block variables that areAkira Hatanaka2019-04-231-3/+9
| | | | | | | | | | | recursively captured. Under ARC, a block variable is zero-initialized when it is recursively captured by the block literal initializer. rdar://problem/11022762 llvm-svn: 359049
* Add support for attributes on @implementations in Objective-CErik Pilkington2019-04-111-2/+2
| | | | | | | | | We want to make objc_nonlazy_class apply to implementations, but ran into this. There doesn't seem to be any reason that this isn't supported. Differential revision: https://reviews.llvm.org/D60542 llvm-svn: 358200
* Introduce the _Clang scoped attribute token.Aaron Ballman2018-11-091-0/+3
| | | | | | Currently, we only accept clang as the scoped attribute identifier for double square bracket attributes provided by Clang, but this has the potential to conflict with user-defined macros. To help alleviate these concerns, this introduces the _Clang scoped attribute identifier as an alias for clang. It also introduces a warning with a fixit on the off chance someone attempts to use __clang__ as the scoped attribute (which is a predefined compiler identification macro). llvm-svn: 346521
* [Sema] Add fixit for unused lambda capturesAlexander Shaposhnikov2018-07-161-0/+94
| | | | | | | | | | | | | This diff adds a fixit to suggest removing unused lambda captures in the appropriate diagnostic. Patch by Andrew Comminos! Test plan: make check-all Differential revision: https://reviews.llvm.org/D48845 llvm-svn: 337148
* [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on DarwinJF Bastien2018-06-222-1/+22
| | | | | | | | | | | | | | | | | | | | | | | Summary: Pick D42933 back up, and make NSInteger/NSUInteger with %zu/%zi specifiers on Darwin warn only in pedantic mode. The default -Wformat recently started warning for the following code because of the added support for analysis for the '%zi' specifier. NSInteger i = NSIntegerMax; NSLog(@"max NSInteger = %zi", i); The problem is that on armv7 %zi is 'long', and NSInteger is typedefed to 'int' in Foundation. We should avoid this warning as it's inconvenient to our users: it's target specific (happens only on armv7 and not arm64), and breaks their existing code. We should also silence the warning for the '%zu' specifier to ensure consistency. This is acceptable because Darwin guarantees that, despite the unfortunate choice of typedef, sizeof(size_t) == sizeof(NS[U]Integer), the warning is therefore noisy for pedantic reasons. Once this is in I'll update public documentation. Related discussion on cfe-dev: http://lists.llvm.org/pipermail/cfe-dev/2018-May/058050.html <rdar://36874921&40501559> Reviewers: ahatanak, vsapsai, alexshap, aaron.ballman, javed.absar, jfb, rjmccall Subscribers: kristof.beyls, aheejin, cfe-commits Differential Revision: https://reviews.llvm.org/D47290 llvm-svn: 335393
* [Parser][FixIt] Better diagnostics for "typedef" instead of "typename" typoJan Korous2018-02-081-0/+16
| | | | | | | | rdar://problem/10214588 Differential Revision: https://reviews.llvm.org/D42170 llvm-svn: 324607
* Add a "vexing parse" warning for ambiguity between a variable declaration and aRichard Smith2017-09-291-0/+21
| | | | | | | | | | | | | | function-style cast. This fires for cases such as T(x); ... where 'x' was previously declared and T is a type. This construct declares a variable named 'x' rather than the (probably expected) interpretation of a function-style cast of 'x' to T. llvm-svn: 314570
* [Sema] Put nullability fix-it after the end of the pointer.Volodymyr Sapsai2017-09-282-0/+50
| | | | | | | | | | | | | | | | | | Fixes nullability fix-it for `id<SomeProtocol>`. With this change nullability specifier is inserted after ">" instead of between "id" and "<". rdar://problem/34260995 Reviewers: jordan_rose, doug.gregor, ahatanak, arphaman Reviewed By: jordan_rose Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D38327 llvm-svn: 314473
* [clang] Add getUnsignedPointerDiffType methodAlexander Shaposhnikov2017-09-281-0/+31
| | | | | | | | | | | | | | | | | C11 standard refers to the unsigned counterpart of the type ptrdiff_t in the paragraph 7.21.6.1p7 where it defines the format specifier %tu. In Clang (in PrintfFormatString.cpp, lines 508-510) there is a FIXME for this case, in particular, Clang didn't diagnose %tu issues at all, i.e. it didn't emit any warnings on the code printf("%tu", 3.14). In this diff we add a method getUnsignedPointerDiffType for getting the corresponding type similarly to how it's already done in the other analogous cases (size_t, ssize_t, ptrdiff_t etc) and fix -Wformat diagnostics for %tu plus the emitted fix-it as well. Test plan: make check-all Differential revision: https://reviews.llvm.org/D38270 llvm-svn: 314470
* [clang] Fix printf fixit for objc specific typesAlexander Shaposhnikov2017-09-221-0/+26
| | | | | | | | | | | | | | | | | | For the triple thumbv7-apple-ios8.0.0 ssize_t is long and size_t is unsigned long, while NSInteger is int and NSUinteger is unsigned int. Following https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html Clang catches it and insert a cast to long, for example printf("%zd", getNSInteger()) will be replaced with printf("%zd", (long)getNSInteger()) but since the underlying type of ssize_t is long the specifier "%zd" is not getting replaced. This diff changes this behavior to enable replacing the specifier "%zd" with the correct one. Differential revision: https://reviews.llvm.org/D38159 Test plan: make check-all llvm-svn: 314011
* [c++2a] Implement P0409R2 - Allow lambda capture [=,this] (by hamzasood)Faisal Vali2017-08-191-1/+0
| | | | | | | | | | This patch, by hamzasood, implements P0409R2, and allows [=, this] pre-C++2a as an extension (with appropriate warnings) for consistency. https://reviews.llvm.org/D36572 Thanks Hamza! llvm-svn: 311224
* Unguarded availability diagnoser should use TraverseStmt instead ofAlex Lorenz2017-08-171-0/+8
| | | | | | | | | Base::TraverseStmt when visiting the then/else branches of if statements This ensures that the statement stack is correctly tracked and correct multi-statement fixit is generated inside of an if (@available) llvm-svn: 311088
* [clang] Get rid of "%T" expansionsKuba Mracek2017-08-151-5/+6
| | | | | | | | | | The %T lit expansion expands to a common directory shared between all the tests in the same directory, which is unexpected and unintuitive, and more importantly, it's been a source of subtle race conditions and flaky tests. In https://reviews.llvm.org/D35396, it was agreed that it would be best to simply ban %T and only keep %t, which is unique to each test. When a test needs a temporary directory, it can just create one using mkdir %t. This patch removes %T in clang. Differential Revision: https://reviews.llvm.org/D36437 llvm-svn: 310950
* Replace remaining user-visible mentions of C++1z with C++17.Richard Smith2017-08-131-1/+1
| | | | llvm-svn: 310804
* -Wpragma-pack: add an additional note and fixit when warningAlex Lorenz2017-07-311-0/+5
| | | | | | | | | about unterminated push directives that are followed by a reset ('#pragma pack()') This has been suggested by Hans Wennborg. llvm-svn: 309559
* unguarded availability: add a fixit for the "annotate '...'Alex Lorenz2017-07-262-0/+39
| | | | | | | | | | with an availability attribute to silence" note rdar://33539233 Differential Revision: https://reviews.llvm.org/D35726 llvm-svn: 309116
* clang/test/FixIt/format.m: Tweak for i686, where ssize_t is int. (r308067)NAKAMURA Takumi2017-07-151-2/+2
| | | | llvm-svn: 308084
* [clang] Fix format test Alexander Shaposhnikov2017-07-151-3/+3
| | | | | | | | | This diff makes the test FixIt/format.m more robust. The issue was caught by the build bot clang-cmake-thumbv7-a15. Test plan: make check-all llvm-svn: 308073
* [clang] Fix handling of "%zd" format specifierAlexander Shaposhnikov2017-07-141-0/+13
| | | | | | | | | | | | | This diff addresses FIXME in lib/Analysis/PrintfFormatString.cpp and makes PrintfSpecifier::getArgType return the correct type. In particular, this change enables Clang to emit a warning on incorrect using of "%zd"/"%zn" format specifiers. Differential revision: https://reviews.llvm.org/D35427 Test plan: make check-all llvm-svn: 308067
* Add a fixit for -Wobjc-protocol-property-synthesisAlex Lorenz2017-07-031-0/+14
| | | | | | | | rdar://32132756 Differential Revision: https://reviews.llvm.org/D34886 llvm-svn: 307014
* [clang] Enable printf check for CFIndexAlexander Shaposhnikov2017-06-262-1/+32
| | | | | | | | | | | | | | According to https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html CFIndex and NSInteger should be treated the same way (see the section Platform Dependencies). This diff changes the function shouldNotPrintDirectly in SemaChecking.cpp accordingly and adds tests for the "fixit" and the warning. Differential revision: https://reviews.llvm.org/D34496 Test plan: make check-all llvm-svn: 306343
* [clang] Fix format specifiers fixits for nested macrosAlexander Shaposhnikov2017-06-201-0/+17
| | | | | | | | | | | | | | 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
* [clang] Cleanup fixit.cAlexander Shaposhnikov2017-06-091-2/+1
| | | | | | | | | | | | This diff removes temporary file t2 in fixit.c and updates the test command accordingly. NFC. Test plan: make check-all Differential revision: https://reviews.llvm.org/D34066 llvm-svn: 305124
* [clang] Fix format specifiers fixitsAlexander Shaposhnikov2017-06-081-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add support for pretty platform names to `@available`/Alex Lorenz2017-05-092-22/+22
| | | | | | | | | | | | | `__builtin_available` This commit allows us to use the macOS/iOS/tvOS/watchOS platform names in `@available`/`__builtin_available`. rdar://32067795 Differential Revision: https://reviews.llvm.org/D33000 llvm-svn: 302540
* Add a fix-it for -Wunguarded-availabilityAlex Lorenz2017-05-052-0/+121
| | | | | | | | | | | | | This patch adds a fix-it for the -Wunguarded-availability warning. This fix-it is similar to the Swift one: it suggests that you wrap the statement in an `if (@available)` check. The produced fixits are indented (just like the Swift ones) to make them look nice in Xcode's fix-it preview. rdar://31680358 Differential Revision: https://reviews.llvm.org/D32424 llvm-svn: 302253
* Add #pragma clang attributeAlex Lorenz2017-04-182-0/+89
| | | | | | | | | | | | | | | | | This is a recommit of r300539 that was reverted in r300543 due to test failures. The original commit message is displayed below: The new '#pragma clang attribute' directive can be used to apply attributes to multiple declarations. An attribute must satisfy the following conditions to be supported by the pragma: - It must have a subject list that's defined in the TableGen file. - It must be documented. - It must not be late parsed. - It must have a GNU/C++11 spelling. Differential Revision: https://reviews.llvm.org/D30009 llvm-svn: 300556
* Revert r300539 - Add #pragma clang attributeAlex Lorenz2017-04-182-89/+0
| | | | | | | Some tests fail on the Windows buildbots. I will have to investigate more. This commit reverts r300539, r300540 and r300542. llvm-svn: 300543
* Add #pragma clang attributeAlex Lorenz2017-04-182-0/+89
| | | | | | | | | | | | | | The new '#pragma clang attribute' directive can be used to apply attributes to multiple declarations. An attribute must satisfy the following conditions to be supported by the pragma: - It must have a subject list that's defined in the TableGen file. - It must be documented. - It must not be late parsed. - It must have a GNU/C++11 spelling. Differential Revision: https://reviews.llvm.org/D30009 llvm-svn: 300539
* [Sema] Improve the error diagnostic for dot destructor calls on pointer objectsAlex Lorenz2017-01-202-0/+23
| | | | | | | | | | | | | 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
* Don't try to emit nullability fix-its within/around macros.Jordan Rose2016-12-192-0/+14
| | | | | | | | | | | | | | The newly-added notes from r290132 are too noisy even when the fix-it is valid. For the existing warning from r286521, it's probably the right decision 95% of the time to put the change outside the macro if the array is outside the macro and inside otherwise, but I don't want to overthink it right now. Caught by the ASan bot! More rdar://problem/29524992 llvm-svn: 290141
* Add fix-it notes to the nullability consistency warning.Jordan Rose2016-12-192-18/+41
| | | | | | | | | | | | | | | | | | | | | This is especially important for arrays, since no one knows the proper syntax for putting qualifiers in arrays. nullability.h:3:26: warning: array parameter is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) void arrayParameter(int x[]); ^ nullability.h:3:26: note: insert '_Nullable' if the array parameter may be null void arrayParameter(int x[]); ^ _Nullable nullability.h:3:26: note: insert '_Nonnull' if the array parameter should never be null void arrayParameter(int x[]); ^ _Nonnull rdar://problem/29524992 llvm-svn: 290132
* 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
* Warn when 'assume_nonnull' infers nullability within an array.Jordan Rose2016-11-101-0/+68
| | | | | | | | | | | ...or within a reference. Both of these add an extra level of indirection that make us less certain that the pointer really was supposed to be non-nullable. However, changing the default behavior would be a breaking change, so we'll just make it a warning instead. Part of rdar://problem/25846421 llvm-svn: 286521
* ObjC Class Property: diagnostics when accessing a class property using instance.Manman Ren2016-06-281-0/+8
| | | | | | | | | | | | | When a class property is accessed with an object instance, before this commit, we try to apply a typo correction of the same property: property 'c' not found on object of type 'A *'; did you mean 'c'? With this commit, we correctly emit a diagnostics: property 'c' is a class property; did you mean to access it with class 'A'? rdar://26866973 llvm-svn: 274076
* Re-commit r273548, reverted in r273589, with a fix to not produceRichard Smith2016-06-231-1/+1
| | | | | | | | | | | | | | | | -Wfor-loop-analysis warnings for a for-loop with a condition variable. In such a case, the loop condition variable is modified on each iteration of the loop by definition. Original commit message: Rearrange condition handling so that semantic checks on a condition variable are performed before the other substatements of the construct are parsed, rather than deferring them until the end. This allows better error recovery from semantic errors in the condition, improves diagnostic order, and is a prerequisite for C++17 constexpr if. llvm-svn: 273600
* Revert r273548, "Rearrange condition handling so that semantic checks on a ↵Peter Collingbourne2016-06-231-1/+1
| | | | | | | | condition variable" as it caused a regression in -Wfor-loop-analysis. llvm-svn: 273589
* Rearrange condition handling so that semantic checks on a condition variableRichard Smith2016-06-231-1/+1
| | | | | | | | | are performed before the other substatements of the construct are parsed, rather than deferring them until the end. This allows better error recovery from semantic errors in the condition, improves diagnostic order, and is a prerequisite for C++17 constexpr if. llvm-svn: 273548
* FixIt: use getLocForEndOfToken to insert fix-it after a type name.Manman Ren2016-06-021-2/+11
| | | | | | | | | | | | | | | | Instead of setting DeclSpec's range end to point to the next token after the DeclSpec, we use getLocForEndOfToken to insert fix-it after a type name. Before this fix, fix-it will change ^(NSView view) to ^(*NSView view) This commit correctly updates the source to ^(NSView* view). rdar://21042144 Differential Revision: http://reviews.llvm.org/D20844 llvm-svn: 271448
* Add the Pure attribute to C99 builtin functions from ctype.h. This is a ↵Aaron Ballman2016-05-041-2/+0
| | | | | | | | corrected version of r266199 with test case fixes. Patch by Taewook Oh. llvm-svn: 268553
* Set the default C standard to C99 when targeting the PS4.Sunil Srivastava2016-04-271-0/+3
| | | | | | | | Patch by Douglas Yung! Differential Revision: http://reviews.llvm.org/D19003 llvm-svn: 267772
OpenPOWER on IntegriCloud