mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +00:00
Switch FuncType capture-list storage to optional<vector<Capture>>
May help clarify overall mem-mgmt/ownership semantics.
This commit is contained in:
parent
ab15a98b28
commit
b08112b2e7
8 changed files with 44 additions and 41 deletions
10
src/Expr.cc
10
src/Expr.cc
|
@ -4421,7 +4421,7 @@ LambdaExpr::LambdaExpr(std::unique_ptr<function_ingredients> arg_ing,
|
|||
void LambdaExpr::CheckCaptures()
|
||||
{
|
||||
auto ft = type->AsFuncType();
|
||||
auto captures = ft->GetCaptures();
|
||||
const auto& captures = ft->GetCaptures();
|
||||
|
||||
capture_by_ref = false;
|
||||
|
||||
|
@ -4441,9 +4441,9 @@ void LambdaExpr::CheckCaptures()
|
|||
std::set<const ID*> outer_is_matched;
|
||||
std::set<const ID*> capture_is_matched;
|
||||
|
||||
for ( auto c : *captures )
|
||||
for ( const auto& c : *captures )
|
||||
{
|
||||
auto cid = c->id.get();
|
||||
auto cid = c.id.get();
|
||||
|
||||
if ( ! cid )
|
||||
// This happens for undefined/inappropriate
|
||||
|
@ -4470,9 +4470,9 @@ void LambdaExpr::CheckCaptures()
|
|||
if ( outer_is_matched.count(id) == 0 )
|
||||
ExprError(util::fmt("%s is used inside lambda but not captured", id->Name()));
|
||||
|
||||
for ( auto c : *captures )
|
||||
for ( const auto& c : *captures )
|
||||
{
|
||||
auto cid = c->id.get();
|
||||
auto cid = c.id.get();
|
||||
if ( cid && capture_is_matched.count(cid) == 0 )
|
||||
ExprError(util::fmt("%s is captured but not used inside lambda", cid->Name()));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue