Differential D89638 Diff 298860 clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | void checkASTDecl(const TranslationUnitDecl *TUD, AnalysisManager &MGR, | ||||
LocalVisitor visitor(this); | LocalVisitor visitor(this); | ||||
visitor.TraverseDecl(const_cast<TranslationUnitDecl *>(TUD)); | visitor.TraverseDecl(const_cast<TranslationUnitDecl *>(TUD)); | ||||
} | } | ||||
void visitLambdaExpr(LambdaExpr *L) const { | void visitLambdaExpr(LambdaExpr *L) const { | ||||
for (const LambdaCapture &C : L->captures()) { | for (const LambdaCapture &C : L->captures()) { | ||||
if (C.capturesVariable()) { | if (C.capturesVariable()) { | ||||
VarDecl *CapturedVar = C.getCapturedVar(); | VarDecl *CapturedVar = C.getCapturedVar(); | ||||
if (!CapturedVar) | |||||
continue; | |||||
vsavchenko: It looks like a new case! Do we have a test for that? | |||||
if (CapturedVar->hasAttr<NoUncountedLambdaCapturesAttr>()) | |||||
continue; | |||||
if (auto *CapturedVarType = CapturedVar->getType().getTypePtrOrNull()) { | if (auto *CapturedVarType = CapturedVar->getType().getTypePtrOrNull()) { | ||||
Optional<bool> IsUncountedPtr = isUncountedPtr(CapturedVarType); | Optional<bool> IsUncountedPtr = isUncountedPtr(CapturedVarType); | ||||
if (IsUncountedPtr && *IsUncountedPtr) { | if (IsUncountedPtr && *IsUncountedPtr) { | ||||
reportBug(C, CapturedVar, CapturedVarType); | reportBug(C, CapturedVar, CapturedVarType); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
Show All 39 Lines |
It looks like a new case! Do we have a test for that?