Change find_nested_record_types() to take IntrusivePtr

This commit is contained in:
Jon Siwek 2020-05-21 23:21:37 -07:00
parent a0481c0b26
commit 0a23b8dff5

View file

@ -1342,7 +1342,7 @@ static void table_entry_val_delete_func(void* val)
delete tv; delete tv;
} }
static void find_nested_record_types(BroType* t, std::set<RecordType*>* found) static void find_nested_record_types(const IntrusivePtr<BroType>& t, std::set<RecordType*>* found)
{ {
if ( ! t ) if ( ! t )
return; return;
@ -1354,28 +1354,28 @@ static void find_nested_record_types(BroType* t, std::set<RecordType*>* found)
found->emplace(rt); found->emplace(rt);
for ( auto i = 0; i < rt->NumFields(); ++i ) for ( auto i = 0; i < rt->NumFields(); ++i )
find_nested_record_types(rt->FieldDecl(i)->type.get(), found); find_nested_record_types(rt->FieldDecl(i)->type, found);
} }
return; return;
case TYPE_TABLE: case TYPE_TABLE:
find_nested_record_types(t->AsTableType()->GetIndices().get(), found); find_nested_record_types(t->AsTableType()->GetIndices(), found);
find_nested_record_types(t->AsTableType()->Yield().get(), found); find_nested_record_types(t->AsTableType()->Yield(), found);
return; return;
case TYPE_LIST: case TYPE_LIST:
{ {
for ( const auto& type : t->AsTypeList()->Types() ) for ( const auto& type : t->AsTypeList()->Types() )
find_nested_record_types(type.get(), found); find_nested_record_types(type, found);
} }
return; return;
case TYPE_FUNC: case TYPE_FUNC:
find_nested_record_types(t->AsFuncType()->Params().get(), found); find_nested_record_types(t->AsFuncType()->Params(), found);
find_nested_record_types(t->AsFuncType()->Yield().get(), found); find_nested_record_types(t->AsFuncType()->Yield(), found);
return; return;
case TYPE_VECTOR: case TYPE_VECTOR:
find_nested_record_types(t->AsVectorType()->Yield().get(), found); find_nested_record_types(t->AsVectorType()->Yield(), found);
return; return;
case TYPE_TYPE: case TYPE_TYPE:
find_nested_record_types(t->AsTypeType()->GetType().get(), found); find_nested_record_types(t->AsTypeType()->GetType(), found);
return; return;
default: default:
return; return;
@ -1395,7 +1395,7 @@ TableVal::TableVal(IntrusivePtr<TableType> t, IntrusivePtr<Attributes> a) : Val(
std::set<RecordType*> found; std::set<RecordType*> found;
// TODO: this likely doesn't have to be repeated for each new TableVal, // TODO: this likely doesn't have to be repeated for each new TableVal,
// can remember the resulting dependencies per TableType // can remember the resulting dependencies per TableType
find_nested_record_types(t.get(), &found); find_nested_record_types(t, &found);
for ( auto rt : found ) for ( auto rt : found )
parse_time_table_record_dependencies[rt].emplace_back(NewRef{}, this); parse_time_table_record_dependencies[rt].emplace_back(NewRef{}, this);