Jordan Rose
d49a33e86c
Disallow using ObjC literals in direct comparisons (== and friends).
...
Objective-C literals conceptually always create new objects, but may be
optimized by the compiler or runtime (constant folding, singletons, etc).
Comparing addresses of these objects is relying on this optimization
behavior, which is really an implementation detail.
In the case of == and !=, offer a fixit to a call to -isEqual:, if the
method is available. This fixit is directly on the error so that it is
automatically applied.
Most of the time, this is really a newbie mistake, hence the fixit.
llvm-svn: 158230
2012-06-08 21:14:25 +00:00
Jordan Rose
288c421b3d
Insert a space if necessary when suggesting CFBridgingRetain/Release.
...
This was a problem for people who write 'return(result);'
Also fix ARCMT's corresponding code, though there's no test case for this
because implicit casts like this are rejected by the migrator for being
ambiguous, and explicit casts have no problem.
<rdar://problem/11577346>
llvm-svn: 158130
2012-06-07 01:10:31 +00:00
Argyrios Kyrtzidis
4e633b56c0
Fix test/SemaObjC/cocoa-api-usage.m that broke via r158114.
...
llvm-svn: 158115
2012-06-06 22:32:07 +00:00
Fariborz Jahanian
3da28f80e3
objective-c: merge deprecated/unavailable attributes to
...
the overriding deprecated/unavailable method.
// rdar://11475360
llvm-svn: 158022
2012-06-05 21:14:46 +00:00
Jordan Rose
97c6f2b9e5
Teach format string checking about compile-time CFString constants.
...
Within the guts of CheckFormatHandler, the IsObjCLiteral flag was being used in
two ways: to see if null bytes were allowed, and to see if the '%@' specifier
is allowed.* The former usage has been changed to an explicit test and the
latter pushed down to CheckPrintfHandler and renamed ObjCContext, since it
applies to CFStrings as well.
* This also changes how wide chars are interpreted; in OS X Foundation, the
wide character type is 'unichar', a typedef for short, rather than wchar_t.
llvm-svn: 157968
2012-06-04 23:52:23 +00:00
Fariborz Jahanian
22535def43
objective-c: Handle more warning cases for when
...
message receiver is 'weak' property.
// rdar://10225276
llvm-svn: 157946
2012-06-04 19:16:34 +00:00
Fariborz Jahanian
bebd0ba549
objc: properties of NSObject attribute must
...
have correct pointer type or issue error,
instead of crashing in IRGen. // rdar:// 11569860
llvm-svn: 157780
2012-05-31 23:18:32 +00:00
Fariborz Jahanian
a1d29cd471
objective-c: revert r157407. It broke a project
...
and reported as PR12959. // rdar://11499742
llvm-svn: 157697
2012-05-30 17:33:54 +00:00
Fariborz Jahanian
836914c0aa
fixes radar no. in this test.
...
llvm-svn: 157642
2012-05-29 19:59:25 +00:00
Fariborz Jahanian
b5dd2cb13c
objective-c: fix a sema and IRGen crash when property
...
getter result type is safe but does not match with property
type resulting in spurious warning followed by crash in
IRGen. // rdar://11515196
llvm-svn: 157641
2012-05-29 19:56:01 +00:00
Fariborz Jahanian
f021889036
-Wdeprecated warning to include reference (as a note)
...
to the declaration in this patch. // rdar://10893232
llvm-svn: 157537
2012-05-27 16:59:48 +00:00
Fariborz Jahanian
f3b7681f2b
Change warning to error when property setter names conflict.
...
// rdar://11528439
llvm-svn: 157517
2012-05-26 16:10:06 +00:00
Fariborz Jahanian
3f88afad2f
objective-c: warn on use of property setters
...
backing two propeties because proprty names
match except for first letter being of different
case. // rdar://11528439, [PR12936].
llvm-svn: 157435
2012-05-24 22:48:38 +00:00
Fariborz Jahanian
246f519a51
objective-c: Fixes a corner case and interesting bug.
...
Where diagnostic about unfound property is not
issued in the context where a setter is looked up
in situation in which name and property name differ
in their first letter case. // rdar://11363363
llvm-svn: 157407
2012-05-24 18:29:41 +00:00
Fariborz Jahanian
870265636c
objc: change option to be -Wobjc-interface-ivars
...
llvm-svn: 157394
2012-05-24 16:19:51 +00:00
Fariborz Jahanian
b52d8d2e5f
objective-c: When default synthesizing readonly IBOutlet properties
...
provide a 'fixit' to change 'readonly' to 'readwrite'. // rdar://11448209
llvm-svn: 157193
2012-05-21 17:02:43 +00:00
Fariborz Jahanian
199a9b57a6
objective-c: Warn if default synthesizing readonly IBOutlet properties
...
and provide a 'fixit' to change 'readonly' to 'readwrite'. 'fixit'
part needs little more work. // rdar://11448209
llvm-svn: 157121
2012-05-19 18:17:17 +00:00
Fariborz Jahanian
d945ce5fb7
objc: use "class extension" instead of "continuation class"
...
to match documentation. // rdar://11309706
llvm-svn: 157074
2012-05-18 21:22:49 +00:00
Fariborz Jahanian
b4bef15ae6
Another test for r157025 <rdar://problem/11460990>.
...
llvm-svn: 157034
2012-05-18 00:19:25 +00:00
Douglas Gregor
0bf70f4be8
A selector match between two Objective-C methods does *not* guarantee
...
that the methods have the same number of parameters, although we
certainly assumed this in many places. Objective-C can be insane
sometimes. Fixes <rdar://problem/11460990>.
llvm-svn: 157025
2012-05-17 23:13:29 +00:00
Douglas Gregor
c5928afb69
In the override search for Objective-C methods, protect against ASTs that have NULL interfaces behind a category, which can happen in invalid code. Fixes <rdar://problem/11478173>, a recent regression
...
llvm-svn: 157021
2012-05-17 22:39:14 +00:00
Fariborz Jahanian
0ebc0fa974
objective-c: perform strict type checking on property
...
type and its accessor type and issue error if types
are incompatible, instead of crashing in IRgen.
// rdar://1105153
llvm-svn: 156871
2012-05-15 22:37:04 +00:00
Argyrios Kyrtzidis
8e6951d81b
Allow objc @() syntax for enum types.
...
Previously we would reject it as illegal using a value of
enum type and on ObjC++ it was illegal to use an enumerator
as well.
rdar://11454917
llvm-svn: 156843
2012-05-15 19:17:44 +00:00
Fariborz Jahanian
3da7775a6d
objc: avoid duplicate diagnostics on certain type mismatches
...
between property and its backing ivar.
llvm-svn: 156832
2012-05-15 18:12:51 +00:00
Fariborz Jahanian
e1ada58ef4
Remove word 'block' from option and diagnostic I added
...
in r156825.
llvm-svn: 156831
2012-05-15 17:43:16 +00:00
Fariborz Jahanian
80297b1d90
objective-c nonfragile abi: discourage ivar declarations
...
in @interface by issuing warning (off by default) under
opt'ed in flag -Winterface-block-ivar. // rdar://10763173
llvm-svn: 156825
2012-05-15 16:33:04 +00:00
Fariborz Jahanian
16d71bb834
objc: allow typedef'ing an id to a pointer to a c-struct only.
...
// rdar://11356439
llvm-svn: 156788
2012-05-14 22:48:56 +00:00
Jordy Rose
4af4487ba4
Only check NSArray/NSDictionary boxing method params once.
...
Once we've found a "good" method, we don't need to check its argument types
again. (Even if we might have later found a "bad" method, we were already
caching the method we first looked up.)
llvm-svn: 156719
2012-05-12 17:32:56 +00:00
Jordy Rose
890f4577b1
Don't crash on boxed strings when +stringWithUTF8String: is missing.
...
Also, unify some diagnostics for boxed expressions that have the same form.
Fixes PR12804.
llvm-svn: 156713
2012-05-12 15:53:41 +00:00
Argyrios Kyrtzidis
9b4fe35689
Don't crash when using objc boxed expression with parsing error.
...
rdar://11426994
llvm-svn: 156565
2012-05-10 20:02:36 +00:00
John McCall
0bd3e404af
Bind cleanups after doing l2r conversion on the operand of a
...
@throw expression; l2r conversion can introduce new cleanups
in certain cases, like when the expression is an ObjC property
reference of retainable type in ARC.
llvm-svn: 156425
2012-05-08 21:41:25 +00:00
Jean-Daniel Dupas
2b7da83759
Inhibit ObjC format warning only in system headers (NSLocalizedString).
...
Add a test case for the related NSAssert workaround.
llvm-svn: 156205
2012-05-04 21:08:08 +00:00
Fariborz Jahanian
d5f34f9fee
objective-c: warn for properties being default synthesized
...
under -Wobjc-missing-property-synthesis which must be
opted-in. // rdar://11295716
llvm-svn: 156078
2012-05-03 16:43:30 +00:00
Eli Friedman
169ec35bb3
Add a missing RequireCompleteType call when synthesizing properties. <rdar://problem/11333367>.
...
While I'm here, fix source locations for other diagnostics related to property synthesis.
llvm-svn: 155953
2012-05-01 22:26:06 +00:00
David Blaikie
afd3d0ba40
Fix test cases broken by 155936.
...
llvm-svn: 155948
2012-05-01 21:29:03 +00:00
Ted Kremenek
124066c5cb
Place several uncovered warnings under warning flags, and tweak diagnostic output including the term "gc" (in lowercase).
...
llvm-svn: 155892
2012-05-01 05:56:02 +00:00
Fariborz Jahanian
08a1eb77c5
with -Wdeprecated, include a note to its deprecated declaration
...
location. // rdar://10893232
llvm-svn: 155385
2012-04-23 20:30:52 +00:00
Fariborz Jahanian
344d65c248
objective-c arc: With currnt documentation,
...
objc_returns_inner_pointer attribute can be applied to
methods only. Diagnsose otherwise, instead of
crashing. // rdar://11253688
llvm-svn: 155245
2012-04-20 22:00:46 +00:00
Fariborz Jahanian
d155c78d18
objective-arc: Retune my previous patch so warning
...
is issued on weak property as receiver and not on
any other use of a weak property. // rdar://10225276
llvm-svn: 155169
2012-04-19 23:49:39 +00:00
Fariborz Jahanian
fce89c609d
objective-c arc: Issue warning under -Wreceiver-is-weak
...
if receiver is a 'weak' property, by type or by attribute.
// rdar://10225276
llvm-svn: 155159
2012-04-19 21:44:57 +00:00
Patrick Beard
0caa39474b
Implements boxed expressions for Objective-C. <rdar://problem/10194391>
...
llvm-svn: 155082
2012-04-19 00:25:12 +00:00
Fariborz Jahanian
b525b52987
objective-c: Issue diagnostic when an implicit
...
property accessor (getter) missing, instead of crashing.
// rdar://11273060
llvm-svn: 155036
2012-04-18 19:13:23 +00:00
Fariborz Jahanian
29898f4565
objective-c modern translator: buildit objc bool
...
type for rewriter project will be BoolTy.
// rdar://11231426.
llvm-svn: 154861
2012-04-16 21:03:30 +00:00
John McCall
d239387098
When we're flagging a protected scope to prevent jumps into the
...
shadow of a block expression with non-trivial destructed cleanups,
we should flag that in the enclosing function, not in the block
that we're about to pop.
llvm-svn: 154646
2012-04-13 01:08:17 +00:00
Fariborz Jahanian
e2b037d6ea
objective-c literals: Issue warning and ignore
...
when BOOL is not of an intergal type when
boolean literals are used. // rdar://11231426
llvm-svn: 154619
2012-04-12 21:24:56 +00:00
Patrick Beard
acfbe9e1f2
Added a new attribute, objc_root_class, which informs the compiler when a root class is intentionally declared.
...
The warning this inhibits, -Wobjc-root-class, is opt-in for now. However, all clang unit tests that would trigger
the warning have been updated to use -Wno-objc-root-class. <rdar://problem/7446698>
llvm-svn: 154187
2012-04-06 18:12:22 +00:00
Fariborz Jahanian
c806b90717
objective-c: Don't warn when a category does not implement a method
...
declared in its adopted protocol when another category declares it
because that category will implement it. // rdar://11186449
llvm-svn: 154132
2012-04-05 22:14:12 +00:00
Fariborz Jahanian
6bd2226037
objc-arc: provide a warning when 'receiver' of a message is 'weak'
...
in arc mode and opted-in with -Wreceiver-is-weak flag.
// rdar://10225276
llvm-svn: 154042
2012-04-04 20:05:25 +00:00
John McCall
bc15335e58
Handle placeholder expressions in an ObjC for-collection loop.
...
The way we handle this implicitly removes the ability to use
property l-values in this position, but that's really okay.
llvm-svn: 153729
2012-03-30 05:43:39 +00:00
John McCall
67cd5e094e
Forbid the block and lambda copy-capture of __autoreleasing variables
...
in ARC, under the usual reasoning limiting the use of __autoreleasing.
llvm-svn: 153725
2012-03-30 05:23:48 +00:00