34 using namespace clang;
35 using namespace arcmt;
36 using namespace trans;
40 class RootBlockObjCVarRewriter :
49 BlockVarChecker(
VarDecl *var) : Var(var) { }
53 ref = dyn_cast<DeclRefExpr>(castE->
getSubExpr())) {
54 if (ref->getDecl() == Var) {
63 return base::TraverseImplicitCastExpr(castE);
76 : VarsToChange(VarsToChange) { }
81 for (
const auto &I : block->
captures()) {
85 isImplicitStrong(var->
getType())) {
86 BlockVars.push_back(var);
90 for (
unsigned i = 0, e = BlockVars.size(); i != e; ++i) {
93 BlockVarChecker checker(var);
94 bool onlyValueOfVarIsNeeded = checker.TraverseStmt(block->
getBody());
95 if (onlyValueOfVarIsNeeded)
96 VarsToChange.insert(var);
98 VarsToChange.erase(var);
105 bool isImplicitStrong(
QualType ty) {
117 : VarsToChange(VarsToChange) { }
119 bool TraverseBlockDecl(
BlockDecl *block) {
120 RootBlockObjCVarRewriter(VarsToChange).TraverseDecl(block);
131 BlockObjCVarRewriter trans(VarsToChange);
135 I = VarsToChange.begin(), E = VarsToChange.end(); I != E; ++I) {
137 BlocksAttr *attr = var->
getAttr<BlocksAttr>();
145 useWeak ?
"__weak" :
"__unsafe_unretained");
Defines the clang::ASTContext interface.
A (possibly-)qualified type.
Defines the SourceManager interface.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
MigrationContext & getMigrationContext()
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
ObjCLifetime getObjCLifetime() const
bool canApplyWeak(ASTContext &Ctx, QualType type, bool AllowOnUnknownClass=false)
Determine whether we can add weak to the given type.
void traverseBody(BodyContext &BodyCtx) override
Assigning into this object requires the old value to be released and the new value to be retained...
CastKind getCastKind() const
ASTContext & getASTContext() const LLVM_READONLY
bool isObjCObjectPointerType() const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
Dataflow Directional Tag Classes.
ArrayRef< Capture > captures() const
SourceManager & getSourceManager()
A reference to a declared variable, function, enum, etc.
const LangOptions & getLangOpts() const
This class handles loading and caching of source files into memory.