//===--- TransBlockObjCVariable.cpp - Transformations to ARC mode ---------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// rewriteBlockObjCVariable:
//
// Adding __block to an obj-c variable could be either because the variable
// is used for output storage or the user wanted to break a retain cycle.
// This transformation checks whether a reference of the variable for the block
// is actually needed (it is assigned to or its address is taken) or not.
// If the reference is not needed it will assume __block was added to break a
// cycle so it will remove '__block' and add __weak/__unsafe_unretained.
// e.g
//
// __block Foo *x;
// bar(^ { [x cake]; });
// ---->
// __weak Foo *x;
// bar(^ { [x cake]; });
//
//===----------------------------------------------------------------------===//
using namespace clang;
using namespace arcmt;
using namespace trans;
// anonymous namespace
void