summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprObjC.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Rewrite variable capture within lambda expressions and blocks,Douglas Gregor2012-02-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | eliminating a bunch of redundant code and properly modeling how the captures of outside blocks/lambdas affect the types seen by inner captures. This new scheme makes two passes over the capturing scope stack. The first pass goes up the stack (from innermost to outermost), assessing whether the capture looks feasible and stopping when it either hits the scope where the variable is declared or when it finds an existing capture. The second pass then walks down the stack (from outermost to innermost), capturing the variable at each step and updating the captured type and the type that an expression referring to that captured variable would see. It also checks type-specific restrictions, such as the inability to capture an array within a block. Note that only the first odr-use of each variable needs to do the full walk; subsequent uses will find the capture immediately, so multiple walks need not occur. The same routine that builds the captures can also compute the type of the captures without signaling errors and without actually performing the capture. This functionality is used to determine the type of declaration references as well as implementing the weird decltype((x)) rule within lambda expressions. The capture code now explicitly takes sides in the debate over C++ core issue 1249, which concerns the type of captures within nested lambdas. We opt to use the more permissive, more useful definition implemented by GCC rather than the one implemented by EDG. llvm-svn: 150875
* Add fixits for ARC casting errors for implicit conversions as well. ↵Argyrios Kyrtzidis2012-02-161-16/+86
| | | | | | | | | | rdar://10289283 Also fix the fixit (oh the irony) when it uses CFBridgingRetain/CFBridgingRelease; they are supposed to be calls with the casted expression as parameter, they should not be inserted into the cast like the __bridge keywords. llvm-svn: 150705
* Revert r145999. This turned out to be a bad idea. Unfortunately, 'id' is ↵Ted Kremenek2012-02-101-3/+0
| | | | | | | | | used so profusely in many APIs and large codebases that this made the deprecated warning trigger happy to the point of not being useful. llvm-svn: 150223
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Implement implicit capture for lambda expressions.Eli Friedman2012-02-031-26/+5
| | | | | | Still left: explicit captures in lambdas need to cause implicit capture, and I need to take a look at the diagnostics for some cases. llvm-svn: 149718
* objc: Issue diagnostic when receiver type is a forward class declaration andFariborz Jahanian2012-02-031-1/+5
| | | | | | | it is treated as of 'id' type resulting in multiple method lookup. // rdar://10686120 llvm-svn: 149653
* Look for declaration of CFBridgingRetain/CFBridgingRetain beforeFariborz Jahanian2012-02-011-11/+28
| | | | | | changing the diagnostic. Also use correct spelling for both. llvm-svn: 149554
* Improve checking of explicit captures in a C++11 lambda expression:Douglas Gregor2012-02-011-1/+2
| | | | | | | | | | | | | | - Actually building the var -> capture mapping properly (there was an off-by-one error) - Keeping track of the source location of each capture - Minor QoI improvements, e.g, highlighing the prior capture if there are multiple captures, pointing at the variable declaration we found if we reject it. As part of this, add standard citations for the various semantic checks we perform, and note where we're not performing those checks as we should. llvm-svn: 149462
* Make the callback object to Sema::CorrectTypo mandatory.Kaelyn Uhrain2012-01-311-2/+2
| | | | llvm-svn: 149451
* objc-arc: In various diagnostics mention Fariborz Jahanian2012-01-311-4/+4
| | | | | | | | CFBridgingRetain/CFBridgingRelease calls instead of __bridge_retained/__bridge_transfer casts as preferred way of moving cf objects to arc land. // rdar://10207950 llvm-svn: 149449
* Fix a couples of issues in format strings checking.Jean-Daniel Dupas2012-01-171-6/+4
| | | | | | | PR 10274: format function attribute with the NSString archetype yields no compiler warnings PR 10275: format function attribute isn't checked in Objective-C methods llvm-svn: 148324
* Fix up the calls to CorrectTypo in Sema*ObjC.cpp to use callbackKaelyn Uhrain2012-01-131-31/+43
| | | | | | | objects, and add a basic CorrectionCandidateCallback template class to simplify the fixups. llvm-svn: 148085
* Add IsImplicit field in ObjCMessageExpr that is true when the messageArgyrios Kyrtzidis2012-01-121-8/+43
| | | | | | | | | | was constructed, e.g. for a property access. This allows the selector identifier locations machinery for ObjCMessageExpr to function correctly, in that there are not real locations to handle/report for such a message. llvm-svn: 148013
* Start refactoring code for capturing variables and 'this' so that it is ↵Eli Friedman2012-01-111-2/+1
| | | | | | shared between lambda expressions and block literals. llvm-svn: 147917
* Move the definition-specific data of ObjCInterfaceDecl into aDouglas Gregor2011-12-151-5/+6
| | | | | | | | | | | | | | | | separately-allocated DefinitionData structure, which we manage the same way as CXXRecordDecl::DefinitionData. This prepares the way for making ObjCInterfaceDecls redeclarable, to more accurately model forward declarations of Objective-C classes and eliminate the mutation of ObjCInterfaceDecl that causes us serious trouble in the AST reader. Note that ObjCInterfaceDecl's accessors are fairly robust against being applied to forward declarations, because Clang (and Sema in particular) doesn't perform RequireCompleteType/hasDefinition() checks everywhere it has to. Each of these overly-robust cases is marked with a FIXME, which we can tackle over time. llvm-svn: 146644
* objc: issue deprecated/unavailable diagnostic whenFariborz Jahanian2011-12-071-0/+3
| | | | | | | methods with these attributes are sent to receivers of 'id' type too. // rdar://10459930 llvm-svn: 145999
* When sending a message to a receiver that has "unknown any" type,Douglas Gregor2011-12-011-3/+7
| | | | | | | force the unknown any type to "id" so that the message send can be completed without requiring a case. Fixes <rdar://problem/10506646>. llvm-svn: 145552
* Use Sema::RequireCompleteType to check for the completeness ofDouglas Gregor2011-11-141-30/+32
| | | | | | | | | | Objective-C classes. This has two purposes: to consistently provide "forward declaration here" notes when we hit an incomplete type, and to give LLDB a chance to complete the type. RequireCompleteType bits from Sean Callanan! llvm-svn: 144573
* Don't crash on invalid objc code.Argyrios Kyrtzidis2011-11-091-0/+5
| | | | llvm-svn: 144150
* Rip out CK_GetObjCProperty.John McCall2011-11-071-1/+0
| | | | llvm-svn: 143910
* Change the AST representation of operations on Objective-CJohn McCall2011-11-061-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | property references to use a new PseudoObjectExpr expression which pairs a syntactic form of the expression with a set of semantic expressions implementing it. This should significantly reduce the complexity required elsewhere in the compiler to deal with these kinds of expressions (e.g. IR generation's special l-value kind, the static analyzer's Message abstraction), at the lower cost of specifically dealing with the odd AST structure of these expressions. It should also greatly simplify efforts to implement similar language features in the future, most notably Managed C++'s properties and indexed properties. Most of the effort here is in dealing with the various clients of the AST. I've gone ahead and simplified the ObjC rewriter's use of properties; other clients, like IR-gen and the static analyzer, have all the old complexity *and* all the new complexity, at least temporarily. Many thanks to Ted for writing and advising on the necessary changes to the static analyzer. I've xfailed a small diagnostics regression in the static analyzer at Ted's request. llvm-svn: 143867
* objc-arc: desugar certain type and improve on diagnostic forFariborz Jahanian2011-10-291-10/+20
| | | | | | | ownership qualifier cast which won't work. // rdar://10244607 llvm-svn: 143258
* objective-c arc: type-casting of an objc pointer toFariborz Jahanian2011-10-281-1/+18
| | | | | | | an rvalue retainable object type with life-time qualifier has no effect and wil be diagnosed as error. // rdar://10244607 llvm-svn: 143219
* Restore r142914 and r142915, now with missing file and apparentJohn McCall2011-10-251-53/+43
| | | | | | GCC compiler workaround. llvm-svn: 142931
* Revert r142914 and r142915, due to possibly missing file.NAKAMURA Takumi2011-10-251-43/+53
| | | | | | r142914: "Introduce a placeholder type for "pseudo object"" r142915: "Pull the pseudo-object stuff into its own file." llvm-svn: 142921
* Introduce a placeholder type for "pseudo object"John McCall2011-10-251-53/+43
| | | | | | | | | | | | | | | expressions: expressions which refer to a logical rather than a physical l-value, where the logical object is actually accessed via custom getter/setter code. A subsequent patch will generalize the AST for these so that arbitrary "implementing" sub-expressions can be provided. Right now the only client is ObjC properties, but this should be generalizable to similar language features, e.g. Managed C++'s __property methods. llvm-svn: 142914
* Strip qualifiers off the type of an implicit property defined byJohn McCall2011-10-171-1/+1
| | | | | | only a setter. llvm-svn: 142236
* Teach the ARC compiler to not require __bridge casts whenJohn McCall2011-10-171-74/+189
| | | | | | | passing/receiving CF objects at +0 to/from Objective-C methods or audited C functions. llvm-svn: 142219
* Avoid duplicate unavailbility diagnostics in objc++.Fariborz Jahanian2011-10-151-1/+3
| | | | | | // rdar://10268422 llvm-svn: 142078
* ArrayRef'ize ObjCMessageExprArgyrios Kyrtzidis2011-10-031-6/+10
| | | | llvm-svn: 140986
* Pass all the locations of the selector identifiers for a message expression ↵Argyrios Kyrtzidis2011-10-031-20/+22
| | | | | | | | from the parser. They are not kept in the AST yet. llvm-svn: 140982
* Allow the results of cf_returns_not_retained functionJohn McCall2011-10-011-133/+281
| | | | | | | | | | calls, or calls to audited functions without an explicit return attribute, to be casted without a bridge cast. Tie this mechanism in with the existing exceptions to the cast restrictions. State those restrictions more correctly and generalize. llvm-svn: 140912
* Revert r139989 and r140031, which implemented the Objective-C typeDouglas Gregor2011-09-271-9/+7
| | | | | | | | | system change in <rdar://problem/10109725> that allows conversion from 'self' in class methods to the root of the class's hierarchy. This conversion rule is a hack that has non-trivial repurcussions (particularly with overload resolution). llvm-svn: 140605
* objc - Treat type of 'self' in class methods as root ofFariborz Jahanian2011-09-171-7/+9
| | | | | | class of this method. // rdar://10109725 llvm-svn: 139989
* Rename the ARC cast kinds to start with "ARC".John McCall2011-09-101-3/+3
| | | | llvm-svn: 139466
* Don't produce 'instancetype' as the type of a message send expression. Map ↵Douglas Gregor2011-09-091-2/+9
| | | | | | it down to 'id'. llvm-svn: 139394
* Contextually converting to 'id' is not a useful operation. ContextuallyJohn McCall2011-09-091-7/+2
| | | | | | | | | | | | converting to an arbitrary Objective-C pointer type is. Without significantly re-implementing anything, change the API to reflect this, and as a minor optimization, strip the pointer conversion off before potentially building it. Mostly, this removes a really bizarre-looking bit of code from BuildInstanceMessage. llvm-svn: 139354
* Give conversions of block pointers to ObjC pointers a different cast kindJohn McCall2011-09-091-3/+10
| | | | | | | | than conversions of C pointers to ObjC pointers. In order to ensure that we've caught every case, add asserts to CastExpr that strictly determine which cast kind is used for which kind of bit cast. llvm-svn: 139352
* Implement the Objective-C 'instancetype' type, which is an alias ofDouglas Gregor2011-09-081-0/+4
| | | | | | | | | | 'id' that can be used (only!) via a contextual keyword as the result type of an Objective-C message send. 'instancetype' then gives the method a related result type, which we have already been inferring for a variety of methods (new, alloc, init, self, retain). Addresses <rdar://problem/9267640>. llvm-svn: 139275
* Don't assert when diagnosing a missing cast of an unknown-anytypeJohn McCall2011-08-311-2/+3
| | | | | | | | message send to an unknown method. rdar://problem/9416370, redux. llvm-svn: 138893
* Warn on missing [super finalize] calls.Nico Weber2011-08-281-0/+4
| | | | | | This matches gcc's logic. Second half of PR10661. llvm-svn: 138730
* Be sure to do unary conversions on the operand to an ARCJohn McCall2011-08-261-0/+4
| | | | | | bridged cast. Noticed by AST inspection by Ted Kremenek! llvm-svn: 138616
* Warn on missing [super dealloc] calls.Nico Weber2011-08-221-0/+3
| | | | | | This matches gcc's logic. Half of PR10661. llvm-svn: 138240
* Add support for C++0x unicode string and character literals, from Craig Topper!Douglas Gregor2011-07-271-3/+3
| | | | llvm-svn: 136210
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-1/+1
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* With -Wselector, don't warn about unimplemented optional methodFariborz Jahanian2011-07-131-5/+8
| | | | | | | used in @selector expression because, well, their implementation is optional. // rdar://9545564 llvm-svn: 135057
* In debugger mode, make ObjC message sends to unknown selectors returnJohn McCall2011-07-131-1/+8
| | | | | | | | | | __unknown_anytype, and rewrite such message sends correctly. I had to bite the bullet and actually add a debugger support mode for this one, which is a bit unfortunate, but there really isn't anything else I could imagine doing; this is clearly just debugger-specific behavior. llvm-svn: 135051
* objc++-arc: diagnose assignment/cast of a weak-unavailableFariborz Jahanian2011-07-071-0/+17
| | | | | | | object to a __weak object/type. // rdar://9732636. One item is yet todo. llvm-svn: 134655
* In ARC, reclaim all return values of retainable type, not just thoseJohn McCall2011-07-071-0/+17
| | | | | | | | | | | | where we have an immediate need of a retained value. As an exception, don't do this when the call is made as the immediate operand of a __bridge retain. This is more in the way of a workaround than an actual guarantee, so it's acceptable to be brittle here. rdar://problem/9504800 llvm-svn: 134605
* objc-arc: enforce performSelector rules in rejecting retaining selectorsFariborz Jahanian2011-07-051-0/+48
| | | | | | | passed to it, and unknown selectors causing potential leak. // rdar://9659270 llvm-svn: 134449
OpenPOWER on IntegriCloud