summaryrefslogtreecommitdiff
path: root/lib/AST/DeclObjC.cpp
Commit message (Collapse)AuthorAge
* If a declaration is loaded, and then a module import adds a redeclaration, thenRichard Smith2014-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ensure that querying the first declaration for its most recent declaration checks for redeclarations from the imported module. This works as follows: * The 'most recent' pointer on a canonical declaration grows a pointer to the external AST source and a generation number (space- and time-optimized for the case where there is no external source). * Each time the 'most recent' pointer is queried, if it has an external source, we check whether it's up to date, and update it if not. * The ancillary data stored on the canonical declaration is allocated lazily to avoid filling it in for declarations that end up being non-canonical. We'll still perform a redundant (ASTContext) allocation if someone asks for the most recent declaration from a decl before setPreviousDecl is called, but such cases are probably all bugs, and are now easy to find. Some finessing is still in order here -- in particular, we use a very general mechanism for handling the DefinitionData pointer on CXXRecordData, and a more targeted approach would be more compact. Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was addressing only a corner of the full problem space here. That's not covered by this patch. Early performance benchmarks show that this makes no measurable difference to Clang performance without modules enabled (and fixes a major correctness issue with modules enabled). I'll revert if a full performance comparison shows any problems. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209046 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Use 'nullptr'. AST edition.Craig Topper2014-05-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208517 91177308-0d34-0410-b5e6-96231b3b80d8
* Stop all the Decl classes poking at Redeclarable's data member directly, and ↵Richard Smith2014-05-10
| | | | | | make getNextRedeclaration follow the pattern of its friends getPreviousDecl and getMostRecentDecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208467 91177308-0d34-0410-b5e6-96231b3b80d8
* [SemaObjC] Fix ObjCInterfaceDecl::inheritsDesignatedInitializers(), if there ↵Argyrios Kyrtzidis2014-04-26
| | | | | | | | | | are no designated initializers in the super class hierarchy then it should return false. rdar://16692535 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207332 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix indentation, NFC.Argyrios Kyrtzidis2014-04-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206411 91177308-0d34-0410-b5e6-96231b3b80d8
* [objc] Consider new initializers inside @implementation when determining if ↵Argyrios Kyrtzidis2014-04-16
| | | | | | | | | | the class introduces new initializers. Part of rdar://16568441 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206409 91177308-0d34-0410-b5e6-96231b3b80d8
* [SemaObjC] For the semantics of the designated-initializer attribute, ↵Argyrios Kyrtzidis2014-03-28
| | | | | | | | | | consider that the ObjC interface of the class includes its class extensions. This is follow-up for rdar://16305347 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205065 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing ObjCImplementationDecl iterators ivar_begin() and ↵Aaron Ballman2014-03-14
| | | | | | ivar_end() with iterator_range ivars(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203932 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing ObjCCategoryDecl iterators propimpl_begin() and ↵Aaron Ballman2014-03-14
| | | | | | propimpl_end() with iterator_range property_impls(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203930 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing ObjCCategoryDecl iterators protocol_begin() and ↵Aaron Ballman2014-03-14
| | | | | | protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203922 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing ObjCProtocolDecl iterators protocol_begin() and ↵Aaron Ballman2014-03-13
| | | | | | protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203863 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing ObjCInterfaceDecl iterators known_extensions_begin() and ↵Aaron Ballman2014-03-13
| | | | | | known_extensions_end() with iterator_range known_extensions(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203857 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing ObjCInterfaceDecl iterators visible_extensions_begin() and ↵Aaron Ballman2014-03-13
| | | | | | visible_extensions_end() with iterator_range visible_extensions(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203855 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing ObjCInterfaceDecl iterators known_categories_begin() and ↵Aaron Ballman2014-03-13
| | | | | | known_categories_end() with iterator_range known_categories(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203854 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing ObjCInterfaceDecl iterators visible_categories_begin() and ↵Aaron Ballman2014-03-13
| | | | | | visible_categories_end() with iterator_range visible_categories(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203851 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing ObjCInterfaceDecl iterators ↵Aaron Ballman2014-03-13
| | | | | | all_referenced_protocol_begin() and all_referenced_protocol_end() with iterator_range all_referenced_protocols(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203848 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing ObjCInterfaceDecl iterators protocol_begin() and ↵Aaron Ballman2014-03-13
| | | | | | | | protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops. Drive-by fixing some incorrect types where a for loop would be improperly using ObjCInterfaceDecl::protocol_iterator. No functional changes in these cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203842 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing ObjCContainerDecl iterators instmeth_begin() and ↵Aaron Ballman2014-03-13
| | | | | | instmeth_end() with iterator_range instance_methods(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203839 91177308-0d34-0410-b5e6-96231b3b80d8
* Renaming the recently-created (r203830) props() range API to properties() ↵Aaron Ballman2014-03-13
| | | | | | for clarity. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203835 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing ObjCContainerDecl iterators prop_begin() and prop_end() ↵Aaron Ballman2014-03-13
| | | | | | with iterator_range props(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203830 91177308-0d34-0410-b5e6-96231b3b80d8
* Objective-C. Prevent an assertion crash due to buggy codeFariborz Jahanian2014-03-11
| | | | | | | | as it can commonly happen. // rdar://16261494 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203598 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing iterators redecls_begin() and redecls_end() with ↵Aaron Ballman2014-03-06
| | | | | | iterator_range redecls(). Updating all of the usages of the iterators with range-based for loops, which allows the begin/end forms to be removed entirely. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203179 91177308-0d34-0410-b5e6-96231b3b80d8
* Objective-C. Return 0 as class of methods in protocols.Fariborz Jahanian2014-03-04
| | | | | | | | This simplifies my last patch a bit. No change in functionality. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202906 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove obsolete ObjCMethodDecl arg_type iterator functionsAlp Toker2014-01-25
| | | | | | These were set into deprecation in r199773. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200086 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-25
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200082 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-20
| | | | | | | | | | | | | | | | | Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199686 91177308-0d34-0410-b5e6-96231b3b80d8
* Distinguish between attributes explicitly written at the request of the ↵Aaron Ballman2014-01-16
| | | | | | | | user, and attributes implicitly generated to assist in bookkeeping by the compiler. This is done so by table generating a CreateImplicit method for each attribute. Additionally, remove the optional nature of the spelling list index when creating attributes. This is supported by table generating a Spelling enumeration when the spellings for an attribute are distinct enough to warrant it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199378 91177308-0d34-0410-b5e6-96231b3b80d8
* [objc] Refactor and improve functionality for the -Wunused-property-ivar ↵Argyrios Kyrtzidis2014-01-03
| | | | | | | | | | | | | | warning. - Remove the additions to ObjCMethodDecl & ObjCIVarDecl that were getting de/serialized and consolidate all functionality for the checking for this warning in Sema::DiagnoseUnusedBackingIvarInAccessor - Don't check immediately after the method body is finished, check when the @implementation is finished. This is so we can see if the ivar was referenced by any other method, even if the method was defined after the accessor. - Don't silence the warning if any method is called from the accessor silence it if the accessor delegates to another method via self. rdar://15727325 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198432 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename attribute 'objc_suppress_protocol_methods' to ↵Ted Kremenek2013-12-10
| | | | | | | | | | | | | | | 'objc_protocol_requires_explicit_implementation'. That's a mouthful, and not necessarily the final name. This also reflects a semantic change where this attribute is now on the protocol itself instead of a class. This attribute will require that a protocol, when adopted by a class, is explicitly implemented by the class itself (instead of walking the super class chain). Note that this attribute is not "done". This should be considered a WIP. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196955 91177308-0d34-0410-b5e6-96231b3b80d8
* [AST] In ObjCInterfaceDecl::isDesignatedInitializer(), use getMethod() ↵Argyrios Kyrtzidis2013-12-10
| | | | | | | | instead of lookupMethod(). lookupMethod also goes through categories, which we don't need there. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196942 91177308-0d34-0410-b5e6-96231b3b80d8
* [objc] If an interface has no initializer marked as designated and ↵Argyrios Kyrtzidis2013-12-05
| | | | | | | | | | | introduces at least one new initializer, don't assume that it inherits the designated initializers from the super class. If the assumption was wrong because a new initializer was a designated one that was not marked as such, we will emit misleading warnings for subclasses of the interface. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196476 91177308-0d34-0410-b5e6-96231b3b80d8
* [objc] Emit warning when the implementation of a secondary initializer calls onArgyrios Kyrtzidis2013-12-03
| | | | | | | | | | | super another initializer and when the implementation does not delegate to another initializer via a call on 'self'. A secondary initializer is an initializer method not marked as a designated initializer within a class that has at least one initializer marked as a designated initializer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196318 91177308-0d34-0410-b5e6-96231b3b80d8
* [objc] Emit warnings when the implementation of a designated initializer ↵Argyrios Kyrtzidis2013-12-03
| | | | | | | | calls on super an initializer that is not a designated one or any initializer on self. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196317 91177308-0d34-0410-b5e6-96231b3b80d8
* [objc] Emit a warning when the implementation of a designated initializer ↵Argyrios Kyrtzidis2013-12-03
| | | | | | | | does not chain to an init method that is a designated initializer for the superclass. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196316 91177308-0d34-0410-b5e6-96231b3b80d8
* [objc] Introduce ObjCInterfaceDecl::getDesignatedInitializers() to get theArgyrios Kyrtzidis2013-12-03
| | | | | | | | | | designated initializers of an interface. If the interface declaration does not have methods marked as designated initializers then the interface inherits the designated initializers of its super class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196315 91177308-0d34-0410-b5e6-96231b3b80d8
* Use specific_attr_iterator to tighten loop over ObjCSuppressProtocolAttrs.Ted Kremenek2013-11-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195561 91177308-0d34-0410-b5e6-96231b3b80d8
* Move logic to check if a class is tagged with objc_suppress_protocol_methods ↵Ted Kremenek2013-11-23
| | | | | | into a helper. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195559 91177308-0d34-0410-b5e6-96231b3b80d8
* Add back experimental attribute objc_suppress_protocol_methods (slightly ↵Ted Kremenek2013-11-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | renamed). This is still an experimental attribute, but I wanted it in tree for review. It may still get yanked. This attribute can only be applied to a class @interface, not a class extension or category. It does not change the type system rules for Objective-C, but rather the implementation checking for Objective-C classes that explicitly conform to a protocol. During protocol conformance checking, clang recursively searches up the class hierarchy for the set of methods that compose a protocol. This attribute will cause the compiler to not consider the methods contributed by a super class, its categories, and those from its ancestor classes. Thus this attribute is used to force subclasses to redeclare (and hopefully re-implement) methods if they decide to explicitly conform to a protocol where some of those methods may be provided by a super class. This attribute intentionally leaves out properties, which are associated with state. This attribute only considers methods (at least right now) that are non-property accessors. These represent methods that "do something" as dictated by the protocol. This may be further refined, and this should be considered a WIP until documentation gets written or this gets removed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195533 91177308-0d34-0410-b5e6-96231b3b80d8
* Change ObjCIntefaceDecl::lookupMethod() to have optional 'followsSuper' ↵Ted Kremenek2013-11-23
| | | | | | | | | | | | | | argument. This enables a micro-optimization in protocol conformance checking to not examine the class hierarchy twice per method. As part of this change, remove the default arguments from lookupInstanceMethod() and lookupClassMethod(). It was becoming very redundant. For clients needing the default arguments, have them use the full API instead of these convenience methods. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195532 91177308-0d34-0410-b5e6-96231b3b80d8
* Add class-specific operator new to Decl hierarchy. This guarantees that DeclsRichard Smith2013-11-22
| | | | | | | | | | | | | | can't accidentally be allocated the wrong way (missing prefix data for decls from AST files, for instance) and simplifies the CreateDeserialized functions a little. An extra DeclContext* parameter to the not-from-AST-file operator new allows us to ensure that we don't accidentally call the wrong one when deserializing (when we don't have a DeclContext), allows some extra checks, and prepares for some planned modules-related changes to Decl allocation. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195426 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Add new attribute 'objc_suppress_protocol' to suppress protocol ↵Ted Kremenek2013-11-21
| | | | | | | | | | | conformance for a class." After implementing this patch, a few concerns about the language feature itself emerged in my head that I had previously not considered. I want to resolve those design concerns first before having a half-designed language feature in the tree. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195328 91177308-0d34-0410-b5e6-96231b3b80d8
* Add new attribute 'objc_suppress_protocol' to suppress protocol conformance ↵Ted Kremenek2013-11-21
| | | | | | | | | | | | | | | | | | | | | | | for a class. The idea is to allow a class to stipulate that its methods (and those of its parents) cannot be used for protocol conformance in a subclass. A subclass is then explicitly required to re-implement those methods of they are present in the class marked with this attribute. Currently the attribute can only be applied to an @interface, and not a category or class extension. This is by design. Unlike protocol conformance, where a category can add explicit conformance of a protocol to class, this anti-conformance really needs to be observed uniformly by all clients of the class. That's because the absence of the attribute implies more permissive checking of protocol conformance. This unfortunately required changing method lookup in ObjCInterfaceDecl to take an optional protocol parameter. This should not slow down method lookup in most cases, and is just used for protocol conformance. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195323 91177308-0d34-0410-b5e6-96231b3b80d8
* ObjectiveC: under -Wunused-property-ivar warn if property'sFariborz Jahanian2013-10-25
| | | | | | | | backing warning is not used in one of its accessor methods. // rdar://14989999 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193439 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename some functions for consistency.Rafael Espindola2013-10-17
| | | | | | Every other function in Redeclarable.h was using Decl instead of Declaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192900 91177308-0d34-0410-b5e6-96231b3b80d8
* ObjC migrator: Improve on hueristics.Fariborz Jahanian2013-07-10
| | | | | | | | | | | | | migrate to 'copy attribute if Object class implements NSCopying otherwise assume implied 'strong'. Remove lifetime qualifier on property as it has moved to property's attribute. Added TODO comment for future work by poking into setter implementation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186037 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix potential infinite loop when iterating over redeclarations of an ↵Argyrios Kyrtzidis2013-05-30
| | | | | | | | | | | ObjMethodDecl, resulting from invalid code. Check for invalid decls in ObjCMethodDecl::getNextRedeclaration(); otherwise if we start from an invalid redeclaration of an @implementation we would move to the @interface and not reach the original declaration again. Fixes rdar://14024851 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182951 91177308-0d34-0410-b5e6-96231b3b80d8
* Objective-C [qoi]: When an class conforms to multipleFariborz Jahanian2013-05-20
| | | | | | | | | protocols that declare the same property of incompatible types, issue a warning when class implementation synthesizes the property. // rdar://13075400 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182316 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace ArrayRef<T>() with None, now that we have an implicit ArrayRef ↵Dmitri Gribenko2013-05-05
| | | | | | | | | constructor from None Patch by Robert Wilhelm. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181139 91177308-0d34-0410-b5e6-96231b3b80d8
* Keep track of an @implementation's super class name location, if one was ↵Argyrios Kyrtzidis2013-05-03
| | | | | | provided. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181039 91177308-0d34-0410-b5e6-96231b3b80d8
* Objective-C: This is a small modification to myFariborz Jahanian2013-04-25
| | | | | | | | | | | patch -n r180198. When reporting on missing property accessor implementation in categories, do not report when they are declared in primary class, class's protocol, or one of it super classes or in of the other categories. // rdar://13713098 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180580 91177308-0d34-0410-b5e6-96231b3b80d8