summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprObjC.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Implement bracket insertion for Objective-C instance message sends asDouglas Gregor2010-09-151-19/+30
| | | | | | | | | | | | | | | | | | | | | | | part of parser recovery. For example, given: a method1:arg]; we detect after parsing the expression "a" that we have the start of a message send expression. We pretend we've seen a '[' prior to the a, then parse the remainder as a message send. We'll then give a diagnostic+fix-it such as: fixit-objc-message.m:17:3: error: missing '[' at start of message send expression a method1:arg]; ^ [ The algorithm here is very simple, and always assumes that the open bracket goes at the beginning of the message send. It also only works for non-super instance message sends at this time. llvm-svn: 113968
* One who seeks knowledge learns something new every day.John McCall2010-08-261-18/+18
| | | | | | | | | One who seeks the Tao unlearns something new every day. Less and less remains until you arrive at non-action. When you arrive at non-action, nothing will be left undone. llvm-svn: 112244
* Split out a header to hold APIs meant for the Sema implementation from Sema.h.John McCall2010-08-251-1/+1
| | | | | | | Clients of Sema don't need to know (for example) the list of diagnostics we support. llvm-svn: 112093
* GCC didn't care for my attempt at API compatibility, so brute-force everythingJohn McCall2010-08-251-2/+2
| | | | | | to the new constants. llvm-svn: 112047
* More header elimination. The goal of all this is to allow Parser toJohn McCall2010-08-241-0/+1
| | | | | | | #include Sema.h while keeping all the AST declarations opaque. That may not be reasonably attainable, though. llvm-svn: 111907
* OwningExprResult -> ExprResult. This patch brought to you byJohn McCall2010-08-241-14/+14
| | | | | | | M-x query-replace-regexp \(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result llvm-svn: 111903
* Abstract out passing around types and kill off ActionBase.John McCall2010-08-241-6/+6
| | | | llvm-svn: 111901
* Kill off ExprArg (now just Expr*) and StmtArg (now just Stmt*).John McCall2010-08-231-7/+5
| | | | llvm-svn: 111863
* Convert all uses of StringLiteral::getStrData() to StringLiteral::getString()Benjamin Kramer2010-08-171-2/+2
| | | | | | and remove getStrData(). Patch by Peter Davies (with some tweaks). llvm-svn: 111229
* Move Sema's headers into include/clang/Sema, renaming a few along the way.Douglas Gregor2010-08-121-3/+3
| | | | llvm-svn: 110945
* Fix a spurious warning when message sent to qualified-idFariborz Jahanian2010-08-101-2/+1
| | | | | | type receiver (pr7861). llvm-svn: 110696
* Implements gcc's -Wstrict-selector-match.Fariborz Jahanian2010-08-091-7/+13
| | | | | | (radar 8127244). llvm-svn: 110622
* Simplify global method pool implementation in Sema. No functionality change.Sebastian Redl2010-08-021-1/+1
| | | | llvm-svn: 110078
* Remove the vast majority of the Destroy methods from the AST library,Douglas Gregor2010-07-251-7/+1
| | | | | | since we aren't going to be calling them ever. llvm-svn: 109377
* Vectors are not integer types, so the type system should not classifyDouglas Gregor2010-07-231-3/+2
| | | | | | | | | | | them as such. Type::is(Signed|Unsigned|)IntegerType() now return false for vector types, and new functions has(Signed|Unsigned|)IntegerRepresentation() cover integer types and vector-of-integer types. This fixes a bunch of latent bugs. Patch from Anton Yartsev! llvm-svn: 109229
* atch for implementation of objective-c's -WselectorFariborz Jahanian2010-07-221-0/+5
| | | | | | | warning flag in clang. Little more to do for a PCH issue. Radar 6507158. llvm-svn: 109129
* When forming a function call or message send expression, be sure toDouglas Gregor2010-07-131-4/+4
| | | | | | | | | | | | | | | | | strip cv-qualifiers from the expression's type when the language calls for it: in C, that's all the time, while C++ only does it for non-class types. Centralized the computation of the call expression type in QualType::getCallResultType() and some helper functions in other nodes (FunctionDecl, ObjCMethodDecl, FunctionType), and updated all relevant callers of getResultType() to getCallResultType(). Fixes PR7598 and PR7463, along with a bunch of getResultType() call sites that weren't stripping references off the result type (nothing stripped cv-qualifiers properly before this change). llvm-svn: 108234
* C return types must be complete as well.Fariborz Jahanian2010-06-161-5/+6
| | | | | | | Moved check before we build the ObjCMessageExpr node. (PR7386 related). llvm-svn: 106139
* Make sure result type of objc++ message expression isFariborz Jahanian2010-06-161-0/+5
| | | | | | | complete before attempting to bind it to a temporary. Fixes PR7386. llvm-svn: 106130
* Improve our handling of reference binding for subobjects ofDouglas Gregor2010-05-221-15/+19
| | | | | | | | | | | | | | | | | | | | | | | | | temporaries. There are actually several interrelated fixes here: - When converting an object to a base class, it's only an lvalue cast when the original object was an lvalue and we aren't casting pointer-to-derived to pointer-to-base. Previously, we were misclassifying derived-to-base casts of class rvalues as lvalues, causing various oddities (including problems with reference binding not extending the lifetimes of some temporaries). - Teach the code for emitting a reference binding how to look through no-op casts and parentheses directly, since Expr::IgnoreParenNoOpCasts is just plain wrong for this. Also, make sure that we properly look through multiple levels of indirection from the temporary object, but destroy the actual temporary object; this fixes the reference-binding issue mentioned above. - Teach Objective-C message sends to bind the result as a temporary when needed. This is actually John's change, but it triggered the reference-binding problem above, so it's included here. Now John can actually test his return-slot improvements. llvm-svn: 104434
* Renamed misleading getSourceRange -> getLocalSourceRange and ↵Abramo Bagnara2010-05-201-1/+1
| | | | | | getFullSourceRange -> getSourceRange for TypeLoc. llvm-svn: 104220
* fix rdar://7985267 - Don't emit an error about a non-pod argumentChris Lattner2010-05-161-1/+1
| | | | | | passed to va_start, it doesn't actually pass it. llvm-svn: 103899
* Substantially alter the design of the Objective C type AST by introducingJohn McCall2010-05-151-4/+2
| | | | | | | | | | | | | | | | | | | | | ObjCObjectType, which is basically just a pair of one of {primitive-id, primitive-Class, user-defined @class} with a list of protocols. An ObjCObjectPointerType is therefore just a pointer which always points to one of these types (possibly sugared). ObjCInterfaceType is now just a kind of ObjCObjectType which happens to not carry any protocols. Alter a rather large number of use sites to use ObjCObjectType instead of ObjCInterfaceType. Store an ObjCInterfaceType as a pointer on the decl rather than hashing them in a FoldingSet. Remove some number of methods that are no longer used, at least after this patch. By simplifying ObjCObjectPointerType, we are now able to easily remove and apply pointers to Objective-C types, which is crucial for a certain kind of ObjC++ metaprogramming common in WebKit. llvm-svn: 103870
* Objective-C++ Sema. Fix a bug in instantiation of receivers.Fariborz Jahanian2010-05-131-1/+6
| | | | | | Completes radar 7963410. llvm-svn: 103719
* Objective-C++ Sema. Support for conversion of a C++Fariborz Jahanian2010-05-121-0/+10
| | | | | | | class object used as a receiver to an objective-c pointer via a converwsion function. wip. llvm-svn: 103672
* With -fno-constant-cfstrrings, class NSConstantStringFariborz Jahanian2010-04-231-0/+15
| | | | | | must be there or it is error (Next runtime). llvm-svn: 102223
* 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
OpenPOWER on IntegriCloud