Commit Graph

354 Commits

Author SHA1 Message Date
Daniel Dunbar 3a4fc4b2ec XFAIL this test for now. David/Steve, please sort out the correct fix.
llvm-svn: 79259
2009-08-17 18:01:54 +00:00
Chris Lattner 2ba5ca9d4f Improve the diagnostic emitted when an unused ObjC property getter
is found.  Instead of complaining about a generic "unused expr",
emit:
t.m:7:3: warning: property access result unused - getters should not have side effects

While objc property getters *could* have side effects, according to
the language best practices, they *shouldn't*.  Hopefully the
diagnostic now gets this across.

llvm-svn: 79192
2009-08-16 16:57:27 +00:00
Ted Kremenek 08479ae7fe Change handling of attribute 'malloc' to only accept the attribute on function
declarations (and not function pointers). This is consistent with GCC. Accepting
this attribute on function pointers means that the attribute should be treated
as a type qualifier, which apparently is not what GCC does. We obviously can
change this later should we desire to enhance the 'malloc' attribute in this
way.

llvm-svn: 79060
2009-08-15 00:51:46 +00:00
Ted Kremenek 8d091dbe13 Add more attribute 'malloc' test cases involving function pointers.
llvm-svn: 79055
2009-08-14 22:06:01 +00:00
Fariborz Jahanian 2e4a46b745 objc2's foreach statement's selector type can be
a block pointer too.

llvm-svn: 79050
2009-08-14 21:53:27 +00:00
Ted Kremenek 026d201eca This test case does not need to include 'stdlib.h'.
llvm-svn: 79042
2009-08-14 20:53:10 +00:00
Ted Kremenek 527042b5a9 Improve Sema's handling of attribute 'malloc' to reject the attribute when
attaching to Objective-C methods (which mirrors GCC's behavior) and to allow the
return type of the function to be an Objective-C pointer or Block pointer (which
GCC also accepts).

Along the way, add 'const' to some of the pointer arguments of various utility
functions...

llvm-svn: 79040
2009-08-14 20:49:40 +00:00
Fariborz Jahanian 83b000c713 Fixed a regression in deciding when to issue warning on properties which
implement NSCopying protocol in GC mode.

llvm-svn: 79008
2009-08-14 18:06:25 +00:00
Fariborz Jahanian 887cd6a8eb error on property of objc interface type instead of crashing
llvm-svn: 78826
2009-08-12 18:17:53 +00:00
Fariborz Jahanian 853d21a18a Warn on use of property dot syntax when unused.
llvm-svn: 78760
2009-08-12 00:45:33 +00:00
Fariborz Jahanian 3f8917abf6 Patch to warn if a property which is 'assign' by default
may not implement NSCopying protocol in -fobjc-gc[-only] mode.

llvm-svn: 78726
2009-08-11 22:02:25 +00:00
Chris Lattner 66a388b859 merge two tests.
llvm-svn: 78705
2009-08-11 20:08:52 +00:00
Chris Lattner f1c9797ffa Fix rdar://7126285: don't warn on unused ObjC property access
that uses "dot syntax" since it might have a side effect.

llvm-svn: 78704
2009-08-11 20:08:03 +00:00
Daniel Dunbar d3a114fe2d Update test case; I don't really understand why packed enums changed this, but
the new havior is better so...

llvm-svn: 78473
2009-08-08 15:47:00 +00:00
Fariborz Jahanian b61af4c566 Some code refactoring. Be more generous in issuance of warning
on method type mismatches per Chris's comment.

llvm-svn: 78075
2009-08-04 17:01:09 +00:00
Fariborz Jahanian 10ff786e1e Compare matching selectors in current and
super class(s) and warn on any parameter
type mismatch if potentially unsafe. 

llvm-svn: 78029
2009-08-04 01:07:16 +00:00
Steve Naroff 53fcbb89f9 Remove an ObjC-specific XFAIL (and tweak test).
llvm-svn: 77454
2009-07-29 15:24:47 +00:00
Steve Naroff 85d9715c24 Fix <rdar://problem/7100524> regression: "error: incompatible operand types ('void *' and 'NSString *')".
Remove XFAIL from 'conditional-expr-4.m' test case (which would have caught this).
Also tweaked several aspects of the test to jive with the current type checking.

llvm-svn: 77453
2009-07-29 15:09:39 +00:00
John McCall 02dee0a46a Semantic checking for main().
Fix some invalid main() methods in the test suite that were nicely
exposed by the new checks.

llvm-svn: 77047
2009-07-25 04:36:53 +00:00
Steve Naroff e87026a08f Allow front-end 'isa' access on object's of type 'id'.
Enhance test case to cover 'isa' access on interface types (clang produces an error, GCC produces a warning).

Still need back-end CodeGen for ObjCIsaExpr.

llvm-svn: 76979
2009-07-24 17:54:45 +00:00
Steve Naroff 8e6aee5821 Remove a bunch of FIXME's related to ObjC type checking.
- 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
2009-07-23 01:01:38 +00:00
Mike Stump 33979f75a0 Add warning for falling off the end of a function that should return a
value.  This is on by default, and controlled by -Wreturn-type (-Wmost
-Wall).  I believe there should be very few false positives, though
the most interesting case would be:

  int() { bar(); }

when bar does:

  bar() { while (1) ; }

Here, we assume functions return, unless they are marked with the
noreturn attribute.  I can envision a fixit note for functions that
never return normally that don't have a noreturn attribute to add a
noreturn attribute.

If anyone spots other false positives, let me know!

llvm-svn: 76821
2009-07-22 23:56:57 +00:00
Steve Naroff 51d4f79ffa Fix <rdar://problem/6770276> Support Class<Proto> syntax.
llvm-svn: 76741
2009-07-22 16:07:01 +00:00
Mike Stump 753d120975 Prep for new warning.
llvm-svn: 76709
2009-07-22 00:43:08 +00:00
Argyrios Kyrtzidis 43cee935ae Remove Sema::LookupObjCImplementation and replace it with just calling ObjCInterfaceDecl::getImplementation().
llvm-svn: 76509
2009-07-21 00:06:04 +00:00
Argyrios Kyrtzidis 6d9fab7619 - Introduce ASTContext::getObjCImplementation() and ASTContext::setObjCImplementation() which use a DenseMap to associate
an interface/category with its implementation (if one exists).

- Introduce ObjCInterfaceDecl::get/setImplementation() and ObjCCategoryDecl::get/setImplementation() that use the above methods.

- Add a compiler error for when a category is reimplemented.

llvm-svn: 76508
2009-07-21 00:05:53 +00:00
Daniel Dunbar a3f41f4bba Some more ?: for Obj-C tests.
llvm-svn: 76125
2009-07-16 23:34:22 +00:00
Daniel Dunbar 0418a5f11e Add more testing of ?: for Obj-C object types.
llvm-svn: 76108
2009-07-16 21:55:48 +00:00
Fariborz Jahanian ca75db7c02 Diagnose ++/-- op on objc pointers in
nonfragile abi, instead of crashing.

llvm-svn: 76088
2009-07-16 17:59:14 +00:00
Steve Naroff a057ba905b Avoid crashing for the enclosed test case.
This is fallout from the recent ObjCObjectPointerType rework. I'll work on fixing this tomorrow.

llvm-svn: 75870
2009-07-16 00:25:06 +00:00
Ted Kremenek d4adebbbd6 Handle some more fallout with the conversion of using PointerType for
Objective-C pointers to using ObjCObjectPointerType.

Now the checking for 'attribute ((nonnull))' in Sema doesn't emit an error when
trying to apply that attribute to a parameter that is an Objective-C pointer
(this is a regression).

To prevent this regression from occuring in the future, the 'nonnull.c' test was
moved to test/SemaObjC and renamed 'nonnull.m'. I also enhanced the tests to
show that function calls involved a NULL Objective-C pointer constant does not
trigger a warning. This is consistent with GCC, but should likely be fixed.

llvm-svn: 75856
2009-07-15 23:23:54 +00:00
Steve Naroff 7183eefdfa Remove cast from test case (cast was incorrectly added as part of http://llvm.org/viewvc/llvm-project?view=rev&revision=75314).
Add new warnings that are being produced.

llvm-svn: 75816
2009-07-15 19:44:23 +00:00
Steve Naroff 1329fa0ed9 Implement the ObjC pseudo built-in types as clang "BuiltinType's". I say pseudo built-in types, since Sema still injects a typedef for recognition (i.e. they aren't truly built-ins from a parser perspective).
This removes the static data/methods on ObjCObjectPointerType while preserving the nice API (no need to fiddle with ASTContext:-).

This patch also adds Type::isObjCBuiltinType().

This should be the last fairly large patch related to recrafting the ObjC type system. The follow-on patches should be fairly small.

llvm-svn: 75808
2009-07-15 18:40:39 +00:00
Daniel Dunbar df1cff7356 Remove excessive use of Carbon.h / Cocoa.h in clang tests.
- These kinds of "shotgun" tests are very slow, and do not belong in the
   regression suite. If these kinds of tests are regarded to have value, they
   should be added to the LLVM test-suite.

 - I would actually like to remove all of these tests, but I left Sema/carbon.c
   and SemaObjC/cocoa.m...

llvm-svn: 75399
2009-07-11 23:03:07 +00:00
Steve Naroff 7cae42b07a This patch includes a conceptually simple, but very intrusive/pervasive change.
The idea is to segregate Objective-C "object" pointers from general C pointers (utilizing the recently added ObjCObjectPointerType). The fun starts in Sema::GetTypeForDeclarator(), where "SomeInterface *" is now represented by a single AST node (rather than a PointerType whose Pointee is an ObjCInterfaceType). Since a significant amount of code assumed ObjC object pointers where based on C pointers/structs, this patch is very tedious. It should also explain why it is hard to accomplish this in smaller, self-contained patches.

This patch does most of the "heavy lifting" related to moving from PointerType->ObjCObjectPointerType. It doesn't include all potential "cleanups". The good news is additional cleanups can be done later (some are noted in the code). This patch is so large that I didn't want to include any changes that are purely aesthetic.

By making the ObjC types truly built-in, they are much easier to work with (and require fewer "hacks"). For example, there is no need for ASTContext::isObjCIdStructType() or ASTContext::isObjCClassStructType()! We believe this change (and the follow-up cleanups) will pay dividends over time. 

Given the amount of code change, I do expect some fallout from this change (though it does pass all of the clang tests). If you notice any problems, please let us know asap! Thanks.

llvm-svn: 75314
2009-07-10 23:34:53 +00:00
Fariborz Jahanian 5582f231f2 don't crash if class is using itself as its super class.
llvm-svn: 75178
2009-07-09 22:08:26 +00:00
Fariborz Jahanian 385db80cc5 Diagnose, and not crash, when taking address of property expression.
llvm-svn: 74935
2009-07-07 18:50:52 +00:00
Douglas Gregor c9c02ed8f4 Keep track of when declarations are "used" according to C and
C++. This logic is required to trigger implicit instantiation of
function templates and member functions of class templates, which will
be implemented separately.

This commit includes support for -Wunused-parameter, printing warnings
for named parameters that are not used within a function/Objective-C
method/block. Fixes <rdar://problem/6505209>.

llvm-svn: 73797
2009-06-19 23:52:42 +00:00
Fariborz Jahanian bada785729 Test case was left behind from my last patch.
llvm-svn: 73519
2009-06-16 17:57:28 +00:00
Eli Friedman 9e81b02ec5 Don't allow defining a block with a non-prototype type. Remove a
hack which introduces some strange inconsistencies in compatibility 
for block pointers.

Note that unlike an earlier revision proposed on cfe-commits, this patch 
still allows declaring block pointers without a prototype.

llvm-svn: 73041
2009-06-08 04:24:21 +00:00
Fariborz Jahanian 991a2b1933 Diagnose misuse of __strong attribute in a redeclaration.
llvm-svn: 72737
2009-06-02 20:58:58 +00:00
Fariborz Jahanian 6ab4375f87 Issue diagnostics on __weak attribute mismatch.
Fixes an error recovery issue which caused a crash.

llvm-svn: 72733
2009-06-02 18:32:00 +00:00
Eli Friedman 179f2b9ec7 Remove test which doesn't pass with gcc.
llvm-svn: 72714
2009-06-02 05:24:36 +00:00
Fariborz Jahanian 2d725b19da This patch attempts to fix the merging of __strong/__weak attributes
in merge_types. It is incomplete. We probably want to issue 
a warning if user attempts to change the attribute from __weak to
__strong or vice-vera. It also assumes that a __weak/__strong
attribute can not be specified with other (currently one) type
attriute. 

llvm-svn: 72711
2009-06-02 01:40:22 +00:00
Daniel Dunbar 7614192d03 Update test case.
llvm-svn: 72694
2009-06-01 17:27:37 +00:00
Eli Friedman dcca6333c6 Disable type merging with gc attributes. This has a number of nasty
properties at the moment:

1. It allows stuff like "__strong id x; __weak id x;".

2. For constructs like "__strong id x; id x;", subsequent references to 
x lose the objc_gc attribute.

3. This incorrectly allows merges involving the address_space attribute.

4. Constructs like "id x; /* some code using x */ __weak id x;" don't 
apply the objc_gc attribute consistently to all uses of x.

The first three can probably be fixed relatively easily; the fourth 
would be extremely difficult to fix.

llvm-svn: 72683
2009-06-01 01:22:52 +00:00
Fariborz Jahanian 88fead8c48 Cannot type cast @selector expressions.
llvm-svn: 72284
2009-05-22 21:42:52 +00:00
Fariborz Jahanian 162af638a9 Added -fblocks to the test's options.
llvm-svn: 72274
2009-05-22 20:06:10 +00:00
Fariborz Jahanian db3a4c1388 (Next runtime only) check to see if class implements forwardInvocation method
and objects of this class are derived from 'NSProxy'.
Under such conditions, which means that every method possible is 
implemented in the class, we should not issue "Method definition not found" 
warnings.

llvm-svn: 72267
2009-05-22 17:12:32 +00:00
Fariborz Jahanian 8c46fec43d Fixed a warning bug when receiver is an object via
setting of NSObject attribute.

llvm-svn: 72225
2009-05-21 21:04:28 +00:00