Remove weak_ref param from ID::SetVal()

It was not used anywhere.
This commit is contained in:
Jon Siwek 2020-05-23 09:29:27 -07:00
parent 198d604dde
commit 28b4206519
2 changed files with 3 additions and 21 deletions

View file

@ -114,7 +114,6 @@ ID::ID(const char* arg_name, IDScope arg_scope, bool arg_is_export)
offset = 0; offset = 0;
infer_return_type = false; infer_return_type = false;
weak_ref = false;
SetLocationInfo(&start_location, &end_location); SetLocationInfo(&start_location, &end_location);
} }
@ -122,9 +121,6 @@ ID::ID(const char* arg_name, IDScope arg_scope, bool arg_is_export)
ID::~ID() ID::~ID()
{ {
delete [] name; delete [] name;
if ( weak_ref )
val.release();
} }
std::string ID::ModuleName() const std::string ID::ModuleName() const
@ -139,17 +135,12 @@ void ID::SetType(IntrusivePtr<BroType> t)
void ID::ClearVal() void ID::ClearVal()
{ {
if ( weak_ref ) val = nullptr;
val.release();
} }
void ID::SetVal(IntrusivePtr<Val> v, bool arg_weak_ref) void ID::SetVal(IntrusivePtr<Val> v)
{ {
if ( weak_ref )
val.release();
val = std::move(v); val = std::move(v);
weak_ref = arg_weak_ref;
Modified(); Modified();
#ifdef DEBUG #ifdef DEBUG

View file

@ -67,15 +67,7 @@ public:
void MakeType() { is_type = true; } void MakeType() { is_type = true; }
// If weak_ref is false, the Val is assumed to be already ref'ed void SetVal(IntrusivePtr<Val> v);
// and will be deref'ed when the ID is deleted.
//
// If weak_ref is true, we store the Val but don't ref/deref it.
// That means that when the ID becomes the only one holding a
// reference to the Val, the Val will be destroyed (naturally,
// you have to take care that it will not be accessed via
// the ID afterwards).
void SetVal(IntrusivePtr<Val> v, bool weak_ref = false);
void SetVal(IntrusivePtr<Val> v, init_class c); void SetVal(IntrusivePtr<Val> v, init_class c);
void SetVal(IntrusivePtr<Expr> ev, init_class c); void SetVal(IntrusivePtr<Expr> ev, init_class c);
@ -153,7 +145,6 @@ protected:
IDScope scope; IDScope scope;
bool is_export; bool is_export;
bool infer_return_type; bool infer_return_type;
bool weak_ref;
IntrusivePtr<BroType> type; IntrusivePtr<BroType> type;
bool is_const, is_enum_const, is_type, is_option; bool is_const, is_enum_const, is_type, is_option;
int offset; int offset;