AST profiles track the associated function/body/expression

This commit is contained in:
Vern Paxson 2021-11-24 15:18:40 -08:00
parent 8e1d770966
commit f865897cac
2 changed files with 23 additions and 6 deletions

View file

@ -100,6 +100,12 @@ public:
ProfileFunc(const Stmt* body, bool abs_rec_fields = false);
ProfileFunc(const Expr* func, bool abs_rec_fields = false);
// Returns the function, body, or expression profiled. Each can be
// null depending on the constructor used.
const Func* ProfiledFunc() const { return profiled_func; }
const Stmt* ProfiledBody() const { return profiled_body; }
const Expr* ProfiledExpr() const { return profiled_expr; }
// See the comments for the associated member variables for each
// of these accessors.
const std::unordered_set<const ID*>& Globals() const { return globals; }
@ -157,6 +163,12 @@ protected:
// Take note of an assignment to an identifier.
void TrackAssignment(const ID* id);
// The function, body, or expression profiled. Can be null
// depending on which constructor was used.
const Func* profiled_func = nullptr;
const Stmt* profiled_body = nullptr;
const Expr* profiled_expr = nullptr;
// Globals seen in the function.
//
// Does *not* include globals solely seen as the function being