Commit Graph

186 Commits

Author SHA1 Message Date
Chris Lattner 1897de1c38 Fix PR3766, a really nasty silent miscompilation case where we emitted
a warning and then threw away the AST.  While I'm in there, tighten up the
code to actually reject completely bogus cases (sending a message to a 
struct).  We still allow sending a message to an int, which doesn't make
sense but GCC allows it and is easy to support.

llvm-svn: 66468
2009-03-09 21:19:16 +00:00
Steve Naroff 9527bbfc08 Implement property '.' notation on Factory/Class objects. Parser changes aren't very pretty:-(
This fixes <rdar://problem/6496506> Implement class setter/getter for properties.

llvm-svn: 66465
2009-03-09 21:12:44 +00:00
Steve Naroff ed03170d28 Improvements to private method lookup.
Patch by Jean-Daniel Dupas. Thanks!

llvm-svn: 66383
2009-03-08 18:56:13 +00:00
Steve Naroff e29c4dd022 Partial fix <rdar://problem/6301205> [irgen] dot-syntax on super isn't supported.
Tweak Sema::ActOnMemberReferenceExpr() and Sema::ActOnDeclarationNameExpr() to handle "super." notation for Class methods.

llvm-svn: 66185
2009-03-05 20:12:00 +00:00
Steve Naroff 8f4528bc7c Tweak diag for <rdar://problem/5982579> [clang on xcode] (using arch=x86_64): synthesized property 'sdkPath' must either be named the same as a compatible ivar or must explicitly name an ivar.
llvm-svn: 66162
2009-03-05 15:45:01 +00:00
Steve Naroff 41d09add4f Fix <rdar://problem/6144382> [sema] gcc inconsistency w.r.t. forward protocol declarations.
llvm-svn: 66161
2009-03-05 15:22:01 +00:00
Fariborz Jahanian b8d091c4eb Implemented access check for ivars accessed inside
c-style functions declared inside objc @implementations.

llvm-svn: 66087
2009-03-04 22:30:12 +00:00
Steve Naroff d1b64be776 Partial fix for <rdar://problem/6645157> [clang on Xcode; regression]: error: instance variable 'someField' is private.
A recent regression caused by http://llvm.org/viewvc/llvm-project?rev=65912&view=rev.

This commit isn't fully baked. Nevertheless, it should cause Xcode to compile again. Will speak with Fariborz offline.

llvm-svn: 66045
2009-03-04 18:34:24 +00:00
Fariborz Jahanian c2371eadd6 Fix a corner case of message lookup looking for class methods.
If all else failed, find the message in class's root's
list of instacne methods!

llvm-svn: 66040
2009-03-04 17:50:39 +00:00
Steve Naroff 3f49feeed5 Finish up some fixes related to <rdar://problem/6497631> Message lookup is sometimes different than gcc's.
- Disallow casting 'super'. GCC allows this, however it doesn't make sense (super isn't an expression and the cast won't alter lookup/dispatch).
- Tighten up lookup when messaging 'self'.

llvm-svn: 66033
2009-03-04 15:11:40 +00:00
Eli Friedman f22fa28522 Make this test a bit more specific about the target so that it passes on
Linux.

llvm-svn: 66019
2009-03-04 06:00:10 +00:00
Steve Naroff 013813dd5d Change a warning to an error...
llvm-svn: 65978
2009-03-03 23:13:51 +00:00
Fariborz Jahanian 9a8e759b4f Implement an important missing warning when a selector
is searched for in the global pool. It already uncovered 
a clang bug in message selection.

llvm-svn: 65974
2009-03-03 22:19:15 +00:00
Steve Naroff c03f6b91b1 Fix <rdar://problem/5982579> [clang on xcode] (using arch=x86_64): synthesized property 'sdkPath' must either be named the same as a compatible ivar or must explicitly name an ivar.
llvm-svn: 65973
2009-03-03 22:09:41 +00:00
Steve Naroff 27ed6f6766 Fix <rdar://problem/6252237> [sema] qualified id should be disallowed in @catch statements.
llvm-svn: 65969
2009-03-03 21:16:54 +00:00
Steve Naroff 39d6fba0d6 Fix <rdar://problem/6632061> [sema] non object types should not be allowed in @catch statements.
llvm-svn: 65968
2009-03-03 20:59:06 +00:00
Steve Naroff b0e25c1ceb Remove old/incorrect warnings.
llvm-svn: 65950
2009-03-03 15:49:23 +00:00
Steve Naroff 3e1181e2e9 Fix <rdar://problem/6497242> Inherited overridden protocol declared objects don't work.
Change Sema::DiagnosePropertyMismatch() to check for type compatibility (rather than type equivalence, which is too strict).

llvm-svn: 65949
2009-03-03 15:43:24 +00:00
Steve Naroff 157599fe1c Fix <rdar://problem/6497608> clang does not catch ivar type mismatches in @implementation.
llvm-svn: 65948
2009-03-03 14:49:36 +00:00
Fariborz Jahanian a458c4ff65 Check of ivar access access control.
llvm-svn: 65912
2009-03-03 01:21:12 +00:00
Steve Naroff f3833d70be Fix <rdar://problem/6635908> crash on invalid
llvm-svn: 65909
2009-03-03 00:45:38 +00:00
Fariborz Jahanian bf8e842b67 Diagnose a variety of access of ivars when they conflict with
local or global variables in instance/class methods.

llvm-svn: 65879
2009-03-02 21:55:29 +00:00
Fariborz Jahanian 33afd771b4 Check for duplicate declaration of method of a class
in its extension.

llvm-svn: 65854
2009-03-02 19:05:07 +00:00
Steve Naroff 8676e08730 Fix <rdar://problem/6248764> parser rejects: bad receiver type 'CFStringRef'.
Downgrade an error to a warning (for GCC compatibility).

llvm-svn: 65779
2009-03-01 17:14:31 +00:00
Steve Naroff 114aecb26b Fix <rdar://problem/6619539> incompatible pointer types sending 'XCElementSpacer *', expected 'XCElement *' (not handling protocol signatures correctly?).
- Reworked ASTContext::canAssignObjCInterfaces().
- Added ObjCProtocolDecl::lookupProtocolNamed().

llvm-svn: 65773
2009-03-01 16:12:44 +00:00
Chris Lattner 9ef10f4638 "This patch uses the new ObjCImplDecl class to merge Sema::ImplMethodsVsClassMethods and Sema::ImplCategoryMethodsVsIntfMethods methods.
And now, when clang check a class implementation to find unimplemented methods, it also checks all methods from the class extensions (unnamed categories).

There is also a test case to check this warning.

This patch contains also a minor update for ObjCImplDecl . getNameAsCString and getNameAsString now returns an empty string instead of crashing for unnamed categories."

Patch by Jean-Daniel Dupas!

llvm-svn: 65744
2009-03-01 00:56:52 +00:00
Fariborz Jahanian f5c1c923e8 Diagnose gc attribute mismatch of property and its ivar.
llvm-svn: 65656
2009-02-27 22:38:11 +00:00
Fariborz Jahanian 7285cf57a3 Do not issue bogus error on __weak/__strong ivar access.
llvm-svn: 65583
2009-02-26 23:05:51 +00:00
Steve Naroff de68001e76 Fix <rdar://problem/6574319> clang issues error on 'readonly' property with a defaul setter attribute.
Needed to make isPropertyReadonly() non-const (for this fix to compile). I imagine there's a way to retain the const-ness, however I have more important fish to fry.

llvm-svn: 65562
2009-02-26 19:11:32 +00:00
Steve Naroff 42ab0dd1ee Fix <rdar://problem/6614945> method not found.
This was a fairly recent regression.

llvm-svn: 65547
2009-02-26 18:16:19 +00:00
Steve Naroff b162f170da Fix http://llvm.org/bugs/show_bug.cgi?id=3544.
The code for looking up local/private method in Sema::ActOnInstanceMessage() was not handling categories properly. Sema::ActOnClassMessage() didn't have this bug.
Created a helper with the correct logic and changed both methods to use it.

llvm-svn: 65532
2009-02-26 15:55:06 +00:00
Steve Naroff 8ec2784f58 Fix ObjCInterfaceDecl::lookupInstanceMethod()/lookupClassMethod() to search in inherited protocols.
Also changed ObjCInterfaceDecl::lookupClassMethod() to look through a categories protocols.

Test/patch submitted by Jean-Daniel Dupas (thanks!).

llvm-svn: 65526
2009-02-26 11:32:02 +00:00
Anders Carlsson f2f2e7f6a1 Use CheckAssignmentConstraints for checking the cleanup attr function. Fixes PR3656.
llvm-svn: 65461
2009-02-25 17:19:08 +00:00
Chris Lattner d13b8b55ca fix rdar://6611778, a redefinition of an interface was causing an
assertion when the ivars and method list was reset into the existing
interface.  To fix this, mark decls as invalid when they are redefined,
and don't insert ivars/methods into invalid decls.

llvm-svn: 65340
2009-02-23 22:00:08 +00:00
Steve Naroff a94e52c687 - Generate error for protocol qualifiers on 'Class'.
- Generate error for protocol qualifiers on non-ObjC types.

llvm-svn: 65333
2009-02-23 18:53:24 +00:00
Steve Naroff 91362dd011 Revert http://llvm.org/viewvc/llvm-project?view=rev&revision=65244.
Remove support for "Class<P>". Will be making this an error.

llvm-svn: 65332
2009-02-23 18:36:16 +00:00
Steve Naroff c4173fa704 Contains the following (related to problems found while investigting <rdar://problem/6497631> Message lookup is sometimes different than gcc's).
- Implement instance/class overloading in ObjCContainerDecl (removing a FIXME). This involved hacking NamedDecl::declarationReplaces(), which took awhile to figure out (didn't realize replace was the default).
- Changed Sema::ActOnInstanceMessage() to remove redundant warnings when dealing with protocols. For now, I've omitted the "protocol" term in the diagnostic. It simplifies the code flow and wan't always 100% accurate (e.g. "Foo<Prot>" looks in the class interface, not just the protocol).
- Changed several test cases to jive with the above changes.

llvm-svn: 65292
2009-02-22 19:35:57 +00:00
Steve Naroff 670e72ddc7 Add support for GCC ObjC extension "Class<protocol>". Sigh.
Found while researching <rdar://problem/6497631> Message lookup is sometimes different than gcc's.

Will never be seen in user code. Needed to pass dejagnu testsuite.

llvm-svn: 65244
2009-02-21 20:17:11 +00:00
Steve Naroff cd8d572283 Warn about bogus protocol qualifiers.
llvm-svn: 65241
2009-02-21 19:50:43 +00:00
Fariborz Jahanian 0c9404e0a7 Warn on use of __weak attribute on local
variable (objc2 gc specific).

llvm-svn: 65240
2009-02-21 19:44:02 +00:00
Steve Naroff da88fb9c73 Add test case to record a couple inconsistencies with GCC (found in <rdar://problem/6561076> [clang on Xcode] warning: cannot find protocol definition for 'OzzyP').
Removing the "cannot find protocol" warning is trivial if necessary (but I don't think it's the right thing to do).

llvm-svn: 65232
2009-02-21 17:03:43 +00:00
Steve Naroff 7a7814c32b This fixes <rdar://problem/6497650> More type mismatches issues with clang.
Move two key ObjC typechecks from Sema::CheckPointerTypesForAssignment() to ASTContext::mergeTypes().

This allows us to take advantage of the recursion in ASTContext::mergeTypes(), removing some bogus warnings.

This test case I've added includes an example where we still warn (and GCC doesn't). Need to talk with folks and decide what to do. At this point, the major bogosities should be fixed.

llvm-svn: 65231
2009-02-21 16:18:07 +00:00
Steve Naroff 326064168a Fix <rdar://problem/6500554> missing objc error message.
llvm-svn: 65198
2009-02-20 22:59:16 +00:00
Steve Naroff 17b2f5d728 Fix <rdar://problem/6586239> bitfield constraints not enforced (for ObjC)
llvm-svn: 65128
2009-02-20 17:57:11 +00:00
Eli Friedman 7157825d44 Use -verify for consistency.
llvm-svn: 65106
2009-02-20 02:03:47 +00:00
Douglas Gregor 171c45ab0c Downgrade complaints about calling unavailable functions to a warning
(as GCC does), except when we've performed overload resolution and
found an unavailable function: in this case, we actually error.

Merge the checking of unavailable functions with the checking for
deprecated functions. This unifies a bit of code, and makes sure that
we're checking for unavailable functions in the right places. Also,
this check can cause an error. We may, eventually, want an option to
make "unavailable" warnings into errors.

Implement much of the logic needed for C++0x deleted functions, which
are effectively the same as "unavailable" functions (but always cause
an error when referenced). However, we don't have the syntax to
specify deleted functions yet :)

llvm-svn: 64955
2009-02-18 21:56:37 +00:00
Chris Lattner a26fb347a0 Start improving diagnostics that relate to subcharacters of string literals.
First step, handle diagnostics in StringLiteral's that are due to token pasting.

For example, we now handle:
  id str2 = @"foo" 
            "bar"
           @"baz"
           " b\0larg";  // expected-warning {{literal contains NUL character}}

Correctly:

test/SemaObjC/exprs.m:17:15: warning: CFString literal contains NUL character
           " b\0larg";  // expected-warning {{literal contains NUL character}}
           ~~~^~~~~~~

There are several other related issues still to be done.

llvm-svn: 64924
2009-02-18 17:49:48 +00:00
Chris Lattner c96e0c4399 pass -verify in exprs.m, merge const-id.m into message.m
llvm-svn: 64886
2009-02-18 04:41:38 +00:00
Chris Lattner 2c4866057d fix rdar://6597252: two exactly identical pointer types are always
compatible, even if they are weird implicit objc pointer types like
Class.

llvm-svn: 64885
2009-02-18 04:38:20 +00:00
Chris Lattner e404d0ba05 warn about interfaces that inherit from deprecated classes.
llvm-svn: 64671
2009-02-16 21:33:09 +00:00