mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 01:28:20 +00:00
Adjust various reaching-def move/reference semantics
Nothing that important, just changing things to what is hypothetically more efficient in general.
This commit is contained in:
parent
1f7580db65
commit
36f27a0d01
6 changed files with 27 additions and 29 deletions
|
@ -41,7 +41,7 @@ void DefSetsMgr::CreatePostDef(std::shared_ptr<DefinitionItem> di,
|
|||
SetPostFromPre(where);
|
||||
}
|
||||
|
||||
CreateDef(di, dp, false, min_only);
|
||||
CreateDef(std::move(di), dp, false, min_only);
|
||||
}
|
||||
|
||||
void DefSetsMgr::CreateDef(std::shared_ptr<DefinitionItem> di,
|
||||
|
|
|
@ -95,8 +95,8 @@ public:
|
|||
// Set the post-RDs for a given node to the given min/max values.
|
||||
void SetPostRDs(const Obj* o, RDPtr min_rd, RDPtr max_rd)
|
||||
{
|
||||
SetPostMinRDs(o, min_rd);
|
||||
SetPostMaxRDs(o, max_rd);
|
||||
SetPostMinRDs(o, std::move(min_rd));
|
||||
SetPostMaxRDs(o, std::move(max_rd));
|
||||
}
|
||||
|
||||
// Propagate the node's pre-RDs to also be its post-RDs.
|
||||
|
@ -122,14 +122,14 @@ public:
|
|||
|
||||
// Fine-grained control for setting RDs.
|
||||
void SetPreMinRDs(const Obj* o, RDPtr rd)
|
||||
{ pre_min_defs->SetRDs(o, rd); }
|
||||
{ pre_min_defs->SetRDs(o, std::move(rd)); }
|
||||
void SetPreMaxRDs(const Obj* o, RDPtr rd)
|
||||
{ pre_max_defs->SetRDs(o, rd); }
|
||||
{ pre_max_defs->SetRDs(o, std::move(rd)); }
|
||||
|
||||
void SetPostMinRDs(const Obj* o, RDPtr rd)
|
||||
{ post_min_defs->SetRDs(o, rd); }
|
||||
{ post_min_defs->SetRDs(o, std::move(rd)); }
|
||||
void SetPostMaxRDs(const Obj* o, RDPtr rd)
|
||||
{ post_max_defs->SetRDs(o, rd); }
|
||||
{ post_max_defs->SetRDs(o, std::move(rd)); }
|
||||
|
||||
// Used for confluence: add a set of RDs into those already
|
||||
// associated with a node's pre-RDs / post-RDs. Only applies
|
||||
|
@ -172,7 +172,7 @@ public:
|
|||
// then only done for minimal RDs.
|
||||
void CreatePreDef(std::shared_ptr<DefinitionItem> di,
|
||||
DefinitionPoint dp, bool min_only)
|
||||
{ CreateDef(di, dp, true, min_only); }
|
||||
{ CreateDef(std::move(di), dp, true, min_only); }
|
||||
void CreatePostDef(const ID* id, DefinitionPoint dp, bool min_only);
|
||||
void CreatePostDef(std::shared_ptr<DefinitionItem> di,
|
||||
DefinitionPoint dp, bool min_only);
|
||||
|
|
|
@ -20,9 +20,9 @@ public:
|
|||
BlockDefs(bool _is_case)
|
||||
{ is_case = _is_case; }
|
||||
|
||||
void AddPreRDs(RDPtr RDs) { pre_RDs.push_back(RDs); }
|
||||
void AddPostRDs(RDPtr RDs) { post_RDs.push_back(RDs); }
|
||||
void AddFutureRDs(RDPtr RDs) { future_RDs.push_back(RDs); }
|
||||
void AddPreRDs(RDPtr RDs) { pre_RDs.push_back(std::move(RDs)); }
|
||||
void AddPostRDs(RDPtr RDs) { post_RDs.push_back(std::move(RDs)); }
|
||||
void AddFutureRDs(RDPtr RDs) { future_RDs.push_back(std::move(RDs)); }
|
||||
|
||||
const std::vector<RDPtr>& PreRDs() const { return pre_RDs; }
|
||||
const std::vector<RDPtr>& PostRDs() const { return post_RDs; }
|
||||
|
@ -48,12 +48,12 @@ void RD_Decorate::TraverseFunction(const Func* f, Scope* scope, StmtPtr body)
|
|||
{
|
||||
func_flavor = f->Flavor();
|
||||
|
||||
auto args = scope->OrderedVars();
|
||||
const auto& args = scope->OrderedVars();
|
||||
int nparam = f->GetType()->Params()->NumFields();
|
||||
|
||||
mgr.SetEmptyPre(f);
|
||||
|
||||
for ( auto a : args )
|
||||
for ( const auto& a : args )
|
||||
{
|
||||
if ( --nparam < 0 )
|
||||
break;
|
||||
|
@ -141,7 +141,7 @@ TraversalCode RD_Decorate::PreStmt(const Stmt* s)
|
|||
case STMT_LIST:
|
||||
{
|
||||
auto sl = s->AsStmtList();
|
||||
auto stmts = sl->Stmts();
|
||||
const auto& stmts = sl->Stmts();
|
||||
const Stmt* pred_stmt = s; // current Stmt's predecessor
|
||||
|
||||
for ( const auto& stmt : stmts )
|
||||
|
@ -723,9 +723,8 @@ bool RD_Decorate::CheckLHS(const Expr* lhs, const Expr* e)
|
|||
auto fn = f->FieldName();
|
||||
|
||||
auto field_rd = r_def->FindField(fn);
|
||||
auto ft = f->GetType();
|
||||
if ( ! field_rd )
|
||||
field_rd = r_def->CreateField(fn, ft);
|
||||
field_rd = r_def->CreateField(fn, f->GetType());
|
||||
|
||||
CreateInitPostDef(field_rd, DefinitionPoint(e), false, rhs.get());
|
||||
|
||||
|
@ -942,9 +941,8 @@ TraversalCode RD_Decorate::PreExpr(const Expr* e)
|
|||
auto offset = f->Field();
|
||||
auto field_rd = r_def->FindField(offset);
|
||||
|
||||
auto ft = f->GetType();
|
||||
if ( ! field_rd )
|
||||
field_rd = r_def->CreateField(offset, ft);
|
||||
field_rd = r_def->CreateField(offset, f->GetType());
|
||||
|
||||
CreateInitPostDef(field_rd, DefinitionPoint(e), false, r);
|
||||
|
||||
|
@ -1031,7 +1029,7 @@ TraversalCode RD_Decorate::PreExpr(const Expr* e)
|
|||
if ( ! field_rd )
|
||||
{
|
||||
auto ft = id_rt->GetFieldType(fn);
|
||||
field_rd = id_di->CreateField(fn, ft);
|
||||
field_rd = id_di->CreateField(fn, std::move(ft));
|
||||
CreateInitPostDef(field_rd, DefinitionPoint(hf),
|
||||
false, 0);
|
||||
}
|
||||
|
@ -1189,7 +1187,7 @@ void RD_Decorate::CreateInitPostDef(std::shared_ptr<DefinitionItem> di,
|
|||
DefinitionPoint dp, bool assume_full,
|
||||
const Expr* rhs)
|
||||
{
|
||||
CreateInitDef(di, dp, false, assume_full, rhs);
|
||||
CreateInitDef(std::move(di), dp, false, assume_full, rhs);
|
||||
}
|
||||
|
||||
void RD_Decorate::CreateInitDef(std::shared_ptr<DefinitionItem> di,
|
||||
|
@ -1225,7 +1223,7 @@ void RD_Decorate::CreateInitDef(std::shared_ptr<DefinitionItem> di,
|
|||
}
|
||||
}
|
||||
|
||||
CreateRecordRDs(di, dp, is_pre, assume_full, rhs_di.get());
|
||||
CreateRecordRDs(std::move(di), dp, is_pre, assume_full, rhs_di.get());
|
||||
}
|
||||
|
||||
void RD_Decorate::CreateRecordRDs(std::shared_ptr<DefinitionItem> di,
|
||||
|
@ -1239,7 +1237,7 @@ void RD_Decorate::CreateRecordRDs(std::shared_ptr<DefinitionItem> di,
|
|||
for ( auto i = 0; i < n; ++i )
|
||||
{
|
||||
auto n_i = rt->FieldName(i);
|
||||
auto t_i = rt->GetFieldType(i);
|
||||
const auto& t_i = rt->GetFieldType(i);
|
||||
auto rhs_di_i = rhs_di ? rhs_di->FindField(n_i) : nullptr;
|
||||
|
||||
bool field_is_defined = false;
|
||||
|
@ -1323,7 +1321,7 @@ void RD_Decorate::CheckRecordRDs(std::shared_ptr<DefinitionItem> di,
|
|||
// very heavy if run on the full code base because
|
||||
// there are some massive records (in some places
|
||||
// nested 5 deep).
|
||||
auto t_i = rt->GetFieldType(i);
|
||||
const auto& t_i = rt->GetFieldType(i);
|
||||
if ( t_i->Tag() == TYPE_RECORD )
|
||||
CheckRecordRDs(field_di, dp, pre_rds, o);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ private:
|
|||
void CreateRecordRDs(std::shared_ptr<DefinitionItem> di,
|
||||
DefinitionPoint dp, bool assume_full,
|
||||
const DefinitionItem* rhs_di)
|
||||
{ CreateRecordRDs(di, dp, false, assume_full, rhs_di); }
|
||||
{ CreateRecordRDs(std::move(di), dp, false, assume_full, rhs_di); }
|
||||
void CreateRecordRDs(std::shared_ptr<DefinitionItem> di,
|
||||
DefinitionPoint dp, bool is_pre,
|
||||
bool assume_full, const DefinitionItem* rhs_di);
|
||||
|
|
|
@ -13,9 +13,9 @@ ReachingDefs::ReachingDefs()
|
|||
const_rd_map = nullptr;
|
||||
}
|
||||
|
||||
ReachingDefs::ReachingDefs(RDPtr& rd)
|
||||
ReachingDefs::ReachingDefs(RDPtr rd)
|
||||
{
|
||||
const_rd_map = rd;
|
||||
const_rd_map = std::move(rd);
|
||||
my_rd_map = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
ReachingDefs();
|
||||
|
||||
// Create a new object, using the RDs from another object.
|
||||
ReachingDefs(RDPtr& rd);
|
||||
ReachingDefs(RDPtr rd);
|
||||
|
||||
~ReachingDefs();
|
||||
|
||||
|
@ -208,9 +208,9 @@ public:
|
|||
RDPtr& FindRDs(const Obj* o) const;
|
||||
|
||||
// Associates the given RDs with the given AST node.
|
||||
void SetRDs(const Obj* o, RDPtr& rd)
|
||||
void SetRDs(const Obj* o, RDPtr rd)
|
||||
{
|
||||
auto new_rd = make_intrusive<ReachingDefs>(rd);
|
||||
auto new_rd = make_intrusive<ReachingDefs>(std::move(rd));
|
||||
(*a_i)[o] = new_rd;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue