Commit Graph

283 Commits

Author SHA1 Message Date
Fariborz Jahanian
4732d43cc2 Objective-C SDK modernizer to use NS_ENUM/NS_OPTIONS macros
with typed enums. rdar://19352510

llvm-svn: 227104
2015-01-26 17:41:03 +00:00
Fariborz Jahanian
f9317f1586 Objective-C moderinzer [qoi], add space on rhs when needed when
converting to property-dot syntax for setters.
rdar://19381786

llvm-svn: 226944
2015-01-23 21:58:46 +00:00
Fariborz Jahanian
30609b8a78 Objective-C modernizer. Avoid using property-dot syntax when
receiver type is not valid for property-dot syntz use.
rdar://19381786

llvm-svn: 226927
2015-01-23 19:23:42 +00:00
Jordan Rose
16ba553f75 ObjC getters with names like "newItem" should still be linked to the @property.
Two years ago I added a compile-time "optimization" to
ObjCMethodDecl::findPropertyDecl: exit early if the current method is part
of a special Objective-C method family (like 'new' or 'init'). However, if a
property (declared with @property) has a name that matches a method family,
the getter picks up that family despite being declared by the property. The
early exit then made ObjCMethodDecl::findPropertyDecl decide that there
was no associated property, despite the method itself being marked as an
accessor. This corrects that by removing the early exit.

This does /not/ change the fact that such a getter is considered to return a
value with a +1 retain count. The best way to eliminate this is by adding the
objc_method_family(none) attribute to the getter, but unlike the existing
ns_returns_not_retained that can't be applied directly to the property -- you
have to redeclare the getter instead.

(It'd be nice if @property just implied objc_method_family(none) for its
getter, but that would be a backwards-incompatible change.)

rdar://problem/19038838

llvm-svn: 226338
2015-01-16 23:04:26 +00:00
Fariborz Jahanian
1406c878cb Objective-C SDK modernizer. When modernizing an enum to
NS_ENUM/NS_OPTIONS use the underlying type if there is 
no associated type. rdar://19198042

llvm-svn: 223934
2014-12-10 18:25:24 +00:00
Fariborz Jahanian
df833a4918 Objective-C SDK modernizer. Modernize to use
property-dot-syntax when receiver is 'super'. 
rdar://19140267

llvm-svn: 223846
2014-12-09 22:36:47 +00:00
Fariborz Jahanian
c62d16f304 Objective-C. Fixes a regression caused by implementation
of new warning for deprecated method call for receiver
of type 'id'. This addresses rdar://18960378 where
unintended warnings being issued.

llvm-svn: 221933
2014-11-13 22:27:05 +00:00
Fariborz Jahanian
05e77f8349 [Objective-C Sema]. Issue availability/deprecated warning when
there is a uinque method found when message is sent to receiver 
of 'id' type. // rdar://18848183

llvm-svn: 221562
2014-11-07 23:51:15 +00:00
Fariborz Jahanian
a6556f7295 Objective-C SDK modernization tool. Use its own option
,-objcmt-migrate-property-dot-syntax, when migarting to use
property-dot syntax in place of messaging expression.
rdar://18839124

llvm-svn: 221001
2014-10-31 21:19:45 +00:00
Fariborz Jahanian
d2241bf561 Objective-C SDK modernization. import Foundation even
when a previous definition of NS_OPTION is available
; e.g. from a pch. enhancement to rdar://18498550

llvm-svn: 219448
2014-10-09 22:04:27 +00:00
Fariborz Jahanian
ed6de56c77 Objective-C SDK modernization. convert message expression
to Objective-C dot-syntax. rdar://18498572

llvm-svn: 219424
2014-10-09 18:30:56 +00:00
Fariborz Jahanian
80ebf8da7e Objective-C SDK modernization. When modernizing to
use NS_ENUM/NS_OPTIONS macros, add an import of
Foundation.h (or its module) as necessary.
rdar://18498550

llvm-svn: 219225
2014-10-07 19:01:46 +00:00
Fariborz Jahanian
35ee87debe Objective-C SDK modernizer. Patch to support modernization
to NS_ENUM/NS_OPTION macros when typedef names are other
than NSInteger/NSUInteger (int8_t, etc.).
rdar://18532199

llvm-svn: 219173
2014-10-06 23:50:37 +00:00
Fariborz Jahanian
77a835bf56 Objective-C Modernizer. Patch to remove dangling space
before the semicolon wahen modernizing to use 
NS_ENUM/NS_OPTIONS macros. rdar://18498539

llvm-svn: 218809
2014-10-01 20:46:32 +00:00
Fariborz Jahanian
18625ee75c Objective-C SDK modernizer. Do not modernize an enum
which already has the underlying interger type specification.
// rdar://1826225

llvm-svn: 217783
2014-09-15 16:41:47 +00:00
Richard Smith
091405d7e3 Reword switch/goto diagnostics "protected scope" diagnostics. Making up a term
"protected scope" is very unhelpful here and actively confuses users. Instead,
simply state the nature of the problem in the diagnostic: we cannot jump from
here to there. The notes explain nicely why not.

llvm-svn: 217293
2014-09-06 00:24:58 +00:00
Fariborz Jahanian
be7bf7285b Objective-C modernization. Convert -initWithUTF8String messaging
with auto-boxing syntax for literals. rdar://18080352

llvm-svn: 216405
2014-08-25 20:22:25 +00:00
Jordan Rose
e3f310f3bd [analyzer] Check for NULL passed to CFAutorelease.
Patch by Sean McBride, tests adjusted by me.

llvm-svn: 211453
2014-06-21 23:50:40 +00:00
Fariborz Jahanian
1ad83a35b1 Objective-C. Revert my patch in r211234.
llvm-svn: 211237
2014-06-18 23:22:38 +00:00
Fariborz Jahanian
62aeb8b653 Objective-C ARC. Allow conversion of (void*) pointers to
retainable ObjC pointers without requiring a bridge-cast
by recognizing this as a +0 context. // rdar://16627903

llvm-svn: 211234
2014-06-18 22:50:40 +00:00
Argyrios Kyrtzidis
c02a0dbe41 [objcmt] Make sure we don't edit the return type to add 'instancetype' if the return type is already that.
rdar://16961577

llvm-svn: 209264
2014-05-21 00:24:20 +00:00
Alp Toker
57cccec446 ARCMT/GC-check-warn-nsalloc.m: don't provide a diag group
This diagnostic is now controlled solely by -no-ns-alloc-error thus matching
the original intended behaviour.

llvm-svn: 209184
2014-05-19 23:48:49 +00:00
Alp Toker
97b084f528 Improve test verification from r209172
llvm-svn: 209175
2014-05-19 22:56:13 +00:00
Alp Toker
403a4f9b82 Get ARCMT/GC-check-warn-nsalloc.m working
The -no-ns-alloc-error migration option now causes the diagnostic to be ignored
completely. If this isn't desired, the error can be downgraded to a warning
using the usual -Wno-error=arcmt-ns-alloc.

Note that we can't use -verify right now on this test because
VerifyDiagnosticConsumer gets confused by multiple SourceManager instances,
which is presumably the reason it was XFAILed in the first place and why the
regression wasn't detected. We'll grep instead for now.

llvm-svn: 209172
2014-05-19 22:51:11 +00:00
Manuel Klimek
fcfc213c3f Make the ARCMT tests self-contained.
This is necessary to reduce staging times on parallel build systems.

llvm-svn: 209120
2014-05-19 11:51:44 +00:00
Argyrios Kyrtzidis
d4d5534034 [objcmt] Don't wrap a PCH generation action with a ObjCMigrateAction one, it messes up the PCH file.
rdar://16941811

llvm-svn: 209059
2014-05-17 04:35:12 +00:00
Richard Smith
6fa28ffd5a Fix "regression" caused by updating our notion of POD to better match the C++11
rules: instead of requiring flexible array members to be POD, require them to
be trivially-destructible. This seems to be the only constraint that actually
matters here (and even then, it's questionable whether this matters).

llvm-svn: 198983
2014-01-11 00:53:35 +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
769c04ea35 ObjectiveC migrator. Fixes a bug when protocol
conformance is inferred. // rdar://15515206

llvm-svn: 197448
2013-12-17 01:01:33 +00:00
Hans Wennborg
bf6dda5116 Re-apply r197076 and r197086; the build was fixed by chapuni in r197114.
llvm-svn: 197116
2013-12-12 02:24:20 +00:00
Hans Wennborg
69a458f690 Revert r197076: "[objcmt] When emitting a remap file, use a json format
with the edit entries, instead of applying the changes"

(And also revert the follow-up r197086.)

This seems to have broken Linux builds, which were failing with the following:

/build/buildbot/osu8/clang-x86_64-linux-selfhost-rel/llvm.obj/Release+Asserts/lib/libclang.so:
error: undefined reference to
'clang::ento::objc_retain::CallEffects::getEffect(clang::ObjCMethodDecl const*)'
/build/buildbot/osu8/clang-x86_64-linux-selfhost-rel/llvm.obj/Release+Asserts/lib/libclang.so:
error: undefined reference to
'clang::ento::objc_retain::CallEffects::getEffect(clang::FunctionDecl const*)'
collect2: error: ld returned 1 exit status

llvm-svn: 197111
2013-12-12 02:12:17 +00:00
Fariborz Jahanian
49e69ee557 Objective-C migrator: when inferring 'readonly' property of an
Objective-C object conforming to 'NSCopying' protocol, infer
a 'copy' property, instead of 'strong'. // rdar://15525937

llvm-svn: 197102
2013-12-12 01:02:00 +00:00
Argyrios Kyrtzidis
712e18a0c1 [objcmt] When emitting a remap file, use a json format with the edit entries, instead of applying the changes
to a temp file directly.

This allows to combine the edits when they can be different based on whether you saw
the implementation or not, e.g. with the designated initializer migration.

llvm-svn: 197076
2013-12-11 21:39:06 +00:00
Argyrios Kyrtzidis
3f72934bba [objcmt] When whitelisting the headers we want to modify, allow changing the
the ObjC implementation declarations, just don't change implementations for
classes that are not in the whitelisted headers.

For example, if we change a method to return 'instancetype' we should also
update the method definition in the implementation.

llvm-svn: 197075
2013-12-11 21:39:00 +00:00
Argyrios Kyrtzidis
4f2ecc6177 [objcmt] Add a modernization option to infer and suggest designated initializers.
rdar://15509284

llvm-svn: 196943
2013-12-10 18:36:49 +00:00
Alp Toker
5a60686cf9 Remove all DISABLE lines from tests
There's no evidence that a 'DISABLE' directive ever existed.

Let's see if anything breaks..

llvm-svn: 196733
2013-12-08 21:12:19 +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
Fariborz Jahanian
d9aef7883d ObjectiveC migrator. delegate property must be
inferred as 'assign', not 'assign' and 'strong'.
// rdar://15509831

llvm-svn: 195368
2013-11-21 17:49:34 +00:00
Fariborz Jahanian
54c8eaad90 ObjectiveC migrator. use strong instead of
retain attribute for inferred properties.
// rdar://15519923

llvm-svn: 195292
2013-11-21 00:58:17 +00:00
Fariborz Jahanian
48a44d4621 ObjectiveC migrator. Do not migrate categories with
'Deprecated' name suffix.

llvm-svn: 195137
2013-11-19 18:17:31 +00:00
Fariborz Jahanian
da267d0551 ObjectiveC migrator: This patch sets access property
attributes on 'readonly' properties. // rdar://15460787

llvm-svn: 194718
2013-11-14 18:28:58 +00:00
Argyrios Kyrtzidis
61f2032d3b [objcmt] Introduce "objcmt-white-list-dir-path=" option.
This options accepts a path to a directory, collects the filenames of the files
it contains, and the migrator will only modify files with the same filename.

llvm-svn: 194710
2013-11-14 16:33:29 +00:00
Fariborz Jahanian
2e793d6124 ObjectiveC migrator. Place use of NS_NONATOMIC_IOSONLY
on inferred property attribute under
 -objcmt-ns-nonatomic-iosonly  option.
// rdar://15442742

llvm-svn: 194532
2013-11-13 00:08:36 +00:00
Fariborz Jahanian
bed1be926d ObjectiveC migrator. Another alternative to
"atomic" or "nonatomic" for properties is
NS_NONATOMIC_IOSONLY. Use it if available.
// rdar://15442742

llvm-svn: 194503
2013-11-12 19:25:50 +00:00
Fariborz Jahanian
b89e172ab6 ObjectiveC migrator. More testing of instancetype migration in
method implementations. // rdar://15438505

llvm-svn: 194402
2013-11-11 18:54:23 +00:00
Fariborz Jahanian
ec7cea925e ObjectiveC migrator. Fixes an obscure bug where
NS_RETURNS_INNER_POINTER ends up unintentionally 
on the @property under -objcmt-migrate-all 
// rdar://15396636

llvm-svn: 194233
2013-11-08 01:15:17 +00:00
Fariborz Jahanian
23417073ee ObjectiveC migrator. Please annotation of properties with
NS_RETURNS_INNER_POINTER under -objcmt-returns-innerpointer-property
flag (off by default), as older compilers do not support such annotations.
// rdar://15396636

llvm-svn: 194100
2013-11-05 22:28:30 +00:00
Fariborz Jahanian
071b98edec ObjectiveC migrator. When inferring readwrite property,
do not remove the setter if its availability differs
from availability of the getter (which is now turned into
a property). Otherwise, synthesized setter will
inherit availability of the property (which is incorrect).
// rdar://15300059

llvm-svn: 193837
2013-11-01 00:26:48 +00:00
Fariborz Jahanian
d41dbadacd ObjectiveC migrator. Change naming hueristic for
deprecated categories, fixes a typo reported by
Jordan.

llvm-svn: 193759
2013-10-31 16:10:44 +00:00
Fariborz Jahanian
9d2ffea486 ObjectiveC migrator: annotate all protocols/methods in
a category with NSxxxDeprecated name with deprecated
annotation. // rdar://15337661

llvm-svn: 193726
2013-10-31 00:06:58 +00:00