23class UncountedLambdaCapturesChecker
24 :
public Checker<check::ASTDecl<TranslationUnitDecl>> {
26 BugType Bug{
this,
"Lambda capture of uncounted variable",
27 "WebKit coding guidelines"};
39 const UncountedLambdaCapturesChecker *
Checker;
40 explicit LocalVisitor(
const UncountedLambdaCapturesChecker *
Checker)
45 bool shouldVisitTemplateInstantiations()
const {
return true; }
46 bool shouldVisitImplicitCode()
const {
return false; }
54 LocalVisitor visitor(
this);
60 if (
C.capturesVariable()) {
63 std::optional<bool> IsUncountedPtr =
isUncountedPtr(CapturedVarType);
64 if (IsUncountedPtr && *IsUncountedPtr) {
65 reportBug(
C, CapturedVar, CapturedVarType);
73 const Type *
T)
const {
77 llvm::raw_svector_ostream Os(Buf);
82 Os <<
"Implicitly captured ";
92 Os <<
" to uncounted type is unsafe.";
95 auto Report = std::make_unique<BasicBugReport>(Bug, Os.str(), BSLoc);
101void ento::registerUncountedLambdaCapturesChecker(
CheckerManager &Mgr) {
105bool ento::shouldRegisterUncountedLambdaCapturesChecker(
Describes the capture of a variable or of this, or of a C++1y init-capture.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
capture_range captures() const
Retrieve this lambda's captures.
const Type * getTypePtrOrNull() const
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
The top declaration context.
The base class of the type hierarchy.
bool isPointerType() const
bool isReferenceType() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
BugReporter is a utility class for generating PathDiagnostics for analysis.
const SourceManager & getSourceManager()
virtual void emitReport(std::unique_ptr< BugReport > R)
Add the given report to the set of reports tracked by BugReporter.
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
The JSON file list parser is used to communicate input to InstallAPI.
std::optional< bool > isUncountedPtr(const Type *T)
void printQuotedQualifiedName(llvm::raw_ostream &Os, const NamedDeclDerivedT &D)
const FunctionProtoType * T