diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-07-15 22:04:00 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-07-15 22:04:00 +0000 |
commit | 1aa60ff0ad1fb5bcb3042670dfdd7d5a8359d922 (patch) | |
tree | 3633486ceec548a3275caac474fe5ac812d4b729 /lib/ARCMigrate/TransRetainReleaseDealloc.cpp | |
parent | 3e4d10917a7ef84ebf86062e8c912de9c00597c9 (diff) |
[arcmt] Rewrite to "foo = nil;" not "foo = 0;", as suggested by Jordy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135309 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ARCMigrate/TransRetainReleaseDealloc.cpp')
-rw-r--r-- | lib/ARCMigrate/TransRetainReleaseDealloc.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/ARCMigrate/TransRetainReleaseDealloc.cpp b/lib/ARCMigrate/TransRetainReleaseDealloc.cpp index 8e6c533991..6f917b3246 100644 --- a/lib/ARCMigrate/TransRetainReleaseDealloc.cpp +++ b/lib/ARCMigrate/TransRetainReleaseDealloc.cpp @@ -19,7 +19,9 @@ #include "Transforms.h" #include "Internals.h" +#include "clang/Sema/Sema.h" #include "clang/Sema/SemaDiagnostic.h" +#include "clang/Lex/Preprocessor.h" #include "clang/AST/ParentMap.h" using namespace clang; @@ -115,10 +117,14 @@ public: if (E->getMethodFamily() == OMF_release && isRemovable(E) && isInAtFinally(E)) { - // Change the -release to "receiver = 0" in a finally to avoid a leak + // Change the -release to "receiver = nil" in a finally to avoid a leak // when an exception is thrown. Pass.TA.replace(E->getSourceRange(), rec->getSourceRange()); - Pass.TA.insertAfterToken(rec->getLocEnd(), " = 0"); + if (Pass.SemaRef.getPreprocessor() + .getIdentifierInfo("nil")->hasMacroDefinition()) + Pass.TA.insertAfterToken(rec->getLocEnd(), " = nil"); + else + Pass.TA.insertAfterToken(rec->getLocEnd(), " = 0"); return true; } |