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) {
58 Var->getASTContext().getLangOpts().CPlusPlus)
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.
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
CastKind getCastKind() const
Defines the SourceManager interface.
ObjCLifetime getObjCLifetime() const
Stmt * getBody() const override
MigrationContext & getMigrationContext()
A class that does preorder depth-first traversal on the entire Clang AST and visits each node...
bool canApplyWeak(ASTContext &Ctx, QualType type, bool AllowOnUnknownClass=false)
Determine whether we can add weak to the given type.
void traverseBody(BodyContext &BodyCtx) override
const Type * getTypePtr() const
SourceManager & getSourceManager()
bool isObjCObjectPointerType() const
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
This class handles loading and caching of source files into memory.