summaryrefslogtreecommitdiffstats
path: root/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Fix clang -Wimplicit-fallthrough warnings across llvm, NFCReid Kleckner2018-11-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch should not introduce any behavior changes. It consists of mostly one of two changes: 1. Replacing fall through comments with the LLVM_FALLTHROUGH macro 2. Inserting 'break' before falling through into a case block consisting of only 'break'. We were already using this warning with GCC, but its warning behaves slightly differently. In this patch, the following differences are relevant: 1. GCC recognizes comments that say "fall through" as annotations, clang doesn't 2. GCC doesn't warn on "case N: foo(); default: break;", clang does 3. GCC doesn't warn when the case contains a switch, but falls through the outer case. I will enable the warning separately in a follow-up patch so that it can be cleanly reverted if necessary. Reviewers: alexfh, rsmith, lattner, rtrieu, EricWF, bollu Differential Revision: https://reviews.llvm.org/D53950 llvm-svn: 345882
* Create ConstantExpr classBill Wendling2018-10-311-3/+3
| | | | | | | | | | | | | | | | A ConstantExpr class represents a full expression that's in a context where a constant expression is required. This class reflects the path the evaluator took to reach the expression rather than the syntactic context in which the expression occurs. In the future, the class will be expanded to cache the result of the evaluated expression so that it's not needlessly re-evaluated Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D53475 llvm-svn: 345692
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-6/+9
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* Remove trailing spaceFangrui Song2018-07-301-2/+2
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-2/+2
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova2017-06-031-0/+1
| | | | llvm-svn: 304640
* Refactor: Simplify boolean conditional return statements in lib/ARCMigrateAlexander Kornienko2015-11-061-15/+5
| | | | | | | | Patch by Richard Thomson! (+a couple of modifications to address comments) Differential revision: http://reviews.llvm.org/D10009 llvm-svn: 252261
* [AST] Remove StmtRange in favor of an iterator_range.Benjamin Kramer2015-07-181-4/+4
| | | | | | | | | StmtRange was just a convenient wrapper for two StmtIterators before we had real range support. This removes some of the implicit conversions StmtRange had leading to slightly more verbose code but also should make more obvious what's going on. No functional change intended. llvm-svn: 242615
* [modules] Stop trying to fake up a linear MacroDirective history.Richard Smith2015-04-291-1/+1
| | | | | | | | | | | | | | Modules builds fundamentally have a non-linear macro history. In the interest of better source fidelity, represent the macro definition information faithfully: we have a linear macro directive history within each module, and at any point we have a unique "latest" local macro directive and a collection of visible imported directives. This also removes the attendent complexity of attempting to create a correct MacroDirective history (which we got wrong in the general case). No functionality change intended. llvm-svn: 236176
* Clean up language and grammar.Eric Christopher2014-05-201-1/+1
| | | | | | | Based on a patch by jfcaron3@gmail.com! PR19806 llvm-svn: 209215
* [C++11] Use 'nullptr'.Craig Topper2014-05-071-6/+6
| | | | llvm-svn: 208163
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-071-1/+1
| | | | | | This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
* [C++11] Replace llvm::tie with std::tie.Benjamin Kramer2014-03-021-1/+1
| | | | llvm-svn: 202639
* Point diagnostics that complain about a use of a selector in an objc ↵Argyrios Kyrtzidis2013-05-011-2/+2
| | | | | | | | | | | | message, to the selector location. Previously it would point to the left bracket or the receiver, which can be particularly problematic if the receiver is a block literal and we end up point the diagnostic far away for the selector that is complaining about. rdar://13620447 llvm-svn: 180833
* [arcmt] Allow removing an -autorelease of a variable initialized in the ↵Argyrios Kyrtzidis2013-01-041-13/+45
| | | | | | | | previous statement. rdar://11074996 llvm-svn: 171485
* [arcmt] Don't error if an autoreleased variable is returned after the ↵Argyrios Kyrtzidis2013-01-041-18/+70
| | | | | | | | -autorelease. rdar://12952025 llvm-svn: 171482
* Don't include Type.h in DeclarationName.h.Benjamin Kramer2012-12-011-0/+1
| | | | | | Recursively prune some includes. llvm-svn: 169094
* s/tranform/transform/Benjamin Kramer2012-11-141-1/+1
| | | | llvm-svn: 167929
* Drop the ASTContext.h include from DeclFriend.h and DeclTemplate.h.Benjamin Kramer2012-07-041-2/+3
| | | | llvm-svn: 159723
* [arcmt] At an unbridged cast error, if we're returning a load-of-ivar from a ↵Argyrios Kyrtzidis2012-06-071-1/+1
| | | | | | | | | | +0 method, automatically insert a __bridge cast. radar://11560638 llvm-svn: 158127
* [arcmt] Remove an unused -autorelease, without failing with error, for thisArgyrios Kyrtzidis2012-05-231-8/+84
| | | | | | | | | | | idiom that is used commonly in setters: [backingValue autorelease]; backingValue = [newValue retain]; // in general a +1 assign rdar://9914061 llvm-svn: 157347
* [arcmt] Revert r156999 "Remove the "it is not safe to remove an unused ↵Argyrios Kyrtzidis2012-05-211-0/+11
| | | | | | | | | | 'autorelease' message" ARC migration error". Per feedback from John this is useful to have in general. llvm-svn: 157198
* [arcmt] Remove the "it is not safe to remove an unused 'autorelease' ↵Argyrios Kyrtzidis2012-05-171-11/+0
| | | | | | | | | | | | | | message" ARC migration error. This is more trouble that it is worth; autoreleasing a value without holding on it is a valid use-case, we should not "punish" correct code for the minority of broken/fragile programs that depend on the behavior of -autorelease. rdar://9914061 llvm-svn: 156999
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-1/+1
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Add new code migrator support for migrating existing Objective-C code to useTed Kremenek2012-03-061-7/+87
| | | | | | | | | | | the new Objective-C NSArray/NSDictionary/NSNumber literal syntax. This introduces a new library, libEdit, which provides a new way to support migration of code that improves on the original ARC migrator. We now believe that most of its functionality can be refactored into the existing libraries, and thus this new library may shortly disappear. llvm-svn: 152141
* Basic: import OwningPtr<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | llvm-svn: 149798
* Change the AST representation of operations on Objective-CJohn McCall2011-11-061-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | property references to use a new PseudoObjectExpr expression which pairs a syntactic form of the expression with a set of semantic expressions implementing it. This should significantly reduce the complexity required elsewhere in the compiler to deal with these kinds of expressions (e.g. IR generation's special l-value kind, the static analyzer's Message abstraction), at the lower cost of specifically dealing with the odd AST structure of these expressions. It should also greatly simplify efforts to implement similar language features in the future, most notably Managed C++'s properties and indexed properties. Most of the effort here is in dealing with the various clients of the AST. I've gone ahead and simplified the ObjC rewriter's use of properties; other clients, like IR-gen and the static analyzer, have all the old complexity *and* all the new complexity, at least temporarily. Many thanks to Ted for writing and advising on the necessary changes to the static analyzer. I've xfailed a small diagnostics regression in the static analyzer at Ted's request. llvm-svn: 143867
* [arcmt] For GC, cleanup and turn -finalize to -dealloc.Argyrios Kyrtzidis2011-11-041-2/+6
| | | | llvm-svn: 143701
* [arcmt] More automatic transformations and safety improvements; rdar://9615812 :Argyrios Kyrtzidis2011-07-271-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Replace calling -zone with 'nil'. -zone is obsolete in ARC. - Allow removing retain/release on a static global var. - Fix assertion hit when scanning for name references outside a NSAutoreleasePool scope. - Automatically add bridged casts for results of objc method calls and when calling CFRetain, for example: NSString *s; CFStringRef ref = [s string]; -> CFStringRef ref = (__bridge CFStringRef)([s string]); ref = s.string; -> ref = (__bridge CFStringRef)(s.string); ref = [NSString new]; -> ref = (__bridge_retained CFStringRef)([NSString new]); ref = [s newString]; -> ref = (__bridge_retained CFStringRef)([s newString]); ref = [[NSString alloc] init]; -> ref = (__bridge_retained CFStringRef)([[NSString alloc] init]); ref = [[s string] retain]; -> ref = (__bridge_retained CFStringRef)([s string]); ref = CFRetain(s); -> ref = (__bridge_retained CFTypeRef)(s); ref = [s retain]; -> ref = (__bridge_retained CFStringRef)(s); - Emit migrator error when trying to cast to CF type the result of autorelease/release: for CFStringRef f3() { return (CFStringRef)[[[NSString alloc] init] autorelease]; } emits: t.m:12:10: error: [rewriter] it is not safe to cast to 'CFStringRef' the result of 'autorelease' message; a __bridge cast may result in a pointer to a destroyed object and a __bridge_retained may leak the object return (CFStringRef)[[[NSString alloc] init] autorelease]; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.m:12:3: note: [rewriter] remove the cast and change return type of function to 'NSString *' to have the object automatically autoreleased return (CFStringRef)[[[NSString alloc] init] autorelease]; ^ - Before changing attributes to weak/unsafe_unretained, check if the backing ivar is set to a +1 object, in which case use 'strong' instead. llvm-svn: 136208
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-1/+0
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* [arcmt] It's not safe to remove the -release on "[[someivar delegate] ↵Argyrios Kyrtzidis2011-07-151-9/+31
| | | | | | | | | | | | | | | | | | release];" since it's very likely that, after migration, the object that was passed to 'setDelegate:' will not be properly retained, e.g: -whatever { id x = [[MyDoHicky alloc] init]; [someivar setDelegate: x]; // x won't get retained in ARC. } -dealloc { [[someivar delegate] release]; // give migration error here. } rdar://8858009 llvm-svn: 135327
* [arcmt] Rewrite to "foo = nil;" not "foo = 0;", as suggested by Jordy.Argyrios Kyrtzidis2011-07-151-2/+8
| | | | llvm-svn: 135309
* [arcmt] For:Argyrios Kyrtzidis2011-07-151-8/+31
| | | | | | | | | | | | | | | id x = ... @try { ... } @finally { [x release]; } Migrator will drop the release. It's better to change it to "x = 0" in a @finally to avoid leak when exception is thrown. rdar://9398256 llvm-svn: 135301
* [arcmt] Don't remove retains/releases on a global variable, flag them with ↵Argyrios Kyrtzidis2011-07-141-0/+9
| | | | | | errors. rdar://9402555. llvm-svn: 135213
* [arcmt] Allow -retain of an __unsafe_unretained receiver if the result gets ↵Argyrios Kyrtzidis2011-07-141-1/+2
| | | | | | | | used. Keep the error if the result is unused. rdar://9552694. llvm-svn: 135209
* [arcmt] Emit an error for unused -autorelease messages.Argyrios Kyrtzidis2011-07-141-2/+14
| | | | | | | | | | | An unused autorelease is badness. If we remove it the receiver will likely die immediately while previously it was kept alive by the autorelease pool. This is bad practice in general, so leave it and emit an error to force the user to restructure his code. rdar://9599884 llvm-svn: 135193
* In ARC, reclaim all return values of retainable type, not just thoseJohn McCall2011-07-071-2/+7
| | | | | | | | | | | | where we have an immediate need of a retained value. As an exception, don't do this when the call is made as the immediate operand of a __bridge retain. This is more in the way of a workaround than an actual guarantee, so it's acceptable to be brittle here. rdar://problem/9504800 llvm-svn: 134605
* [arcmt] Fully migrate ObjC++ classes, rdar://9660007.Argyrios Kyrtzidis2011-06-231-3/+2
| | | | llvm-svn: 133763
* [arcmt] Break apart Transforms.cpp.Argyrios Kyrtzidis2011-06-211-0/+142
llvm-svn: 133539
OpenPOWER on IntegriCloud