summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclObjC.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix ObjCMethodDecl::findPropertyDecl for class properties.Jordan Rose2016-03-111-9/+15
| | | | | | | This affects code completion and a few other things; hopefully the code completion test is sufficient to catch regressions. llvm-svn: 263295
* Class Property: change PropertyMap to include isClassProperty.Manman Ren2016-01-281-6/+8
| | | | | | | | | | | | | | PropertyMap used to map IdentifierInfo (name of the property) to ObjcPropertyDecl *. Now that a class property can have the same name as an instance property, we change PropertyMap to map a pair <IdentifierInfo *, unsigned> to ObjcPropertyDecl *. Also update a few places from iterating over instance_properties to iterating over all properties. rdar://23891898 llvm-svn: 259119
* Class Property: class property and instance property can have the same name.Manman Ren2016-01-281-18/+65
| | | | | | | | | | | | | | | | | | | Add "enum ObjCPropertyQueryKind" to a few APIs that used to only take the name of the property: ObjCPropertyDecl::findPropertyDecl, ObjCContainerDecl::FindPropertyDeclaration, ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass, ObjCImplDecl::FindPropertyImplDecl, and Sema::ActOnPropertyImplDecl. ObjCPropertyQueryKind currently has 3 values: OBJC_PR_query_unknown, OBJC_PR_query_instance, OBJC_PR_query_class This extra parameter specifies that we are looking for an instance property with the given name, or a class property with the given name, or any property with the given name (if both exist, the instance property will be returned). rdar://23891898 llvm-svn: 259070
* Class Property: handle class properties.Manman Ren2016-01-271-2/+2
| | | | | | | | At places where we handle instance properties, if necessary. rdar://23891898 llvm-svn: 258979
* Use instance_properties instead of properties. NFC.Manman Ren2016-01-261-6/+6
| | | | | | | | | | | All current properties are instance properties. This is the second patch in a series of patches to support class properties in addition to instance properties in objective-c. rdar://23891898 llvm-svn: 258824
* [TrailingObjects] Convert Decl* classes.James Y Knight2015-12-291-7/+7
| | | | | | | | Also remove now-redundant explicit alignment specification on some of the classes converted prior to TrailingObjects automatically ensuring proper alignment. llvm-svn: 256585
* Stop back-patching 'readonly' Objective-C properties with 'readwrite' ones.Douglas Gregor2015-11-031-11/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | A 'readonly' Objective-C property declared in the primary class can effectively be shadowed by a 'readwrite' property declared within an extension of that class, so long as the types and attributes of the two property declarations are compatible. Previously, this functionality was implemented by back-patching the original 'readonly' property to make it 'readwrite', destroying source information and causing some hideously redundant, incorrect code. Simplify the implementation to express how this should actually be modeled: as a separate property declaration in the extension that shadows (via the name lookup rules) the declaration in the primary class. While here, correct some broken Fix-Its, eliminate a pile of redundant code, clean up the ARC migrator's handling of properties declared in extensions, and fix debug info's naming of methods that come from categories. A wonderous side effect of doing this write is that it eliminates the "AddedObjCPropertyInClassExtension" method from the AST mutation listener, which in turn eliminates the last place where we rewrite entire declarations in a chained PCH file or a module file. This change (which fixes rdar://problem/18475765) will allow us to eliminate the rewritten-decls logic from the serialization library, and fixes a crash (rdar://problem/23247794) illustrated by the test/PCH/chain-categories.m example. llvm-svn: 251874
* DeclObjC: Move computing the type of self into a separate function (NFC).Adrian Prantl2015-07-081-5/+13
| | | | | | This function will be used for emitting debug info. llvm-svn: 241748
* Use AlignOf instead of alignOf so that this can go back to being a ↵Aaron Ballman2015-07-071-3/+3
| | | | | | static_assert. Amends r241577. llvm-svn: 241604
* Changing a use of alignof() into llvm::alignOf() for MSVC compatibility. ↵Aaron Ballman2015-07-071-2/+3
| | | | | | This requires changing a static_assert into an assert, too. llvm-svn: 241577
* Don't rely on the use of non-POD types within unions.Douglas Gregor2015-07-071-1/+3
| | | | | | | They aren't universally supported and we're not getting any benefit from using them. llvm-svn: 241564
* [libclang] Replace ObjC generic parameters when code-completing method ↵Douglas Gregor2015-07-071-0/+6
| | | | | | | | implementations. rdar://20643768 llvm-svn: 241559
* The AST importer had a bug where it would enter into an infinite recursionDouglas Gregor2015-07-071-13/+22
| | | | | | | | | | | | | | | | when importing type parameter lists. The reason is that type parameters have their DeclContexts set to the interface that is parameterized with those types, and the importer would follow that loop and blow the stack out. I've changed the way this works so that the type parameters are only imported after the interface that contains them has been registered via the Imported() function. This is tested by LLDB. <rdar://problem/20315663> llvm-svn: 241556
* Implement variance for Objective-C type parameters.Douglas Gregor2015-07-071-5/+13
| | | | | | | | | | | | | | | Introduce co- and contra-variance for Objective-C type parameters, which allows us to express that (for example) an NSArray is covariant in its type parameter. This means that NSArray<NSMutableString *> * is a subtype of NSArray<NSString *> *, which is expected of the immutable Foundation collections. Type parameters can be annotated with __covariant or __contravariant to make them co- or contra-variant, respectively. This feature can be detected by __has_feature(objc_generics_variance). Implements rdar://problem/20217490. llvm-svn: 241549
* Improve the Objective-C common-type computation used by the ternary operator.Douglas Gregor2015-07-071-1/+1
| | | | | | | | | | | | | | | | The Objective-C common-type computation had a few problems that required a significant rework, including: - Quadradic behavior when finding the common base type; now it's linear. - Keeping around type arguments when computing the common type between a specialized and an unspecialized type - Introducing redundant protocol qualifiers. Part of rdar://problem/6294649. Also fixes rdar://problem/19572837 by addressing a longstanding bug in ASTContext::CollectInheritedProtocols(). llvm-svn: 241544
* Substitute type arguments into uses of Objective-C interface members.Douglas Gregor2015-07-071-2/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When messaging a method that was defined in an Objective-C class (or category or extension thereof) that has type parameters, substitute the type arguments for those type parameters. Similarly, substitute into property accesses, instance variables, and other references. This includes general infrastructure for substituting the type arguments associated with an ObjCObject(Pointer)Type into a type referenced within a particular context, handling all of the substitutions required to deal with (e.g.) inheritance involving parameterized classes. In cases where no type arguments are available (e.g., because we're messaging via some unspecialized type, id, etc.), we substitute in the type bounds for the type parameters instead. Example: @interface NSSet<T : id<NSCopying>> : NSObject <NSCopying> - (T)firstObject; @end void f(NSSet<NSString *> *stringSet, NSSet *anySet) { [stringSet firstObject]; // produces NSString* [anySet firstObject]; // produces id<NSCopying> (the bound) } When substituting for the type parameters given an unspecialized context (i.e., no specific type arguments were given), substituting the type bounds unconditionally produces type signatures that are too strong compared to the pre-generics signatures. Instead, use the following rule: - In covariant positions, such as method return types, replace type parameters with “id” or “Class” (the latter only when the type parameter bound is “Class” or qualified class, e.g, “Class<NSCopying>”) - In other positions (e.g., parameter types), replace type parameters with their type bounds. - When a specialized Objective-C object or object pointer type contains a type parameter in its type arguments (e.g., NSArray<T>*, but not NSArray<NSString *> *), replace the entire object/object pointer type with its unspecialized version (e.g., NSArray *). llvm-svn: 241543
* Handle Objective-C type arguments.Douglas Gregor2015-07-071-0/+27
| | | | | | | | | | | | | | | | | | | | | Objective-C type arguments can be provided in angle brackets following an Objective-C interface type. Syntactically, this is the same position as one would provide protocol qualifiers (e.g., id<NSCopying>), so parse both together and let Sema sort out the ambiguous cases. This applies both when parsing types and when parsing the superclass of an Objective-C class, which can now be a specialized type (e.g., NSMutableArray<T> inherits from NSArray<T>). Check Objective-C type arguments against the type parameters of the corresponding class. Verify the length of the type argument list and that each type argument satisfies the corresponding bound. Specializations of parameterized Objective-C classes are represented in the type system as distinct types. Both specialized types (e.g., NSArray<NSString *> *) and unspecialized types (NSArray *) are represented, separately. llvm-svn: 241542
* Parsing, semantic analysis, and AST for Objective-C type parameters.Douglas Gregor2015-07-071-4/+113
| | | | | | | | | | | | | | | | | | | | Produce type parameter declarations for Objective-C type parameters, and attach lists of type parameters to Objective-C classes, categories, forward declarations, and extensions as appropriate. Perform semantic analysis of type bounds for type parameters, both in isolation and across classes/categories/extensions to ensure consistency. Also handle (de-)serialization of Objective-C type parameter lists, along with sundry other things one must do to add a new declaration to Clang. Note that Objective-C type parameters are typedef name declarations, like typedefs and C++11 type aliases, in support of type erasure. Part of rdar://problem/6294649. llvm-svn: 241541
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Extend type nullability qualifiers for Objective-C.Douglas Gregor2015-06-191-3/+5
| | | | | | | | | | | | | | | Introduce context-sensitive, non-underscored nullability specifiers (nonnull, nullable, null_unspecified) for Objective-C method return types, method parameter types, and properties. Introduce Objective-C-specific semantics, including computation of the nullability of the result of a message send, merging of nullability information from the @interface of a class into its @implementation, etc . This is the Objective-C part of rdar://problem/18868820. llvm-svn: 240154
* [modules] Deserialize CXXCtorInitializer list for a constructor lazily.Richard Smith2015-03-241-0/+5
| | | | | | | | | | | | | Previously we'd deserialize the list of mem-initializers for a constructor when we deserialized the declaration of the constructor. That could trigger a significant amount of unnecessary work (pulling in all base classes recursively, for a start) and was causing problems for the modules buildbot due to cyclic deserializations. We now deserialize these on demand. This creates a certain amount of duplication with the handling of CXXBaseSpecifiers; I'll look into reducing that next. llvm-svn: 233052
* revert r231700 (designated initializer patch) which brokeFariborz Jahanian2015-03-111-10/+0
| | | | | | several projects. rdar://20120666. llvm-svn: 231939
* [PATCH Sema Objective-C]. Patch to warn on missing designated initializerFariborz Jahanian2015-03-091-0/+10
| | | | | | | override where at least a declaration of a designated initializer is in a super class and not necessarily in the current class. rdar://19653785. llvm-svn: 231700
* Fix ObjCInterfaceDecl::getCategoryMethod() and give it a caller. No behavior ↵Nico Weber2015-03-021-2/+1
| | | | | | change. llvm-svn: 230928
* Cleanup: remove artificial division between lookup results and const lookupRichard Smith2015-02-211-8/+8
| | | | | | | results. No-one was ever modifying a lookup result, and it would not be reasonable to do so. llvm-svn: 230123
* Prefer SmallVector::append/insert over push_back loops. Clang edition.Benjamin Kramer2015-02-171-3/+2
| | | | | | Same functionality, but hoists the vector growth out of the loop. llvm-svn: 229508
* ObjC getters with names like "newItem" should still be linked to the @property.Jordan Rose2015-01-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Two years ago I added a compile-time "optimization" to ObjCMethodDecl::findPropertyDecl: exit early if the current method is part of a special Objective-C method family (like 'new' or 'init'). However, if a property (declared with @property) has a name that matches a method family, the getter picks up that family despite being declared by the property. The early exit then made ObjCMethodDecl::findPropertyDecl decide that there was no associated property, despite the method itself being marked as an accessor. This corrects that by removing the early exit. This does /not/ change the fact that such a getter is considered to return a value with a +1 retain count. The best way to eliminate this is by adding the objc_method_family(none) attribute to the getter, but unlike the existing ns_returns_not_retained that can't be applied directly to the property -- you have to redeclare the getter instead. (It'd be nice if @property just implied objc_method_family(none) for its getter, but that would be a backwards-incompatible change.) rdar://problem/19038838 llvm-svn: 226338
* Wrap to 80 columns. NfC.Nico Weber2014-12-221-10/+11
| | | | llvm-svn: 224695
* Constify a few IdentifierInfo * parameters.Jordan Rose2014-11-191-3/+3
| | | | | | No functionality change. llvm-svn: 222392
* Objective-C. Change to method lookup rules to lookFariborz Jahanian2014-08-271-12/+15
| | | | | | | | | | into primary class's named categories before looking into their protocols. This is because categories are part of the public interface and , just as primary class, preference should be given to them before class (and category) protocols. // rdar://18013929 llvm-svn: 216610
* Objective-C. Warn if user has made explicit callFariborz Jahanian2014-08-221-0/+5
| | | | | | | to +initilize as this results in an extra call to this method. rdar://16628028 llvm-svn: 216271
* Improving diagnostic source ranges for the nonnull attribute. Now it ↵Aaron Ballman2014-08-011-0/+7
| | | | | | highlights the attribute and the faulty nonpointer type when possible. llvm-svn: 214507
* Objective-C. Changes per A. Ballman's commentFariborz Jahanian2014-07-161-10/+12
| | | | | | for my last patch. // rdar://17631257 llvm-svn: 213185
* Objective-C. Introducing __attribute__((objc_runtime_name("runtimename"))Fariborz Jahanian2014-07-161-0/+23
| | | | | | | | | to be applied to class or protocols. This will direct IRGen for Objective-C metadata to use the new name in various places where class and protocol names are needed. rdar:// 17631257 llvm-svn: 213167
* If a declaration is loaded, and then a module import adds a redeclaration, thenRichard Smith2014-05-161-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 209046
* [C++11] Use 'nullptr'. AST edition.Craig Topper2014-05-121-74/+83
| | | | llvm-svn: 208517
* Stop all the Decl classes poking at Redeclarable's data member directly, and ↵Richard Smith2014-05-101-1/+1
| | | | | | make getNextRedeclaration follow the pattern of its friends getPreviousDecl and getMostRecentDecl. llvm-svn: 208467
* [SemaObjC] Fix ObjCInterfaceDecl::inheritsDesignatedInitializers(), if there ↵Argyrios Kyrtzidis2014-04-261-3/+13
| | | | | | | | | | are no designated initializers in the super class hierarchy then it should return false. rdar://16692535 llvm-svn: 207332
* Fix indentation, NFC.Argyrios Kyrtzidis2014-04-161-4/+4
| | | | llvm-svn: 206411
* [objc] Consider new initializers inside @implementation when determining if ↵Argyrios Kyrtzidis2014-04-161-0/+6
| | | | | | | | | | the class introduces new initializers. Part of rdar://16568441 llvm-svn: 206409
* [SemaObjC] For the semantics of the designated-initializer attribute, ↵Argyrios Kyrtzidis2014-03-281-9/+30
| | | | | | | | | | consider that the ObjC interface of the class includes its class extensions. This is follow-up for rdar://16305347 llvm-svn: 205065
* [C++11] Replacing ObjCImplementationDecl iterators ivar_begin() and ↵Aaron Ballman2014-03-141-6/+4
| | | | | | ivar_end() with iterator_range ivars(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203932
* [C++11] Replacing ObjCCategoryDecl iterators propimpl_begin() and ↵Aaron Ballman2014-03-141-6/+2
| | | | | | propimpl_end() with iterator_range property_impls(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203930
* [C++11] Replacing ObjCCategoryDecl iterators protocol_begin() and ↵Aaron Ballman2014-03-141-13/+7
| | | | | | protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203922
* [C++11] Replacing ObjCProtocolDecl iterators protocol_begin() and ↵Aaron Ballman2014-03-131-21/+14
| | | | | | protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203863
* [C++11] Replacing ObjCInterfaceDecl iterators known_extensions_begin() and ↵Aaron Ballman2014-03-131-4/+1
| | | | | | known_extensions_end() with iterator_range known_extensions(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203857
* [C++11] Replacing ObjCInterfaceDecl iterators visible_extensions_begin() and ↵Aaron Ballman2014-03-131-4/+1
| | | | | | visible_extensions_end() with iterator_range visible_extensions(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203855
* [C++11] Replacing ObjCInterfaceDecl iterators known_categories_begin() and ↵Aaron Ballman2014-03-131-7/+2
| | | | | | known_categories_end() with iterator_range known_categories(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203854
* [C++11] Replacing ObjCInterfaceDecl iterators visible_categories_begin() and ↵Aaron Ballman2014-03-131-33/+10
| | | | | | visible_categories_end() with iterator_range visible_categories(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203851
OpenPOWER on IntegriCloud