Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ class RawPtrRefLambdaCapturesChecker
auto *Callee = CE->getCallee();
if (!Callee)
return;
Callee = Callee->IgnoreParenCasts();
if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Callee))
Callee = MTE->getSubExpr();
if (!Callee)
return;
Callee = Callee->IgnoreParenCasts();
if (auto *L = dyn_cast_or_null<LambdaExpr>(Callee)) {
LambdasToIgnore.insert(L); // Calling a lambda upon creation is safe.
return;
}
auto *DRE = dyn_cast<DeclRefExpr>(Callee->IgnoreParenCasts());
if (!DRE)
return;
Expand Down
17 changes: 17 additions & 0 deletions clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,23 @@ void capture_copy_in_lambda(CheckedObj& checked) {
});
}

struct TemplateFunctionCallsLambda {
void ref() const;
void deref() const;

RefCountable* obj();

template <typename T>
RefPtr<T> method(T* t) {
auto ret = ([&]() -> RefPtr<T> {
if constexpr (T::isEncodable)
return t;
return obj() ? t : nullptr;
})();
return ret;
}
};

class Iterator {
public:
Iterator(void* array, unsigned long sizeOfElement, unsigned int index);
Expand Down