summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaObjC
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "Correct class-template deprecation behavior"Martin Bohme2017-03-223-6/+6
| | | | | | | This reverts commit r298410 (which produces incorrect warnings, see comments on https://reviews.llvm.org/rL298410). llvm-svn: 298504
* Correct class-template deprecation behaviorErich Keane2017-03-213-6/+6
| | | | | | | | | | | | | Based on the comment in the test, and my reading of the standard, a deprecated warning should be issued in the following case: template<typename T> [[deprecated]] class Foo{}; Foo<int> f; This was not the case, because the ClassTemplateSpecializationDecl creation did not also copy the deprecated attribute. Note: I did NOT audit the complete set of attributes to see WHICH ones should be copied, so instead I simply copy ONLY the deprecated attribute. Differential Revision: https://reviews.llvm.org/D27486 llvm-svn: 298410
* [ObjC][Sema] Avoid ARC performSelector error for 'self' selectorAlex Lorenz2017-03-161-0/+3
| | | | | | | | | The instance method 'self' does not actually return an over-retained object, so we shouldn't report an error when it's used with 'performSelector'. rdar://31071620 llvm-svn: 297961
* [ObjC][Sema] Avoid warning about a call to an instance method on anAlex Lorenz2017-03-151-0/+27
| | | | | | | | | | | | | | | | instance of a qualified Class object when that instance method comes from a protocol that's implemented by NSObject Instance methods from a root class like NSObject are also class methods because the metaclass of root class derives from that root class. Therefore, we can avoid the warning for instances of qualified Class objects that point to classes that derive from NSObject. Note that we actually don't know if a Class instance points to a class that derives from NSObject at compile-time, so we have to make a reasonable assumption that the majority of instances will do so. rdar://22812517 llvm-svn: 297862
* [Sema][ObjC] Warn about 'performSelector' calls with selectorsAlex Lorenz2017-03-061-0/+127
| | | | | | | | | | | | | | | | | | | that return record or vector types The performSelector family of methods from Foundation use objc_msgSend to dispatch the selector invocations to objects. However, method calls to methods that return record types might have to use the objc_msgSend_stret as the return value won't find into the register. This is also supported by this sentence from performSelector documentation: "The method should not have a significant return value and should take a single argument of type id, or no arguments". This commit adds a new warning that warns when a selector which corresponds to a method that returns a record type is passed into performSelector. rdar://12056271 Differential Revision: https://reviews.llvm.org/D30174 llvm-svn: 297019
* Sema: use PropertyDecl for property selectorSaleem Abdulrasool2017-02-201-0/+9
| | | | | | | | | | | Using the constructed name for the class properties with dot syntax may yield an inappropriate selector (i.e. if it is specified via property attributes). Prefer the declaration for the selector, falling back to the constructed name otherwise. Patch by David Herzka! llvm-svn: 295683
* [Sema][ObjC] perform-selector ARC check should see @selector in parensAlex Lorenz2017-02-201-0/+1
| | | | llvm-svn: 295674
* Use correct fix-it location for -Wblock-capture-autoreleasingAlex Lorenz2017-02-161-0/+7
| | | | | | | | | The '__autoreleasing' keyword should be inserted after the Objective-C pointer type. rdar://30123548 llvm-svn: 295381
* [Sema][ObjC] Don't pass a DeclRefExpr that doesn't reference a VarDeclAkira Hatanaka2017-02-011-0/+13
| | | | | | | | | | to WeakObjectProfileTy's constructor. This fixes an assertion failure in WeakObjectProfileTy's constructor. rdar://problem/30112633 llvm-svn: 293808
* Turn on -Wblock-capture-autoreleasing by default.Akira Hatanaka2017-01-261-1/+1
| | | | | | | | | | Turning on the warning by default helps the users as it's a common mistake to capture out-parameters in a block without ensuring the object assigned doesn't get released. rdar://problem/30200058 llvm-svn: 293199
* [Sema][ObjC] Make sure -Wblock-capture-autoreleasing issues a warningAkira Hatanaka2017-01-261-1/+22
| | | | | | | | | | | | | | | even in the presence of nullability qualifiers. This commit fixes bugs in r285031 where -Wblock-capture-autoreleasing wouldn't issue warnings when the function parameters were annotated with nullability qualifiers. Specifically, look through the sugar and see if there is an AttributedType of kind attr_objc_ownership to determine whether __autoreleasing was explicitly specified or implicitly added by the compiler. rdar://problem/30193488 llvm-svn: 293194
* [ObjC] The declarator for a block literal should be a definitionAlex Lorenz2017-01-061-1/+1
| | | | | | | | | | | This change avoids the -Wstrict-prototypes warning for block literals with an empty argument list or without argument lists. rdar://15060615 Differential Revision: https://reviews.llvm.org/D28296 llvm-svn: 291231
* Fix printf specifier handling: invalid specifier should not be marked as ↵Mehdi Amini2016-12-151-1/+1
| | | | | | | | | | | | "consuming data arguments" Reviewers: rsmith, bruno, dexonsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27796 llvm-svn: 289850
* [PS4] Undo dialect tweak for Objective-C.Paul Robinson2016-12-141-4/+1
| | | | | | | | In r267772, we had set the PS4's default dialect for both C and Objective-C to gnu99. Make that change only for C; we don't really support Objective-C/C++ so there's no point fiddling the dialect. llvm-svn: 289625
* DR616, and part of P0135R1: member access (or pointer-to-member access) on aRichard Smith2016-12-031-2/+3
| | | | | | | temporary produces an xvalue, not a prvalue. Support this by materializing the temporary prior to performing the member access. llvm-svn: 288563
* [ObjC] Prevent infinite loops when iterating over redeclarationAlex Lorenz2016-11-211-0/+21
| | | | | | | | | | | | | | | | of a method that was declared in an invalid interface This commit fixes an infinite loop that occurs when clang tries to iterate over redeclaration of a method that was declared in an invalid @interface. The existing validity checks don't catch this as that @interface is a duplicate of a previously declared valid @interface declaration, so we have to verify that the found redeclaration is in a valid declaration context. rdar://29220965 Differential Revision: https://reviews.llvm.org/D26664 llvm-svn: 287530
* Sema: correct typo correction for ivars in @implementationSaleem Abdulrasool2016-11-171-1/+24
| | | | | | | | | | | | The previous typo correction handling assumed that ivars are only declared in the interface declaration rather than as a private ivar in the implementation. Adjust the handling to permit both interfaces. Assert earlier that the interface has been acquired to ensure that we can identify when both possible casts have failed. Addresses PR31040! llvm-svn: 287238
* Accept nullability qualifiers on array parameters.Jordan Rose2016-11-101-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since array parameters decay to pointers, '_Nullable' and friends should be available for use there as well. This is especially important for parameters that are typedefs of arrays. The unsugared syntax for this follows the syntax for 'static'-sized arrays in C: void test(int values[_Nullable]); This syntax was previously accepted but the '_Nullable' (and any other attributes) were silently discarded. However, applying '_Nullable' to a typedef was previously rejected and is now accepted; therefore, it may be necessary to test for the presence of this feature: #if __has_feature(nullability_on_arrays) One important change here is that DecayedTypes don't always immediately contain PointerTypes anymore; they may contain an AttributedType instead. This only affected one place in-tree, so I would guess it's not likely to cause problems elsewhere. This commit does not change -Wnullability-completeness just yet. I want to think about whether it's worth doing something special to avoid breaking existing clients that compile with -Werror. It also doesn't change '#pragma clang assume_nonnull' behavior, which currently treats the following two declarations as equivalent: #pragma clang assume_nonnull begin void test(void *pointers[]); #pragma clang assume_nonnull end void test(void * _Nonnull pointers[]); This is not the desired behavior, but changing it would break backwards-compatibility. Most likely the best answer is going to be adding a new warning. Part of rdar://problem/25846421 llvm-svn: 286519
* Add -Wduplicate-protocol for existing diagnosticAlex Lorenz2016-11-101-0/+6
| | | | | | | | | | | | | | Expose a warning flag for warn_duplicate_protocol_def. This allows control over the severity of duplicate protocol definitions. For example -Werror=duplicate-protocol or #pragma clang diagnostic ignored "-Wduplicate-protocol". Patch provided by Dave Lee! Differential Revision: https://reviews.llvm.org/D26406 llvm-svn: 286487
* [Sema] Delay partial availability diagnostics, just like deprecatedErik Pilkington2016-10-281-3/+2
| | | | | | | | | This is done so that the following compiles with no warnings: int fn(type_10_12) __attribute__((availability(macos, introduced=10.12))); Differential revision: https://reviews.llvm.org/D25284 llvm-svn: 285457
* [Objective-C] Add objc_subclassing_restricted attributeAlex Lorenz2016-10-281-0/+36
| | | | | | | | | | | | | | | | | | | | This patch adds an objc_subclassing_restricted attribute into clang. This attribute acts similarly to 'final' - Objective-C classes with this attribute can't be subclassed. However, @interface declarations that have objc_subclassing_restricted but don't have @implementation are allowed to inherit other @interface declarations with objc_subclassing_restricted. This is needed to describe the Swift class hierarchy in clang while making sure that the Objective-C classes cannot subclass the Swift classes. This attribute is already implemented in a fork of clang that's used for Swift (https://github.com/apple/swift-clang) and this patch moves that code to the upstream clang repository. rdar://28937548 Differential Revision: https://reviews.llvm.org/D25993 llvm-svn: 285391
* Reapply r284265: "[Sema] Refactor context checking for availability diagnostics"Erik Pilkington2016-10-251-1/+24
| | | | | | | | The problem with the original commit was that some of Apple's headers depended on an incorrect behaviour, this commit adds a temporary workaround until those headers are fixed. llvm-svn: 285098
* Fix diagnostic format string for err_os_log_argument_to_bigBenjamin Kramer2016-10-251-0/+3
| | | | | | | | Patch by Sam McCall, test case by me. Differential Revision: https://reviews.llvm.org/D25936 llvm-svn: 285065
* [Sema][ObjC] Warn about implicitly autoreleasing out-parameters capturedAkira Hatanaka2016-10-241-1/+8
| | | | | | | | | | | | | | by blocks. Add a new warning "-Wblock-capture-autoreleasing". The warning warns about implicitly autoreleasing out-parameters captured by blocks which can introduce use-after-free bugs that are hard to debug. rdar://problem/15377548 Differential Revision: https://reviews.llvm.org/D25844 llvm-svn: 285031
* Add support for __builtin_os_log_format[_buffer_size]Mehdi Amini2016-10-241-0/+62
| | | | | | | | | | | | | | | | | This reverts commit r285007 and reapply r284990, with a fix for the opencl test that I broke. Original commit message follows: These new builtins support a mechanism for logging OS events, using a printf-like format string to specify the layout of data in a buffer. The _buffer_size version of the builtin can be used to determine the size of the buffer to allocate to hold the data, and then __builtin_os_log_format can write data into that buffer. This implements format checking to report mismatches between the format string and the data arguments. Most of this code was written by Chris Willmore. Differential Revision: https://reviews.llvm.org/D25888 llvm-svn: 285019
* Revert "Add support for __builtin_os_log_format[_buffer_size]"Mehdi Amini2016-10-241-62/+0
| | | | | | This reverts commit r284990, two opencl test are broken llvm-svn: 285007
* Add support for __builtin_os_log_format[_buffer_size]Mehdi Amini2016-10-241-0/+62
| | | | | | | | | | | | | | These new builtins support a mechanism for logging OS events, using a printf-like format string to specify the layout of data in a buffer. The _buffer_size version of the builtin can be used to determine the size of the buffer to allocate to hold the data, and then __builtin_os_log_format can write data into that buffer. This implements format checking to report mismatches between the format string and the data arguments. Most of this code was written by Chris Willmore. Differential Revision: https://reviews.llvm.org/D25888 llvm-svn: 284990
* [Sema] Formatting warnings should see through Objective-C message sendsAlex Lorenz2016-10-241-0/+38
| | | | | | | | | | | | This commit improves the '-Wformat' warnings by ensuring that the formatting checker can see through Objective-C message sends when we are calling an Objective-C method with an appropriate format_arg attribute. rdar://23622446 Differential Revision: https://reviews.llvm.org/D25820 llvm-svn: 284961
* Revert r284265 "[Sema] Refactor context checking for availability diagnostics"Erik Pilkington2016-10-181-17/+1
| | | | | | This has a bug in it, pointed out by Bob Wilson! llvm-svn: 284486
* [Sema] Refactor context checking for availability diagnosticsErik Pilkington2016-10-141-1/+17
| | | | | | | | | This commit combines a couple of redundant functions that do availability attribute context checking into a more correct/simpler one. Differential revision: https://reviews.llvm.org/D25283 llvm-svn: 284265
* [SemaObjC] Be more strict while parsing type arguments and protocolsBruno Cardoso Lopes2016-09-131-0/+40
| | | | | | | | | | | | | | | | | | | | Fix a crash-on-invalid. When parsing type arguments and protocols, parseObjCTypeArgsOrProtocolQualifiers() calls ParseTypeName(), which tries to find matching tokens for '[', '(', etc whenever they appear among potential type names. If unmatched, ParseTypeName() yields a tok::eof token stream. This leads to crashes since the parsing at this point is not expected to go beyond the param list closing '>'. Fix that by properly handling tok::eof in parseObjCTypeArgsOrProtocolQualifiers() callers. Differential Revision: https://reviews.llvm.org/D23852 rdar://problem/25063557 llvm-svn: 281383
* ObjectiveC Generics: Start using ObjCTypeParamType.Manman Ren2016-09-132-1/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | For ObjC type parameter, we used to have TypedefType that is canonicalized to id or the bound type. We can't represent "T <protocol>" and thus will lose the type information in the following example: @interface MyMutableDictionary<KeyType, ObjectType> : NSObject - (void)setObject:(ObjectType)obj forKeyedSubscript:(KeyType <NSCopying>)key; @end MyMutableDictionary<NSString *, NSString *> *stringsByString; NSNumber *n1, *n2; stringsByString[n1] = n2; --> no warning on type mismatch of the key. To fix the problem, we introduce a new type ObjCTypeParamType that supports a list of protocol qualifiers. We create ObjCTypeParamType for ObjCTypeParamDecl when we create ObjCTypeParamDecl. We also substitute ObjCTypeParamType instead of TypedefType on an ObjCTypeParamDecl. rdar://24619481 rdar://25060179 Differential Revision: http://reviews.llvm.org/D23080 llvm-svn: 281358
* [SemaObjC] Do not RebuildObjCMessageExpr without valid method declBruno Cardoso Lopes2016-08-221-0/+15
| | | | | | | | | | | | | | Fix crash-on-invalid in ObjC Sema by avoiding to rebuild a message expression to a 'super' class in case the method to call does not exist (i.e. comes from another missing identifier). In this case, the typo transform is invoked upon the message expression in an attempt to solve a typo in a 'super' call parameters, but it crashes since it assumes the method to call has a valid declaration. rdar://problem/27305403 llvm-svn: 279481
* [ObjC] Warn on unguarded use of partial declarationErik Pilkington2016-08-163-17/+197
| | | | | | | | | | | | | | This commit adds a traversal of the AST after Sema of a function that diagnoses unguarded references to declarations that are partially available (based on availability attributes). This traversal is only done when we would otherwise emit -Wpartial-availability. This commit is part of a feature I proposed here: http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html Differential revision: https://reviews.llvm.org/D23003 llvm-svn: 278826
* Objective-C diagnostics: isObjCNSObjectType should check through AttributedType.Manman Ren2016-08-151-0/+2
| | | | | | | | | | | | For the following example: typedef __attribute__((NSObject)) CGColorRef ColorAttrRef; @property (strong, nullable) ColorAttrRef color; The property type should be ObjC NSObject type and the compiler should not emit error: property with 'retain (or strong)' attribute must be of object type rdar://problem/27747154 llvm-svn: 278742
* [ObjC Availability] Fix partial-availability false positive introduced in ↵Erik Pilkington2016-08-011-0/+5
| | | | | | | | | | r277058 Thanks to Nico Weber for pointing this out! Differential revision: https://reviews.llvm.org/D23024 llvm-svn: 277378
* Reapply r277058: "[ObjC] Consider availability of context when emitting ↵Erik Pilkington2016-07-291-0/+31
| | | | | | availability warnings" llvm-svn: 277175
* Revert "[ObjC] Consider availability of context when emitting availability ↵Erik Pilkington2016-07-281-31/+0
| | | | | | | | | | warnings" Reverting r277058, while I fugure out why it broke internal bots. This reverts commit e514ffa8b657416c6784bbe6da9f5de19365103d. llvm-svn: 277070
* [ObjC] Consider availability of context when emitting availability warningsErik Pilkington2016-07-281-0/+31
| | | | | | | | | | This means that a function marked with an availability attribute can safely refer to a declaration that is greater than the deployment target, but less then or equal to the context availability without -Wpartial-availability firing. Differential revision: https://reviews.llvm.org/D22697 llvm-svn: 277058
* [Sema][ObjC] Compute the nullability of a conditional expression basedAkira Hatanaka2016-07-251-1/+27
| | | | | | | | | | | | on the nullabilities of its operands. This commit is a follow-up to r276076 and enables computeConditionalNullability to compute the merged nullability when the operands are objective-c pointers. rdar://problem/22074116 llvm-svn: 276696
* [SemaObjC] Improve ObjCDictionaryLiteral and ObjCArryLiteral diagnosticsBruno Cardoso Lopes2016-07-192-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | Sema actions on ObjCDictionaryLiteral and ObjCArryLiteral are currently done as a side-effect of Sema upon parent expressions, which incurs of delayed typo corrections for such literals to be performed by TypoTransforms upon the ObjCDictionaryLiteral and ObjCArryLiteral themselves instead of its elements individually. This is specially bad because it was not designed to act on several elements; searching through all possible combinations of corrections for several elements is very expensive. Additionally, when one of the elements has no correction candidate, we still explore all options and at the end emit no typo corrections whatsoever. Do the proper sema actions by acting on each element alone during appropriate literal parsing time to get proper diagonistics and decent compile time behavior. Differential Revision: http://reviews.llvm.org/D22183 rdar://problem/21046678 llvm-svn: 276020
* Sema: support __declspec(dll*) on ObjC interfacesSaleem Abdulrasool2016-07-152-0/+60
| | | | | | | | | | | Extend the __declspec(dll*) attribute to cover ObjC interfaces. This was requested by Microsoft for their ObjC support. Cover both import and export. This only adds the semantic analysis portion of the support, code-generation still remains outstanding. Add some basic initial documentation on the attributes that were previously empty. Tweak the previous tests to use the relative expected-warnings to make the tests easier to read. llvm-svn: 275610
* ObjC Class Property: diagnostics when accessing a class property using instance.Manman Ren2016-06-281-0/+1
| | | | | | | | | | | | | 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
* AvailabilityAttr: we accept "macos" as the platform name.Manman Ren2016-06-284-32/+32
| | | | | | | | | | | | | | We continue accepting "macosx" but canonicalize it to "macos", When emitting diagnostics, we use "macOS" instead of "OS X". The PlatformName in TargetInfo is changed from "macosx" to "macos" so we can directly compare the Platform in AvailabilityAttr with the PlatformName in TargetInfo. rdar://26795172 rdar://26800775 llvm-svn: 274064
* ObjC lifetime: pull sugar off when the qualifiers conflict.Manman Ren2016-06-011-0/+32
| | | | | | | | | | | | It's possible to have multiple local ObjCLifetime qualifiers. When there is a conflict, we can't stop after we reach a type that is directly qualified. We need to keep pulling sugar off and removing the ObjCLifetime qualifers. rdar://25804796 Differential Revision: http://reviews.llvm.org/D20843 llvm-svn: 271409
* Don't feed standard error to FileCheck.Akira Hatanaka2016-05-261-1/+1
| | | | | | | | | This is an attempt to fix the buildbot that started failing after r270808. http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/13141 llvm-svn: 270817
* [ObjC] Remove _Atomic from return type and parameter type ofAkira Hatanaka2016-05-261-0/+61
| | | | | | | | | | | | | | objective-c properties. This fixes an assert in CodeGen that fires when the getter and setter functions for an objective-c property of type _Atomic(_Bool) are synthesized. rdar://problem/26322972 Differential Revision: http://reviews.llvm.org/D20407 llvm-svn: 270808
* arc-repeated-use-of-weak should not warn about IBOutlet propertiesBob Wilson2016-05-251-0/+7
| | | | | | | | | | | | | | Revision r211132 was supposed to disable -Warc-repeated-use-of-weak for Objective-C properties marked with the IBOutlet attribute. Those properties are supposed to be weak but they are only accessed from the main thread so there is no risk of asynchronous updates setting them to nil. That combination makes -Warc-repeated-use-of-weak very noisy. The previous change only handled one kind of access to weak IBOutlet properties. Instead of trying to add checks for all the different kinds of property accesses, this patch removes the previous special case check and adds a check at the point where the diagnostic is reported. rdar://21366461 llvm-svn: 270665
* ObjectiveC: canonicalize "kindof id" to "id".Manman Ren2016-05-201-1/+22
| | | | | | | | There is no need to apply kindof on an unqualified id type. rdar://24753825 llvm-svn: 270241
* ObjectiveC Class Properties: warn if a class property accessor is mistakenly anManman Ren2016-05-181-0/+13
| | | | | | | | | | | | | instance method. When diagnosing unimplemented class property, make sure we emit a warning when we only see an instance method with the right selector. Also warn when we only see a class method for an instance property. rdar://26141719 llvm-svn: 269968
OpenPOWER on IntegriCloud