Objective-C arc: don't count use of __weak
variables when they are used in such unevaluated contexts as __typeof, etc. // rdar://13942025 llvm-svn: 182423
This commit is contained in:
parent
9d3ccc700f
commit
6f829e34b3
|
@ -957,7 +957,13 @@ public:
|
||||||
sema::FunctionScopeInfo *getCurFunction() const {
|
sema::FunctionScopeInfo *getCurFunction() const {
|
||||||
return FunctionScopes.back();
|
return FunctionScopes.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename ExprT>
|
||||||
|
void recordUseOfEvaluatedWeak(const ExprT *E, bool IsRead=true) {
|
||||||
|
if (!isUnevaluatedContext())
|
||||||
|
getCurFunction()->recordUseOfWeak(E, IsRead);
|
||||||
|
}
|
||||||
|
|
||||||
void PushCompoundScope();
|
void PushCompoundScope();
|
||||||
void PopCompoundScope();
|
void PopCompoundScope();
|
||||||
|
|
||||||
|
|
|
@ -1550,7 +1550,7 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
|
||||||
Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak,
|
Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak,
|
||||||
E->getLocStart());
|
E->getLocStart());
|
||||||
if (Level != DiagnosticsEngine::Ignored)
|
if (Level != DiagnosticsEngine::Ignored)
|
||||||
getCurFunction()->recordUseOfWeak(E);
|
recordUseOfEvaluatedWeak(E);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just in case we're building an illegal pointer-to-member.
|
// Just in case we're building an illegal pointer-to-member.
|
||||||
|
@ -2152,7 +2152,7 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S,
|
||||||
DiagnosticsEngine::Level Level =
|
DiagnosticsEngine::Level Level =
|
||||||
Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak, Loc);
|
Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak, Loc);
|
||||||
if (Level != DiagnosticsEngine::Ignored)
|
if (Level != DiagnosticsEngine::Ignored)
|
||||||
getCurFunction()->recordUseOfWeak(Result);
|
recordUseOfEvaluatedWeak(Result);
|
||||||
}
|
}
|
||||||
if (CurContext->isClosure())
|
if (CurContext->isClosure())
|
||||||
Diag(Loc, diag::warn_implicitly_retains_self)
|
Diag(Loc, diag::warn_implicitly_retains_self)
|
||||||
|
|
|
@ -1311,7 +1311,7 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
|
||||||
Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak,
|
Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak,
|
||||||
MemberLoc);
|
MemberLoc);
|
||||||
if (Level != DiagnosticsEngine::Ignored)
|
if (Level != DiagnosticsEngine::Ignored)
|
||||||
getCurFunction()->recordUseOfWeak(Result);
|
recordUseOfEvaluatedWeak(Result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -882,8 +882,8 @@ ExprResult ObjCPropertyOpBuilder::complete(Expr *SyntacticForm) {
|
||||||
S.Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak,
|
S.Diags.getDiagnosticLevel(diag::warn_arc_repeated_use_of_weak,
|
||||||
SyntacticForm->getLocStart());
|
SyntacticForm->getLocStart());
|
||||||
if (Level != DiagnosticsEngine::Ignored)
|
if (Level != DiagnosticsEngine::Ignored)
|
||||||
S.getCurFunction()->recordUseOfWeak(SyntacticRefExpr,
|
S.recordUseOfEvaluatedWeak(SyntacticRefExpr,
|
||||||
SyntacticRefExpr->isMessagingGetter());
|
SyntacticRefExpr->isMessagingGetter());
|
||||||
}
|
}
|
||||||
|
|
||||||
return PseudoOpBuilder::complete(SyntacticForm);
|
return PseudoOpBuilder::complete(SyntacticForm);
|
||||||
|
|
|
@ -410,3 +410,18 @@ void doubleLevelAccessIvar(Test *a, Test *b) {
|
||||||
use(a.strongProp.weakProp); // no-warning
|
use(a.strongProp.weakProp); // no-warning
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rdar://13942025
|
||||||
|
@interface X
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation X
|
||||||
|
- (int) warningAboutWeakVariableInsideTypeof {
|
||||||
|
__typeof__(self) __weak weakSelf = self;
|
||||||
|
^(){
|
||||||
|
__typeof__(weakSelf) blockSelf = weakSelf;
|
||||||
|
use(blockSelf);
|
||||||
|
}();
|
||||||
|
return sizeof(weakSelf);
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue