summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprObjC.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* When a dependent Objective-C++ message send was able to resolve theDouglas Gregor2010-04-221-130/+142
| | | | | | | | method being called at template definition time, retain that method and pass it through to type-checking. We will not perform any lookup for the method during template instantiation. llvm-svn: 102081
* Remove the SelectorLoc argument to Sema::BuildInstanceMesssage andDouglas Gregor2010-04-221-13/+4
| | | | | | | Sema::BuildClassMessage; we weren't using it, and template instantiation was faking it anyway. llvm-svn: 102074
* Implement template instantiation for Objective-C++ message sends. WeDouglas Gregor2010-04-221-4/+37
| | | | | | | | | | | | support dependent receivers for class and instance messages, along with dependent message arguments (of course), and check as much as we can at template definition time. This commit also deals with a subtle aspect of template instantiation in Objective-C++, where the type 'T *' can morph from a dependent PointerType into a non-dependent ObjCObjectPointer type. llvm-svn: 102071
* Switch the initialization of Objective-C message parameters (as occursDouglas Gregor2010-04-211-21/+15
| | | | | | | | | during message sends) over to the new initialization code and away from the C-only CheckSingleAssignmentConstraints. The enables the use of C++ types in method parameters and message arguments, as well as unifying more initialiation code overall. llvm-svn: 102035
* Migrate the responsibility for turning the receiver name in anDouglas Gregor2010-04-211-9/+22
| | | | | | | | | Objective-C class message expression into a type from the parser (which was doing so in two places) to Action::getObjCMessageKind() which, in the case of Sema, reduces the number of name lookups we need to perform. llvm-svn: 102026
* Eliminate unused code in Sema::ActOnSuperMessage and use early exitsDouglas Gregor2010-04-211-68/+28
| | | | | | to reduce nesting. No functionality change. llvm-svn: 102022
* Rework the Parser-Sema interaction for Objective-C messageDouglas Gregor2010-04-211-165/+312
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sends. Major changes include: - Expanded the interface from two actions (ActOnInstanceMessage, ActOnClassMessage), where ActOnClassMessage also handled sends to "super" by checking whether the identifier was "super", to three actions (ActOnInstanceMessage, ActOnClassMessage, ActOnSuperMessage). Code completion has the same changes. - The parser now resolves the type to which we are sending a class message, so ActOnClassMessage now accepts a TypeTy* (rather than an IdentifierInfo *). This opens the door to more interesting types (for Objective-C++ support). - Split ActOnInstanceMessage and ActOnClassMessage into parser action functions (with their original names) and semantic functions (BuildInstanceMessage and BuildClassMessage, respectively). At present, this split is onyl used by ActOnSuperMessage, which decides which kind of super message it has and forwards to the appropriate Build*Message. In the future, Build*Message will be used by template instantiation. - Use getObjCMessageKind() within the disambiguation of Objective-C message sends vs. array designators. Two notes about substandard bits in this patch: - There is some redundancy in the code in ParseObjCMessageExpr and ParseInitializerWithPotentialDesignator; this will be addressed shortly by centralizing the mapping from identifiers to type names for the message receiver. - There is some #if 0'd code that won't likely ever be used---it handles the use of 'super' in methods whose class does not have a superclass---but could be used to model GCC's behavior more closely. This code will die in my next check-in, but I want it in Subversion. llvm-svn: 102021
* Overhaul the AST representation of Objective-C message sendDouglas Gregor2010-04-211-100/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | expressions, to improve source-location information, clarify the actual receiver of the message, and pave the way for proper C++ support. The ObjCMessageExpr node represents four different kinds of message sends in a single AST node: 1) Send to a object instance described by an expression (e.g., [x method:5]) 2) Send to a class described by the class name (e.g., [NSString method:5]) 3) Send to a superclass class (e.g, [super method:5] in class method) 4) Send to a superclass instance (e.g., [super method:5] in instance method) Previously these four cases where tangled together. Now, they have more distinct representations. Specific changes: 1) Unchanged; the object instance is represented by an Expr*. 2) Previously stored the ObjCInterfaceDecl* referring to the class receiving the message. Now stores a TypeSourceInfo* so that we know how the class was spelled. This both maintains typedef information and opens the door for more complicated C++ types (e.g., dependent types). There was an alternative, unused representation of these sends by naming the class via an IdentifierInfo *. In practice, we either had an ObjCInterfaceDecl *, from which we would get the IdentifierInfo *, or we fell into the case below... 3) Previously represented by a class message whose IdentifierInfo * referred to "super". Sema and CodeGen would use isStr("super") to determine if they had a send to super. Now represented as a "class super" send, where we have both the location of the "super" keyword and the ObjCInterfaceDecl* of the superclass we're targetting (statically). 4) Previously represented by an instance message whose receiver is a an ObjCSuperExpr, which Sema and CodeGen would check for via isa<ObjCSuperExpr>(). Now represented as an "instance super" send, where we have both the location of the "super" keyword and the ObjCInterfaceDecl* of the superclass we're targetting (statically). Note that ObjCSuperExpr only has one remaining use in the AST, which is for "super.prop" references. The new representation of ObjCMessageExpr is 2 pointers smaller than the old one, since it combines more storage. It also eliminates a leak when we loaded message-send expressions from a precompiled header. The representation also feels much cleaner to me; comments welcome! This patch attempts to maintain the same semantics we previously had with Objective-C message sends. In several places, there are massive changes that boil down to simply replacing a nested-if structure such as: if (message has a receiver expression) { // instance message if (isa<ObjCSuperExpr>(...)) { // send to super } else { // send to an object } } else { // class message if (name->isStr("super")) { // class send to super } else { // send to class } } with a switch switch (E->getReceiverKind()) { case ObjCMessageExpr::SuperInstance: ... case ObjCMessageExpr::Instance: ... case ObjCMessageExpr::SuperClass: ... case ObjCMessageExpr::Class:... } There are quite a few places (particularly in the checkers) where send-to-super is effectively ignored. I've placed FIXMEs in most of them, and attempted to address send-to-super in a reasonable way. This could use some review. llvm-svn: 101972
* Patch to support transparent_union types onFariborz Jahanian2010-04-201-0/+5
| | | | | | objective-c methods. Fixes radar 7875968. llvm-svn: 101935
* Keep proper source location information for the type in an Objective-CDouglas Gregor2010-04-201-4/+9
| | | | | | @encode expression. llvm-svn: 101907
* When normal name lookup to disambiguiate an Objective-C message sendDouglas Gregor2010-04-191-0/+10
| | | | | | | fails to find anything, perform ivar lookup and, if we find one, consider this an instance message. llvm-svn: 101810
* Expand the argument diagnostics for too many arguments and giveEric Christopher2010-04-161-1/+2
| | | | | | | | both number seen and number expected. Finishes fixing PR6501. llvm-svn: 101442
* Expand argument diagnostic for too few arguments to give the numberEric Christopher2010-04-161-1/+2
| | | | | | | | of arguments both seen and expected. Fixes PR6501. llvm-svn: 101441
* Feed proper source-location information into Sema::LookupSingleResult,Douglas Gregor2010-04-151-5/+8
| | | | | | | | in case it ends up doing something that might trigger diagnostics (template instantiation, ambiguity reporting, access reporting). Noticed while working on PR6831. llvm-svn: 101412
* Teach typo correction about various language keywords. We can'tDouglas Gregor2010-04-141-12/+31
| | | | | | | | | | | | | generally recover from typos in keywords (since we would effectively have to mangle the token stream). However, there are still benefits to typo-correcting with keywords: - We don't make stupid suggestions when the user typed something that is similar to a keyword. - We can suggest the keyword in a diagnostic (did you mean "static_cast"?), even if we can't recover and therefore don't have a fix-it. llvm-svn: 101274
* remove some obsolete super-handling code that I forgot to zap.Chris Lattner2010-04-141-30/+0
| | | | llvm-svn: 101212
* Implement typo correction for Objective-C message sends when theDouglas Gregor2010-04-141-0/+55
| | | | | | | | | | | | | | | | | | | | | receiver is a mis-typed class name. Previously, we would give a non-specific typo-correction diagnostic from the expression-parsing code, but there was no fix-it because it was too late to recover. Now, we give a nice diagnostic honk.m:6:4: error: unknown receiver 'Hnk'; did you mean 'Honk'? [Hnk method]; ^~~ Honk honk.m:1:1: note: 'Honk' declared here @interface Honk ^ which includes a fix-it. We still need to recover better from mis-typing "super". llvm-svn: 101211
* fix PR6819Chris Lattner2010-04-121-0/+10
| | | | llvm-svn: 101050
* Have the parser decide whether a message to super is a variable orChris Lattner2010-04-121-36/+12
| | | | | | type, instead of having sema do it. llvm-svn: 101016
* fix PR6811 by not parsing 'super' as a magic expression inChris Lattner2010-04-111-31/+53
| | | | | | | | | | | | | LookupInObjCMethod. Doing so allows all sorts of invalid code to slip through to codegen. This patch does not change the AST representation of super, though that would now be a natural thing to do since it can only be in the receiver position and in the base of a ObjCPropertyRefExpr. There are still several ugly areas handling super in the parser, but this is definitely a step in the right direction. llvm-svn: 100959
* actually the interface grossness in the previous patch was due toChris Lattner2010-04-111-11/+7
| | | | | | | | typo correction. However, now that the code has been factored out of LookupMemberExpr, it can recurse to itself instead of to LookupMemberExpr! Remove grossness. llvm-svn: 100958
* factor the code that handles "expr.field" when expr is aChris Lattner2010-04-111-0/+109
| | | | | | | | pointer to an objc interface out to a method in SemaExprObjC. This is *much* uglier than it should be due to grossness in LookupMemberExpr :( llvm-svn: 100957
* fix a problem causing us to lose the ''s around objc interface namesChris Lattner2010-04-111-1/+1
| | | | | | in a diagnostic. llvm-svn: 100956
* Patch to implement gcc's cstyle arguments in objcFariborz Jahanian2010-04-081-1/+9
| | | | | | methods. wip. llvm-svn: 100734
* Diagnose miuse of property dot-syntax instead of crashing.Fariborz Jahanian2010-03-221-1/+4
| | | | | | (radar 7634653). llvm-svn: 99210
* Add support for -Wwrite-strings. Patch by Mike M! Fixes PR 4804.John McCall2010-03-151-1/+1
| | | | llvm-svn: 98541
* Extend ObjCMessageExpr for class method sends with the source locationDouglas Gregor2010-03-081-6/+6
| | | | | | of the class name. llvm-svn: 97943
* Make Sema::ActOnClassMessage robust when name lookup for the receiverDouglas Gregor2010-02-191-8/+8
| | | | | | | name finds something other than a TypedefDecl or an ObjCInterfaceDecl. This is a small part of <rdar://problem/7660386>. llvm-svn: 96676
* Allocate the SubExprs array in ObjCMessageExpr using the allocator ↵Ted Kremenek2010-02-111-12/+17
| | | | | | associated with ASTContext. This fixes yet another leak (<rdar://problem/7639260>). llvm-svn: 95930
* Revert "Numerous changes to selector handling:", this breaks a whole bunch ofDaniel Dunbar2010-02-031-14/+1
| | | | | | working code, for no apparent reason. llvm-svn: 95244
* Numerous changes to selector handling:David Chisnall2010-02-031-1/+14
| | | | | | | | | | | | | | | | | | | | | | | - Don't use GlobalAliases with non-0 GEPs (GNU runtime) - this was unsupported and LLVM will be generating errors if you do it soon. This also simplifies the code generated by the GNU runtime a bit. - Make GetSelector() return a constant (GNU runtime), not a load of a store of a constant. - Recognise @selector() expressions as valid static initialisers (as GCC does). - Add methods to GCObjCRuntime to emit selectors as constants (needed for using @selector() expressions as constants. These need implementing for the Mac runtimes - I couldn't figure out how to do this, they seem to require a load. - Store an ObjCMethodDecl in an ObjCSelectorExpr so that we can get at the type information for the selector. This is needed for generating typed selectors from @selector() expressions (as GCC does). Ideally, this information should be stored in the Selector, but that would be an invasive change. We should eventually add checks for common uses of @selector() expressions. Possibly adding an attribute that can be applied to method args providing the types of a selector so, for example, you'd do something like this: - (id)performSelector: __attribute__((selector_types(id, SEL, id)))(SEL) withObject: (id)object; Then, any @selector() expressions passed to the method will be check to ensure that it conforms to this signature. We do this at run time on the GNU runtime already, but it would be nice to do it at compile time on all runtimes. - Made @selector() expressions emit type info if available and the runtime supports it. Someone more familiar with the Mac runtime needs to implement the GetConstantSelector() function in CGObjCMac. This currently just assert()s. llvm-svn: 95189
* Implement the lvalue-to-rvalue conversion where needed. TheDouglas Gregor2010-02-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lvalue-to-rvalue conversion adjusts lvalues of qualified, non-class type to rvalue expressions of the unqualified variant of that type. For example, given: const int i; (void)(i + 17); the lvalue-to-rvalue conversion for the subexpression "i" will turn it from an lvalue expression (a DeclRefExpr) with type 'const int' into an rvalue expression with type 'int'. Both C and C++ mandate this conversion, and somehow we've slid through without implementing it. We now have both DefaultFunctionArrayConversion and DefaultFunctionArrayLvalueConversion, and which gets used depends on whether we do the lvalue-to-rvalue conversion or not. Generally, we do the lvalue-to-rvalue conversion, but there are a few notable exceptions: - the left-hand side of a '.' operator - the left-hand side of an assignment - a C++ throw expression - a subscript expression that's subscripting a vector Making this change exposed two issues with blocks: - we were deducing const-qualified return types of non-class type from a block return, which doesn't fit well - we weren't always setting the known return type of a block when it was provided with the ^return-type syntax Fixes the current Clang-on-Clang compile failure and PR6076. llvm-svn: 95167
* outside a method, 'super' should resolve in a normal name look upFariborz Jahanian2010-01-221-1/+11
| | | | | | to mimic gcc's behavior. Fixes radar 7400691. llvm-svn: 94246
* Implement typo correction for a variety of Objective-C-specificDouglas Gregor2010-01-031-2/+3
| | | | | | | | | | | | | | constructs: - Instance variable lookup ("foo->ivar" and, in instance methods, "ivar") - Property name lookup ("foo.prop") - Superclasses - Various places where a class name is required - Protocol names (e.g., id<proto>) This seems to cover many of the common places where typos could occur. llvm-svn: 92449
* Fix semantic diagnostics that embed English works, from Nicola Gigante!Douglas Gregor2009-12-161-1/+1
| | | | llvm-svn: 91503
* Remove default argument for ImpCastExprToType. Add appropriate argument Eli Friedman2009-10-201-1/+5
| | | | | | | | | | | | | to all callers. Switch a few other users of CK_Unknown to proper cast kinds. Note that there are still some situations where we end up with CK_Unknown; they're pretty easy to find with grep. There are still a few missing conversion kinds, specifically pointer/int/float->bool and the various combinations of real/complex float/int->real/complex float/int. llvm-svn: 84623
* Refactor the LookupResult API to simplify most common operations. Require ↵John McCall2009-10-091-3/+5
| | | | | | | | | users to pass a LookupResult reference to lookup routines. Call out uses which assume a single result. llvm-svn: 83674
* Change all the Type::getAsFoo() methods to specializations of Type::getAs().John McCall2009-09-211-1/+1
| | | | | | | | | | | Several of the existing methods were identical to their respective specializations, and so have been removed entirely. Several more 'leaf' optimizations were introduced. The getAsFoo() methods which imposed extra conditions, like getAsObjCInterfacePointerType(), have been left in place. llvm-svn: 82501
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-81/+80
| | | | llvm-svn: 81346
* Don't issue warning on multiple selector found when Fariborz Jahanian2009-08-221-1/+1
| | | | | | selector name is for a @selector expression. llvm-svn: 79776
* Using "ObjCImplicitSetterGetterRefExpr" instead of ↵Fariborz Jahanian2009-08-201-1/+1
| | | | | | | | "ObjCImplctSetterGetterRefExpr". A field rename and more comments. llvm-svn: 79537
* Use Sema's LocInfoType to pass and preserve type source info through the Parser.Argyrios Kyrtzidis2009-08-191-1/+2
| | | | llvm-svn: 79395
* Renamed ObjCKVCRefExpr to ObjCImplctSetterGetterRefExpr.Fariborz Jahanian2009-08-181-1/+2
| | | | | | | | Removed an unnecessary loop to get to setters incoming argument. Added DoxyGen comments. Still more work to do in this area (WIP). llvm-svn: 79365
* Remove a bunch of FIXME's related to ObjC type checking.Steve Naroff2009-07-231-193/+0
| | | | | | | | - Move Sema::ObjCQualifiedIdTypesAreCompatible(), Sema::QualifiedIdConformsQualifiedId(), and a couple helper functions to ASTContext. - Change ASTContext::canAssignObjCInterfaces() to use ASTContext:: ObjCQualifiedIdTypesAreCompatible(). - Tweak several test cases to accommodate the new/improved type checking. llvm-svn: 76830
* Fix <rdar://problem/6770276> Support Class<Proto> syntax.Steve Naroff2009-07-221-3/+6
| | | | llvm-svn: 76741
* Remove the ObjCCategoryImpls vector from Sema class.Argyrios Kyrtzidis2009-07-211-18/+6
| | | | | | Use ObjCInterfaceDecl::getCategoryClassMethod() and ObjCInterfaceDecl::getCategoryInstanceMethod() for the same functionality. llvm-svn: 76510
* Remove Sema::LookupObjCImplementation and replace it with just calling ↵Argyrios Kyrtzidis2009-07-211-8/+4
| | | | | | ObjCInterfaceDecl::getImplementation(). llvm-svn: 76509
* 5 cleanups to ObjCObjectPointerType work:Steve Naroff2009-07-201-28/+0
| | | | | | | | | | - Remove Sema::CheckPointeeTypesForAssignment(), a temporary API I added to ease migration to ObjCObjectPointerType. Convert Sema::CheckAssignmentConstraints() to no longer depend on the temporary API. - Sema::ConvertDeclSpecToType(): Replace a couple FIXME's with an important comment/example. - Sema::GetTypeForDeclarator(): Get the protocol's from the interface, NOT the declspec (to support the following C typedef idiom: "typedef C<P> T; T *obj"). - Sema::ObjCQualifiedIdTypesAreCompatible(): Removed some dead code. - ASTContext::getObjCEncodingForTypeImpl(): Some minor cleanups. llvm-svn: 76443
* Remove ObjCQualifiedInterfaceType:-)Steve Naroff2009-07-181-1/+1
| | | | llvm-svn: 76321
* Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methodsTed Kremenek2009-07-171-1/+1
| | | | | | | | | until Doug Gregor's Type smart pointer code lands (or more discussion occurs). These methods just call the new Type::getAs<XXX> methods, so we still have reduced implementation redundancy. Having explicit getAsXXXType() methods makes it easier to set breakpoints in the debugger. llvm-svn: 76193
OpenPOWER on IntegriCloud