fix for script profiling of lambda functions

This commit is contained in:
Vern Paxson 2022-07-07 11:01:54 -07:00
parent ee88aa3acb
commit 77ca9ae013

View file

@ -93,7 +93,7 @@ public:
ScriptProfile(const Func* _func, const detail::StmtPtr& body) ScriptProfile(const Func* _func, const detail::StmtPtr& body)
: ScriptProfileStats(_func->Name()) : ScriptProfileStats(_func->Name())
{ {
func = _func; func = {NewRef{}, const_cast<Func*>(_func)};
is_BiF = body == nullptr; is_BiF = body == nullptr;
if ( is_BiF ) if ( is_BiF )
@ -124,7 +124,9 @@ public:
void Report(FILE* f) const; void Report(FILE* f) const;
private: private:
const Func* func; // We store "func" as a FuncPtr to ensure it sticks around when
// it would otherwise be ephemeral (i.e., for lambdas).
FuncPtr func;
bool is_BiF; bool is_BiF;
detail::Location loc; detail::Location loc;