39class RootBlockObjCVarRewriter :
41 llvm::DenseSet<VarDecl *> &VarsToChange;
52 ref = dyn_cast<DeclRefExpr>(castE->
getSubExpr())) {
53 if (ref->getDecl() == Var) {
62 return base::TraverseImplicitCastExpr(castE);
66 if (
E->getDecl() == Var)
74 RootBlockObjCVarRewriter(llvm::DenseSet<VarDecl *> &VarsToChange)
75 : VarsToChange(VarsToChange) { }
80 for (
const auto &I : block->
captures()) {
83 var->getType()->isObjCObjectPointerType() &&
84 isImplicitStrong(
var->getType())) {
85 BlockVars.push_back(var);
89 for (
unsigned i = 0, e = BlockVars.size(); i != e; ++i) {
92 BlockVarChecker checker(var);
93 bool onlyValueOfVarIsNeeded = checker.TraverseStmt(block->
getBody());
94 if (onlyValueOfVarIsNeeded)
95 VarsToChange.insert(var);
97 VarsToChange.erase(var);
104 bool isImplicitStrong(
QualType ty) {
112 llvm::DenseSet<VarDecl *> &VarsToChange;
115 BlockObjCVarRewriter(llvm::DenseSet<VarDecl *> &VarsToChange)
116 : VarsToChange(VarsToChange) { }
118 bool TraverseBlockDecl(
BlockDecl *block) {
119 RootBlockObjCVarRewriter(VarsToChange).TraverseDecl(block);
128 llvm::DenseSet<VarDecl *> VarsToChange;
130 BlockObjCVarRewriter trans(VarsToChange);
133 for (llvm::DenseSet<VarDecl *>::iterator
134 I = VarsToChange.begin(),
E = VarsToChange.end(); I !=
E; ++I) {
136 BlocksAttr *
attr = var->getAttr<BlocksAttr>();
144 useWeak ?
"__weak" :
"__unsafe_unretained");
Defines the clang::ASTContext interface.
Defines the SourceManager interface.
SourceManager & getSourceManager()
const LangOptions & getLangOpts() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
ArrayRef< Capture > captures() const
CastKind getCastKind() const
A reference to a declared variable, function, enum, etc.
ASTContext & getASTContext() const LLVM_READONLY
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
A (possibly-)qualified type.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
ObjCLifetime getObjCLifetime() const
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
This class handles loading and caching of source files into memory.
Represents a variable declaration or definition.
void traverseBody(BodyContext &BodyCtx) override
MigrationContext & getMigrationContext()
bool canApplyWeak(ASTContext &Ctx, QualType type, bool AllowOnUnknownClass=false)
Determine whether we can add weak to the given type.
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
constexpr Variable var(Literal L)
Returns the variable of L.
The JSON file list parser is used to communicate input to InstallAPI.