Commit Graph

1390 Commits

Author SHA1 Message Date
Benjamin Kramer cdac761475 Sema: When merging objc string literals, give the result a constant array type.
Also assert that we never create non-array string literals again.

PR18939.

llvm-svn: 202147
2014-02-25 12:26:20 +00:00
Ted Kremenek 204c3c50b9 [ObjC] Make attribute 'objc_protocol_requires_explicit_implementation' behave correctly with default property synthesis.
In particular, if we see an @property within the @interface of a class
conforming to a protocol with this attribute, we treat that as
if the implementation were available, per the rules of default
property synthesis.

llvm-svn: 201911
2014-02-22 00:02:03 +00:00
Ted Kremenek 27cfe10df8 Add requirement that attribute 'objc_protocol_requires_explicit_implementation' can only be applied to protocol definitions.
llvm-svn: 201899
2014-02-21 22:49:04 +00:00
Ted Kremenek 38882022af [ObjC] add support for properties in attribute 'objc_protocol_requires_explicit_implementation'.
llvm-svn: 201880
2014-02-21 19:41:39 +00:00
Fariborz Jahanian 92e3aa2622 [Objective-C Sema]. Warn when an indirectly overridden property
mismatches the one declared in current class; in addition to
those that are directly overridden. 
// rdar://15967517

llvm-svn: 201446
2014-02-15 00:04:36 +00:00
Jordan Rose c939907a5a 'nonnull(1)' on a block parameter should apply to the block's argument.
Thanks to r199467, __attribute__((nonnull)) (without arguments) can apply
directly to parameters, instead of being applied to the whole function.
However, the old form of nonnull (with an argument index) could also apply
to the arguments of function and block pointers, and both of these can be
passed as parameters.

Now, if 'nonnull' with an argument is found on a parameter, /and/ the
parameter is a function or block pointer, it is handled the old way.

PR18795

llvm-svn: 201162
2014-02-11 17:27:59 +00:00
Fariborz Jahanian 7395c79c4e Objective-C. Revert patch r193003 for further
internal discussions. // rdar://16006401

llvm-svn: 200986
2014-02-07 19:25:10 +00:00
Fariborz Jahanian f40ef45c9d Objective-C. Fixes a bug where "new" family attribute
was not being overridden in the category method implementation
resulting in bogus warning. // rdar://15919775

llvm-svn: 200342
2014-01-28 22:46:29 +00:00
Fariborz Jahanian c5fa540bcf Another test for patch for // rdar://15890251
llvm-svn: 200257
2014-01-27 22:44:17 +00:00
Fariborz Jahanian 122d94fd61 ObjectiveC. Fixes a bug in recognition of an ivar
backing a property resulting in bogus warning.
// rdar://15890251

llvm-svn: 200254
2014-01-27 22:27:43 +00:00
Fariborz Jahanian 369a9c3b51 ObjectiveC. When introducing a new property declaration in
parimary class and in mrr mode, assume property's default
memory attribute (assign) and to prevent a bogus warning.
// rdar://15859862

llvm-svn: 200238
2014-01-27 19:14:49 +00:00
Fariborz Jahanian dad9630398 ObjectiveC. When issuing property implementation is
not using backing ivar warning, ignore when
property is not being synthesized (user declared its
implementation @dynamic). // rdar://1583425

llvm-svn: 199820
2014-01-22 19:02:20 +00:00
Ted Kremenek ef9e7f8059 Add basic checking for returning null from functions/methods marked 'returns_nonnull'.
This involved making CheckReturnStackAddr into a static function, which
is now called by a top-level return value checking routine called
CheckReturnValExpr.

llvm-svn: 199790
2014-01-22 06:10:28 +00:00
Ted Kremenek dbf62e3eee Wire up basic parser/sema support for attribute 'returns_nonnull'.
This attribute is supported by GCC.  More generally it should
probably be a type attribute, but this behavior matches 'nonnull'.

This patch does not include warning logic for checking if a null
value is returned from a function annotated with this attribute.
That will come in subsequent patches.

llvm-svn: 199626
2014-01-20 05:50:47 +00:00
Ted Kremenek 15478b32cb Add more test cases for attribute 'objc_protocol_requires_explicit_implementation'.
llvm-svn: 199480
2014-01-17 08:34:19 +00:00
Ted Kremenek 9aedc159ef Enhance attribute 'nonnull' to be applicable to parameters directly (infix).
This allows the following syntax:

  void baz(__attribute__((nonnull)) const char *str);

instead of:

  void baz(const char *str) __attribute__((nonnull(1)));

This also extends to Objective-C methods.

The checking logic in Sema is not as clean as I would like.  Effectively
now we need to check both the FunctionDecl/ObjCMethodDecl and the parameters,
so the point of truth is spread in two places, but the logic isn't that
cumbersome.

Implements <rdar://problem/14691443>.

llvm-svn: 199467
2014-01-17 06:24:56 +00:00
Fariborz Jahanian bae1bcb6bf ObjectiveC. Improve on diagnostics per Jordan's feedback.
llvm-svn: 199278
2014-01-15 00:59:25 +00:00
Fariborz Jahanian 2ea30fb9b0 ObjectiveC. produce more expressive warning when
-Wselector detects an unimplemented method used
in an @selector expression. // rdar://15781538

llvm-svn: 199255
2014-01-14 20:35:13 +00:00
Fariborz Jahanian 26cb6d90b8 ObjectiveC. Remove warning on mismatched methods
which may belong to unrelated classes. It was
primarily intended for miuse of @selector expression.
But warning is too noisy and will be issued when
an actual @selector is used. // rdar://15740134

llvm-svn: 198952
2014-01-10 19:27:21 +00:00
Fariborz Jahanian 65b1377911 ObjectiveC. 1) Warn when @dynamic (as well as synthesize)
property has the naming convention that implies 'ownership'.
2) improve on diagnostic and make it property specific.
3) fix the line number in the case of default property
synthesis. // rdar://15757510

llvm-svn: 198905
2014-01-10 00:53:48 +00:00
Ted Kremenek ce0e3f8a09 Have attribute 'objc_precise_lifetime' suppress -Wunused.
Fixes <rdar://problem/15596883>

In ARC, __attribute__((objc_precise_lifetime)) guarantees that the
object stored in it will survive to the end of the variable's formal
lifetime.  It is therefore useful even if it completely unused.

llvm-svn: 198888
2014-01-09 20:19:45 +00:00
Argyrios Kyrtzidis 2080d90f37 [objc] Refactor and improve functionality for the -Wunused-property-ivar warning.
- Remove the additions to ObjCMethodDecl & ObjCIVarDecl that were getting de/serialized and consolidate
  all functionality for the checking for this warning in Sema::DiagnoseUnusedBackingIvarInAccessor
- Don't check immediately after the method body is finished, check when the @implementation is finished.
  This is so we can see if the ivar was referenced by any other method, even if the method was defined after the accessor.
- Don't silence the warning if any method is called from the accessor silence it if the accessor delegates to another method via self.

rdar://15727325

llvm-svn: 198432
2014-01-03 18:32:18 +00:00
Aaron Ballman 34b3475cd3 Reworded the NSObject attribute diagnostics to be more consistent with other attribute diagnostics. Also updated the associated test case.
llvm-svn: 198368
2014-01-02 22:45:33 +00:00
Fariborz Jahanian 5b3105d2cb ObjectiveC. Remove false positive warning for missing property
backing ivar by not issuing this warning if ivar is referenced
somewhere and accessor makes method calls. // rdar://15727325

llvm-svn: 198367
2014-01-02 22:42:09 +00:00
Aaron Ballman 05e420abad Updated the wording of two attribute-related diagnostics so that they print the offending attribute name. Also updates the associated test cases.
llvm-svn: 198355
2014-01-02 21:26:14 +00:00
Fariborz Jahanian 1cc7ae1d08 ObjectiveC. Class methods must be ignored when looking for
property accessor's missing backing ivar. This eliminates
the bogus warning being issued. // rdar://15728901

llvm-svn: 198322
2014-01-02 17:24:32 +00:00
Ted Kremenek 1654511884 Wordsmith "maybe" into "may be" in diagnostic, and move warning under flag.
llvm-svn: 197736
2013-12-19 22:47:11 +00:00
Aaron Ballman 37c5f5da32 After discussing with John McCall, removing the ns_bridged attribute as it is unused.
llvm-svn: 197729
2013-12-19 22:12:51 +00:00
Fariborz Jahanian 4b7946a28a ObjectiveC. Sema test for property, methods
'section' attribute. // rdar://15450637

llvm-svn: 197704
2013-12-19 17:22:23 +00:00
Ted Kremenek b79ee57080 Implemented delayed processing of 'unavailable' checking, just like with 'deprecated'.
Fixes <rdar://problem/15584219> and <rdar://problem/12241361>.

This change looks large, but all it does is reuse and consolidate
the delayed diagnostic logic for deprecation warnings with unavailability
warnings.  By doing so, it showed various inconsistencies between the
diagnostics, which were close, but not consistent.  It also revealed
some missing "note:"'s in the deprecated diagnostics that were showing
up in the unavailable diagnostics, etc.

This change also changes the wording of the core deprecation diagnostics.
Instead of saying "function has been explicitly marked deprecated"
we now saw "'X' has been been explicitly marked deprecated".  It
turns out providing a bit more context is useful, and often we
got the actual term wrong or it was not very precise
 (e.g., "function" instead of "destructor").  By just saying the name
of the thing that is deprecated/deleted/unavailable we define
this issue away.  This diagnostic can likely be further wordsmithed
to be shorter.

llvm-svn: 197627
2013-12-18 23:30:06 +00:00
Fariborz Jahanian 8ef938972a ObjectiveC. Fixes the sentence in a diagnostic.
// rdar://15397430

llvm-svn: 197586
2013-12-18 16:51:06 +00:00
Fariborz Jahanian 1b30b593ba ObjectiveC. typo fix in my last patch,
per Jordan's review. 

llvm-svn: 197540
2013-12-18 00:52:54 +00:00
Fariborz Jahanian 7e350d23b2 Objctive-C. warn if dealloc is being overridden in
a category implementation. // rdar://15397430

llvm-svn: 197534
2013-12-17 22:44:28 +00:00
Fariborz Jahanian 381edf5759 ObjectiveC. Further improvements of use
of objc_bridge_related attribute; eliminate
unnecessary diagnostics which is issued elsewhere,
fixit now produces a valid AST tree per convention.
This results in some simplification in handling of
this attribute as well. // rdar://15499111

llvm-svn: 197436
2013-12-16 22:54:37 +00:00
Alp Toker 099b0d3741 Fix test containing backslash and newline separated by space
This was silently accepted by clang without warning due to a lexer bug.

llvm-svn: 197330
2013-12-14 23:32:27 +00:00
Argyrios Kyrtzidis 0f7f222c59 [objc] Add a test to make sure that a class can add a secondary initializer via a category
and still inherit the designated initializers of its super class.

llvm-svn: 197301
2013-12-14 02:16:41 +00:00
Fariborz Jahanian 07e7e6cbc8 Objective-C. Remove obsolete option from test.
// rdar://15641300

llvm-svn: 197263
2013-12-13 19:06:55 +00:00
Fariborz Jahanian 059021a369 Objective-C. Do not issue warning when 'readonly'
property declaration has a memory management
attribute (retain, copy, etc.). Sich properties
are usually overridden to become 'readwrite'
via a class extension (which require the memory
management attribute specified). In the absence of class
extension override, memory management attribute is
needed to produce correct Code Gen. for the
property getter in any case and this warning becomes
confusing to user. // rdar://15641300

llvm-svn: 197251
2013-12-13 18:19:59 +00:00
Ted Kremenek 33e430fc58 Refine 'objc_protocol_requires_explicit_implementation' attribute to better handle indirect protocols.
llvm-svn: 197209
2013-12-13 06:26:14 +00:00
Ted Kremenek 2ccf19e1ab Change 'method X in protocol not implemented' warning to include the name of the protocol.
This removes an extra "note:", which wasn't really all that more useful
and overall reduces the diagnostic spew for this case.

llvm-svn: 197207
2013-12-13 05:58:51 +00:00
Argyrios Kyrtzidis d664a34de8 [objc] If we don't know for sure what the designated initializers of the superclass are,
assume that a [super init..] inside a designated initializer also refers to a designated one
and do not warn.

llvm-svn: 197202
2013-12-13 03:48:17 +00:00
Ted Kremenek 6d69ac8b8a Enhance "auto synthesis will not synthesize property in protocol" to include property and protocol name.
Implements <rdar://problem/15617839>.

llvm-svn: 197187
2013-12-12 23:40:14 +00:00
Ted Kremenek c152c528b0 Add more test cases for 'objc_protocol_requires_explicit_implementation'.
llvm-svn: 197128
2013-12-12 06:20:42 +00:00
Fariborz Jahanian 54f87385c0 ObjectiveC. Fixes a bug where an 'unused property ivar'
warning is coming out incorrectly too early
becuase of unrelated scope pop. // rdar://15630719

llvm-svn: 196989
2013-12-11 00:53:48 +00:00
Fariborz Jahanian ddd28dc061 Objective-C. Minor change to a diagnostic.
// rdar://15499111

llvm-svn: 196977
2013-12-10 22:22:45 +00:00
Ted Kremenek f41cf7f10f Rename attribute 'objc_suppress_protocol_methods' to 'objc_protocol_requires_explicit_implementation'.
That's a mouthful, and not necessarily the final name.  This also
reflects a semantic change where this attribute is now on the
protocol itself instead of a class.  This attribute will require
that a protocol, when adopted by a class, is explicitly implemented
by the class itself (instead of walking the super class chain).

Note that this attribute is not "done".  This should be considered
a WIP.

llvm-svn: 196955
2013-12-10 19:43:48 +00:00
Fariborz Jahanian 7c04a55545 Improve on an objc_bridge_related diagnostic.
// rdar://15499111

llvm-svn: 196950
2013-12-10 19:22:41 +00:00
Fariborz Jahanian 67379e25c6 Objective-C: Improve on various diagnostics related to
use of objc_bridge_related attribute. // rdar://15499111

llvm-svn: 196828
2013-12-09 22:04:26 +00:00
Alp Toker 3cde27785b Fix three tests that weren't checking anything
Add -verify and update the test directives to match current expectations.

Also add a FIXME to an ObjC test that has expected-* directives but no -verify.

llvm-svn: 196737
2013-12-08 22:22:31 +00:00
Argyrios Kyrtzidis e818681c88 Add a SubsetSubject in Attr.td to automate checking of where the objc_designated_initializer
attribute is acceptable.

llvm-svn: 196644
2013-12-07 06:08:04 +00:00
Fariborz Jahanian 1f0b3bfd75 ObjectiveC. Continuing implementation of objc_bridge_related
attribute in sema and issuing a variety of diagnostics lazily 
for misuse of this attribute (and what to do) when converting 
from CF types to ObjectiveC types (and vice versa).
// rdar://15499111

llvm-svn: 196629
2013-12-07 00:34:23 +00:00
Fariborz Jahanian f3077a29ce ObjectiveC: Don't warn when method implemented in
category is declared in category's primary
class's super class. Because the super class is
expected to implemented the method. // rdar://15580969

llvm-svn: 196531
2013-12-05 20:52:31 +00:00
Alp Toker f6a24ce40f Fix a tranche of comment, test and doc typos
llvm-svn: 196510
2013-12-05 16:25:25 +00:00
Argyrios Kyrtzidis b9a405b33e [objc] If an interface has no initializer marked as designated and introduces at least one new initializer,
don't assume that it inherits the designated initializers from the super class.

If the assumption was wrong because a new initializer was a designated one that was not marked as such,
we will emit misleading warnings for subclasses of the interface.

llvm-svn: 196476
2013-12-05 07:07:03 +00:00
Alp Toker d473363876 Correct hyphenations in comments and assert messages
This patch tries to avoid unrelated changes other than fixing a few
hyphen-related ambiguities in nearby lines.

llvm-svn: 196466
2013-12-05 04:47:09 +00:00
Argyrios Kyrtzidis db5ce0f71e [objc] Add a warning when a class that provides a designated initializer, does not
override all of the designated initializers of its superclass.

llvm-svn: 196319
2013-12-03 21:11:54 +00:00
Argyrios Kyrtzidis b66d3cf5cf [objc] Emit warning when the implementation of a secondary initializer calls on
super another initializer and when the implementation does not delegate to
another initializer via a call on 'self'.

A secondary initializer is an initializer method not marked as a designated
initializer within a class that has at least one initializer marked as a
designated initializer.

llvm-svn: 196318
2013-12-03 21:11:49 +00:00
Argyrios Kyrtzidis fcded9b93a [objc] Emit warnings when the implementation of a designated initializer calls on
super an initializer that is not a designated one or any initializer on self.

llvm-svn: 196317
2013-12-03 21:11:43 +00:00
Argyrios Kyrtzidis 22bfa2c28b [objc] Emit a warning when the implementation of a designated initializer does not chain to
an init method that is a designated initializer for the superclass.

llvm-svn: 196316
2013-12-03 21:11:36 +00:00
Argyrios Kyrtzidis d1438b446e [objc] Introduce attribute 'objc_designated_initializer'.
It only applies to methods of init family in an interface declaration.

llvm-svn: 196314
2013-12-03 21:11:25 +00:00
Aaron Ballman 80469038c0 Enables support for custom subject lists for attributes. As a testbed, uses the custom subject for the ibaction attribute.
llvm-svn: 195960
2013-11-29 14:57:58 +00:00
Aaron Ballman f361453519 Making some attribute diagnostics more consistent. Removes a newly-unused diagnostic.
Reviewed by Fariborz Jahanian

llvm-svn: 195578
2013-11-24 20:36:50 +00:00
Ted Kremenek 7559b47fa2 Remove optional parameter bit from attribute ObjCSuppressProtocol.
This refines some diagnostics and reduces some boilerplate checking logic.

llvm-svn: 195560
2013-11-23 22:29:11 +00:00
Ted Kremenek 28eace65c0 Add back experimental attribute objc_suppress_protocol_methods (slightly renamed).
This is still an experimental attribute, but I wanted it in tree
for review.  It may still get yanked.

This attribute can only be applied to a class @interface, not
a class extension or category.  It does not change the type
system rules for Objective-C, but rather the implementation checking
for Objective-C classes that explicitly conform to a protocol.
During protocol conformance checking, clang recursively searches
up the class hierarchy for the set of methods that compose
a protocol.  This attribute will cause the compiler to not consider
the methods contributed by a super class, its categories, and those
from its ancestor classes.  Thus this attribute is used to force
subclasses to redeclare (and hopefully re-implement) methods if
they decide to explicitly conform to a protocol where some of those
methods may be provided by a super class.

This attribute intentionally leaves out properties, which are associated
with state.  This attribute only considers methods (at least right now)
that are non-property accessors.  These represent methods that "do something"
as dictated by the protocol.  This may be further refined, and this
should be considered a WIP until documentation gets written or this
gets removed.

llvm-svn: 195533
2013-11-23 01:01:34 +00:00
Fariborz Jahanian 36129a953d ObjectiveC. Remove warning diagnostic which checks
attribute on method declaration and implementation
match. This makes no sense. Most annotations are
meant for declarations only and one is for implementation.
This has been constant source of regresions and hackery to
get around special cases. I am removing this check.
Such checks must be done on a case by case basis and
when it makes sense. For example, it makes sense
for availability/deprecated and I will file a radar
for that. // rdar://15531984

llvm-svn: 195524
2013-11-23 00:14:32 +00:00
Fariborz Jahanian 2651ac5445 ObjectiveC migrator. Improve on definition, use
and testing of objc_bridgmutable attribute per
Aaron Ballman's comments.
// rdar://15498044

llvm-svn: 195396
2013-11-22 00:02:22 +00:00
Fariborz Jahanian 87c7791bb7 ObjectiveC. Implement attribute 'objc_bridge_mutable'
whose semantic is currently identical to objc_bridge,
but their differences may manifest down the road with
further enhancements. // rdar://15498044

llvm-svn: 195376
2013-11-21 20:50:32 +00:00
Ted Kremenek a14c3119ac Revert "Add new attribute 'objc_suppress_protocol' to suppress protocol conformance for a class."
After implementing this patch, a few concerns about the language
feature itself emerged in my head that I had previously not considered.
I want to resolve those design concerns first before having
a half-designed language feature in the tree.

llvm-svn: 195328
2013-11-21 07:57:53 +00:00
Ted Kremenek a4bd9a0c0e Add new attribute 'objc_suppress_protocol' to suppress protocol conformance for a class.
The idea is to allow a class to stipulate that its methods (and those
of its parents) cannot be used for protocol conformance in a subclass.
A subclass is then explicitly required to re-implement those methods
of they are present in the class marked with this attribute.

Currently the attribute can only be applied to an @interface, and
not a category or class extension.  This is by design.  Unlike
protocol conformance, where a category can add explicit conformance
of a protocol to class, this anti-conformance really needs to be
observed uniformly by all clients of the class.  That's because
the absence of the attribute implies more permissive checking of
protocol conformance.

This unfortunately required changing method lookup in ObjCInterfaceDecl
to take an optional protocol parameter.  This should not slow down
method lookup in most cases, and is just used for protocol conformance.

llvm-svn: 195323
2013-11-21 07:20:42 +00:00
Fariborz Jahanian 8c5b4be417 ObjectiveC. Allow toll free bridge cast warnings outside
ARC and in objectiveC/ObjectiveC++ MRR mode as well.
// rdar://15454846

llvm-svn: 195288
2013-11-21 00:39:36 +00:00
Fariborz Jahanian 1f92b7f7c4 ObjectiveC ARC. warn in presense of __bridge casting to
or from a toll free bridge cast. // rdar://15454846

llvm-svn: 195278
2013-11-20 22:55:41 +00:00
Fariborz Jahanian 91fb0be96a ObjectiveC ARC. Better checking of toll free briding
from qualified-id objects to CF types with 
objc_bridge annotation. // rdar://15454846

llvm-svn: 195264
2013-11-20 19:01:50 +00:00
Ted Kremenek cb42dbe7ad Refine 'deprecated' checking for Objective-C classes/methods.
- If a deprecated class refers to another deprecated class, do not warn.
- @implementations of a deprecated class can refer to other deprecated things.

Fixes <rdar://problem/15407366> and <rdar://problem/15466783>.

llvm-svn: 195259
2013-11-20 17:24:03 +00:00
Fariborz Jahanian 92ab2985da ObjectiveC ARC. validate toll free bridge casting
to or from 'id' and qualified-id types.
// rdar://15454846

llvm-svn: 195178
2013-11-20 00:32:12 +00:00
Fariborz Jahanian 3b65982b9f ObjectiveC ARC. Removes a bogus warning when a weak
property is redeclared as 'weak' in class extension.
// rdar://15465916

llvm-svn: 195146
2013-11-19 19:26:30 +00:00
Fariborz Jahanian f720f86774 bjectiveC. Use a uniform diagnostic for
'objc_bridge' attribute. // rdar://15454846.

llvm-svn: 195135
2013-11-19 17:42:25 +00:00
Aaron Ballman 2950cbb567 Giving this test a triple since it uses a calling convention attribute.
llvm-svn: 195099
2013-11-19 04:25:20 +00:00
Aaron Ballman b8f67f2de8 Improving calling convention test coverage by adding tests for things not currently handled. Specifically: the diagnostics in SemaDeclAttr.cpp, and ensuring that calling convention attributes are applied to ObjC method declarations. No functional changes.
llvm-svn: 195098
2013-11-19 04:08:34 +00:00
Fariborz Jahanian 509f31efd0 ObjectiveC 'objc_bridging'. Assorment of improvements
per Doug/Jordan comments. // rdar://15454846.

llvm-svn: 195066
2013-11-19 01:23:07 +00:00
Fariborz Jahanian db3d8554be ObjectiveC ARC. Adopt objc_bridge attribute
on struct/union/class instead of typedef of
such types. // rdar://15454846

llvm-svn: 195061
2013-11-19 00:09:48 +00:00
Fariborz Jahanian 2c31212827 ObjectiveC ARC. More validation of toll-free bridging of
CF objects with objc_bridge'ing annotaiton.
// rdar://15454846

llvm-svn: 194938
2013-11-16 23:22:37 +00:00
Fariborz Jahanian 8a0210e535 ObjectiveC ARC. Validate toll free bridge casting
of ObjectiveC objects to CF types when CF type
has the objc_bridge attribute.

llvm-svn: 194930
2013-11-16 19:16:32 +00:00
Fariborz Jahanian f07183ce94 ObjetiveC ARC. Start diagnosing invalid toll free bridging.
// rdar://15454846.

llvm-svn: 194915
2013-11-16 01:45:25 +00:00
Fariborz Jahanian b8233193a4 ObjectiveC ARC. Only briding of pointer to struct CF object is allowed.
Improve on wording on illegal objc_bridge argumment.
// rdar://15454846

llvm-svn: 194881
2013-11-15 23:14:45 +00:00
Fariborz Jahanian e79cef6ae1 ObjectiveC ARG. A positive test of my previous patch.
// rdar://15454846

llvm-svn: 194864
2013-11-15 22:33:12 +00:00
Fariborz Jahanian a649c82d69 ObjectiveC ARC. Lookup type associated with objc_bridage at
the point of CF object type-cast and issue diagnostic
if it is not a valid ObjectiveC class. // rdar//15454846.
This is wip.

llvm-svn: 194861
2013-11-15 22:18:17 +00:00
Fariborz Jahanian 617e49ad59 ObjectiveC. Fixes a bogus warning of unused backing
ivar when property belongs to a super class and
currnt class happens to have a method with same name as
property. // rdar//15473432

llvm-svn: 194830
2013-11-15 17:48:00 +00:00
Ted Kremenek 435b4c786a Revert r194663 and r194647.
Per feedback from Jordan Rose I realized this wasn't the right way to go.

llvm-svn: 194664
2013-11-14 04:44:56 +00:00
Ted Kremenek 428b61dc14 Refine -Wunused-variable to only suppress warning for __bridge_transfer, not all bridge casts.
Also refine test case to capture the intention of this suppression.  Essentially
some developers use __bridge_transfer as if it were a safe CFRelease.

llvm-svn: 194663
2013-11-14 04:27:00 +00:00
Ted Kremenek f6171b3cdf Suppress -Wunused-variable when initializer uses bridge casts for memory management.
Fixes <rdar://problem/15432770>.

llvm-svn: 194647
2013-11-14 01:42:17 +00:00
Fariborz Jahanian a0f0395b9f Use a more realistic NS class names in
objc_bridge attributes in my previous test.
Per Jordan's comment.

llvm-svn: 194645
2013-11-14 01:00:26 +00:00
Fariborz Jahanian ae02d1552f ObjectiveC ARC. objc_bridge attribute should be applied to
toll-free bridging cf types only. // rdar//15454846 wip.

llvm-svn: 194640
2013-11-14 00:43:05 +00:00
Fariborz Jahanian 0a0a39708c ObjectiveC ARC. Introduce a new attribute, 'objc_bridge'
that teaches the compiler about a subset of toll-free 
bridging semantics. This is wip. // rdar://15454846

llvm-svn: 194633
2013-11-13 23:59:17 +00:00
Fariborz Jahanian ce4bbb2532 ObjectiveC. Method implementations should only check for
"Missing call to Super" in the overriding method and
not in the method itself. // rdar://15385981.

llvm-svn: 194031
2013-11-05 00:28:21 +00:00
Fariborz Jahanian e1e33f8e82 ObjectiveC. Define a new cc1 flag
-fobjc-subscripting-legacy-runtime which is off 
by default and on only when using ObjectiveC
legacy runtime. Use this flag to allow
array and dictionary subscripting and disallow
objectiveC pointer arithmatic in ObjectiveC
legacy runtime. // rdar://15363492

llvm-svn: 193889
2013-11-01 21:58:17 +00:00
Richard Smith b1f9a283ac Factor out custom parsing for iboutletcollection and vec_type_hint attributes
into a separate "parse an attribute that takes a type argument" codepath. This
results in both codepaths being a lot cleaner and simpler, and fixes some bugs
where the type argument handling bled into the expression argument handling and
caused us to both accept invalid and reject valid attribute arguments.

llvm-svn: 193731
2013-10-31 01:56:18 +00:00
Fariborz Jahanian 7196487de9 ObjectiveC arc. Warn when an implicitly 'strong' property
is redeclared as 'weak' in class extension.
// rdar://15304886

llvm-svn: 193453
2013-10-26 00:35:39 +00:00
Fariborz Jahanian 5e3429c395 ObjectiveC: under -Wunused-property-ivar warn if property's
backing warning is not used in one of its accessor methods.
// rdar://14989999

llvm-svn: 193439
2013-10-25 21:44:50 +00:00
Fariborz Jahanian 4ba4a5b02e ObjectiveC. Added support for methods annotated with format_arg
attributes when such methods are actually envoked in message
expression. // rdar://15242010

llvm-svn: 193003
2013-10-18 21:20:34 +00:00
Ted Kremenek da2f405b09 Special case '%C' handling in ObjC format strings to handle integer literals that can represent unicode characters
Fixes <rdar://problem/13991617>.

llvm-svn: 192673
2013-10-15 05:25:17 +00:00
Ted Kremenek a553fbfcd1 GetExprRange() (used by -Wconversion checking) should look through OpaqueValueExprs.
Fixes a false positive with -Wconversion involving Objective-C properties.

Fixes <rdar://problem/14415662>.

llvm-svn: 192611
2013-10-14 18:55:27 +00:00
Serge Pavlov c0cd80fb20 Do not use typo correction that is unaccessible.
This patch fixes PR17019. When doing typo correction, Sema::CorrectTypo uses
correction already seen for the same typo. This causes problems if that
correction is from another scope and cannot be accessed in the current.

llvm-svn: 192594
2013-10-14 14:05:48 +00:00
Fariborz Jahanian 8bcf182b9d ObjectiveC. ObjectiveC's collection selector expression in
the fereach loop must be a non-const lvalue expression as
it will be assigned to at the beginning of the loop.
// rdar://15123684

llvm-svn: 192399
2013-10-10 21:58:04 +00:00
Ted Kremenek 197fee407e Refine string literal concatenation warning within an NSArray literal to not warn when the literal comes from a macro expansion. Fixes <rdar://problem/15147688>.
llvm-svn: 192328
2013-10-09 22:34:33 +00:00
Fariborz Jahanian 88ff20ef2a ObjectiveC: Warn when 'readonly' property has explicit
ownership attribute (such as 'copy', 'assign' etc.)
// rdar://15131088

llvm-svn: 192115
2013-10-07 17:20:02 +00:00
Fariborz Jahanian b809a0e280 ObjectiveC. Allow readonly properties without an explicit ownership
(assign/unsafe_unretained/weak/retain/strong/copy) in super class
to be overridden by a property with any explicit ownership in the 
subclass. // rdar://15014468

llvm-svn: 191971
2013-10-04 18:06:08 +00:00
Rafael Espindola ea1ba0adfc Replace -fobjc-default-synthesize-properties with disable-objc-default-synthesize-properties.
We want the modern behavior most of the time, so inverting the option simplifies
the driver and the tests.

llvm-svn: 191551
2013-09-27 20:21:48 +00:00
Kaelyn Uhrain 46b6cdcc9c Don't give suggest things like function names on the left side of "=".
llvm-svn: 191545
2013-09-27 19:40:16 +00:00
Fariborz Jahanian b7c5f74264 ObjectiveC: Handle the case of qualifying protocols
declared in a typedef declaraton used as super
class of an ObjC class. Curretnly, these protocols
are dropped from the class hierarchy. Test shows that
it is now included. // rdar://15051465

llvm-svn: 191395
2013-09-25 19:36:32 +00:00
Fariborz Jahanian 5c005839f6 Refinement to my previous patch for
objc_returns_inner_pointer on properties. // rdar://14990439

llvm-svn: 191016
2013-09-19 17:18:55 +00:00
Fariborz Jahanian 8a5e947454 ObjectiveC: Allow NS_RETURNS_INNER_POINTER annotation
of ObjectiveC properties to mean annotation of 
NS_RETURNS_INNER_POINTER on its synthesized getter.
This also facilitates more migration to properties when 
methods are annotated with NS_RETURNS_INNER_POINTER. 
// rdar://14990439

llvm-svn: 191009
2013-09-19 16:37:20 +00:00
Eli Friedman 4ef077a072 Fix regression from r190427.
<rdar://problem/14970968>

llvm-svn: 190635
2013-09-12 22:36:24 +00:00
Eli Friedman 5a722e92af Add self-comparison warnings for fields.
This expands very slightly what -Wtautological-compare considers to be
tautological to include implicit accesses to C++ fields and ObjC ivars.
I don't want to turn this into a full expression-identity check, but
these additions seem pretty well-contained, and maintain the theme
of checking for "x == x".

<rdar://problem/14431127>

llvm-svn: 190118
2013-09-06 03:13:09 +00:00
Aaron Ballman 5e13985df8 Improving objc_ownership attribute test coverage.
llvm-svn: 189731
2013-09-01 19:11:23 +00:00
Aaron Ballman 00e99966c4 Consolidating the notion of a GNU attribute parameter with the attribute argument list.
llvm-svn: 189711
2013-08-31 01:11:41 +00:00
Fariborz Jahanian 8181caa44e ObjectiveC [Sema]. This patch makes sure that all inherited
properties (direct or indirect) setter/getter (or declared 
methods as well) are seen by the method implementation type 
matching logic before declaration of method in super class 
is seen. This fixes the warning coming out of that method mismatch.
// rdar://14650159

llvm-svn: 188438
2013-08-14 23:58:55 +00:00
Fariborz Jahanian fde99b2e31 Refine diagnostics in my last patch.
// rdar://14303083

llvm-svn: 188335
2013-08-14 00:07:10 +00:00
Fariborz Jahanian a802c3526b ObjectiveC [QoI] issue warning if an element of an nsarray
expresison is a concatenated nsstring element.
// rdar://14303083

llvm-svn: 188332
2013-08-13 23:44:55 +00:00
Richard Smith d7293d7fcb Implement C++'s restrictions on the type of an expression passed to a vararg
function: it can't be 'void' and it can't be an initializer list. We give a
hard error for these rather than treating them as undefined behavior (we can
and probably should do the same for non-POD types in C++11, but as of this
change we don't).

Slightly rework the checking of variadic arguments in a function with a format
attribute to ensure that certain kinds of format string problem (non-literal
string, too many/too few arguments, ...) don't suppress this error.

llvm-svn: 187735
2013-08-05 18:49:43 +00:00
Fariborz Jahanian 3a25d0d593 ObjectiveC ARC: finishing off issuing error when
retainable pointer is passed to an audited CF function
expecting CF type. // rdar://14569171

llvm-svn: 187543
2013-07-31 23:19:34 +00:00
Aaron Ballman 3bf758cd65 err_attribute_not_string has been subsumed by err_attribute_argument_type.
llvm-svn: 187400
2013-07-30 01:31:03 +00:00
Aaron Ballman b7243381c2 Added the attribute name to the err_attribute_wrong_number_arguments diagnostic for clarity; updated almost all of the affected test cases.
Thanks to Fariborz Jahanian for the suggestion!

llvm-svn: 186980
2013-07-23 19:30:11 +00:00
Aaron Ballman 086e428b5b Going back to using getName for consistency.
llvm-svn: 186966
2013-07-23 17:35:26 +00:00
Aaron Ballman b06c690c5d Fixing the build bots from the previous commit.
llvm-svn: 186947
2013-07-23 15:21:34 +00:00
Aaron Ballman 283ef4234c Replacing some manual diagnostic checks with an existing helper method. Adding missing test cases for the diagnostics.
llvm-svn: 186944
2013-07-23 15:16:00 +00:00
Aaron Ballman 7ced167a09 Correcting the NSObject and Overloadable attribute diagnostics so that the count reported matches reality.
llvm-svn: 186936
2013-07-23 12:13:14 +00:00
Eli Friedman 75807f239e Make IgnoreParens() look through ChooseExprs.
This is the same way GenericSelectionExpr works, and it's generally a
more consistent approach.

A large part of this patch is devoted to caching the value of the condition
of a ChooseExpr; it's needed to avoid threading an ASTContext into
IgnoreParens().

Fixes <rdar://problem/14438917>.

llvm-svn: 186738
2013-07-20 00:40:58 +00:00
Jean-Daniel Dupas 06028a5454 Fix another place where clang check objc selector name instead of checking the selector family
Summary: In ARC mode, clang emits a warning if the result of an 'init' method is unused but miss cases where the method does not follows the Cocoa naming convention but is properly declared as an init family method.

CC: cfe-commits, eli.friedman

Differential Revision: http://llvm-reviews.chandlerc.com/D1163

llvm-svn: 186718
2013-07-19 20:25:56 +00:00
Aaron Ballman f90ccb082b Replacing a morally duplicate diagnostic by adding it to an existing diagnostic's select list. Updates the tests for the more consistent diagnostic.
llvm-svn: 186584
2013-07-18 14:56:42 +00:00
Jean-Daniel Dupas 3965574929 Improve idiomatic-parentheses by checking method family instead of relying on the selector name.
llvm-svn: 186524
2013-07-17 18:17:14 +00:00
Fariborz Jahanian 14e9541916 Restore warning to its original text when
certain familiy of methods have the wrong type.
// rdar://14408244

llvm-svn: 186111
2013-07-11 19:13:34 +00:00
Fariborz Jahanian b248ca5548 ObjectiveC arc[qoi]: When due to change of certain methods'
result type, a diagnostic being issued, issue a 'note' 
mentioning reason behind the unexpected warning.
// rdar://14121570.

llvm-svn: 186105
2013-07-11 16:48:06 +00:00
Fariborz Jahanian db4fc28145 Objective-C: merge objc_requires_super attribute of
method declaration into its implementation to
prevent a bogus warning about mismatched attributes.
then make sure the warning about missing call to super comes out
of the method implementation. // rdar://14251387

llvm-svn: 185974
2013-07-09 22:02:20 +00:00
Fariborz Jahanian ae26bb67f8 Objective-C: Warn when fast enumeration variable isn't used.
// rdar://14182680.

llvm-svn: 185762
2013-07-06 18:04:13 +00:00
Rafael Espindola 925213b0fa Add 'not' to commands that are expected to fail.
This is at least good documentation, but also opens the possibility of
using pipefail.

llvm-svn: 185652
2013-07-04 16:16:58 +00:00
Fariborz Jahanian e23f26bf94 ObjectiveC: diagnose duplicate declaration of
private ivars in class extensions and class
@implementation. // rdar://14278560

llvm-svn: 185025
2013-06-26 22:10:27 +00:00
Fariborz Jahanian f030d16c92 Objective-C: Warn when IBOutletCollection property
is declared to have 'assign' attribute.
// rdar://14212998

llvm-svn: 184863
2013-06-25 17:34:50 +00:00
Ted Kremenek 009d61dd16 Tweak -Wdeprecated-objc-pointer-introspection to have a subgroup for results of using -performSelectorXXX.
-performSelector: and friends return a value that is boxed as an Objective-C
pointer.  Sometimes it is an Objective-C pointer, sometimes it isn't.
Some clients may wish to silence this warning based on calling
this method.

Fixes <rdar://problem/14147304>

llvm-svn: 184789
2013-06-24 21:35:39 +00:00
Reid Kleckner 5a11580205 [Sema] Call CheckParmForFunctionDef on ObjC method parameters
CheckParmForFunctionDef performs standard checks for type completeness
and other things like a destructor check for the MSVC++ ABI.

llvm-svn: 184740
2013-06-24 14:38:26 +00:00
Eli Friedman 81e4e4e5cc Add test.
llvm-svn: 184519
2013-06-21 02:09:51 +00:00
Enea Zaffanella a86d88c7cd Improved source code fidelity for gcc mode attribute.
llvm-svn: 184417
2013-06-20 12:46:19 +00:00
Fariborz Jahanian 0649923b57 Objective-C: Fixes a typo correction bug where a
selector would be correted to identical selector name
in certain corner cases. // rdar://7853549

llvm-svn: 184208
2013-06-18 17:10:58 +00:00
Fariborz Jahanian 9917fcad11 Fix buildbot failure.
llvm-svn: 184199
2013-06-18 15:54:30 +00:00
Fariborz Jahanian 4cc5552b9b Objective-C [qoi]: privide typo correction for selectors
in addition of receiver having static type, but also when
receiver has dynamic type (of 'id' variety) as well as when
receiver is of 'Class' type vareity. // rdar://7853549

llvm-svn: 184195
2013-06-18 15:31:36 +00:00
Fariborz Jahanian aaddc09b39 unbreak buildbot for now.
llvm-svn: 184093
2013-06-17 17:41:13 +00:00
Fariborz Jahanian 7548167845 Objective-C [qoi]: Provide fixit hint when message with typo
is sent to a receiver object. This is wip. // rdar://7853549

llvm-svn: 184086
2013-06-17 17:10:54 +00:00
Eli Friedman 31a5bcc24e Unify return type checking for functions and ObjC methods. Move all the
random checks for ObjC object return types to SemaType.cpp.

Fixes issue with ObjC method type checking reported on cfe-dev.

llvm-svn: 184006
2013-06-14 21:14:10 +00:00
Fariborz Jahanian bbc126e7df Objective-C: Another case of issuing warning about misusing
property auto-synthesis before knowingit it is to be
auto-synthesized. // rdar://14094682

llvm-svn: 183556
2013-06-07 20:26:51 +00:00
Fariborz Jahanian 4614524d4a Objective-C: Removes a bogus warning about auto-synthesis
of properties. Fixes // rdar://14085456

llvm-svn: 183542
2013-06-07 18:32:55 +00:00
Fariborz Jahanian deac9ac546 Objective-C: Fixes an ivar lookup bug where
'ivar' was used inside a record/union used 
as argument to __typeof. // rdar14037151 pr5984

llvm-svn: 183048
2013-05-31 21:51:12 +00:00