117 std::map<const IR::Expression *, const SetOfLocations *> rw;
122 void postorder(
const IR::Operation_Binary *expression)
override {
123 auto left = ::P4::get(rw, expression->left);
124 auto right = ::P4::get(rw, expression->right);
127 rw.emplace(expression, left->join(right));
130 void postorder(
const IR::PathExpression *expression)
override {
131 auto decl = getDeclaration(expression->path);
134 rw.emplace(expression, locs);
137 void postorder(
const IR::Operation_Unary *expression)
override {
138 auto e = ::P4::get(rw, expression->expr);
140 rw.emplace(expression, e);
143 void postorder(
const IR::Member *expression)
override {
144 auto e = ::P4::get(rw, expression->expr);
146 auto result = e->append(expression->member);
147 rw.emplace(expression, result);
150 void postorder(
const IR::ArrayIndex *expression)
override {
151 auto e = ::P4::get(rw, expression->left);
154 if (expression->right->is<IR::Constant>()) {
155 int index = expression->right->to<IR::Constant>()->asInt();
156 result = e->
append(Util::toString(index));
158 auto index = ::P4::get(rw, expression->right);
159 result = e->
append(
"*"_cs)->join(index);
161 rw.emplace(expression, result);
164 void postorder(
const IR::Literal *expression)
override {
168 void postorder(
const IR::InvalidHeader *expression)
override {
172 void postorder(
const IR::InvalidHeaderUnion *expression)
override {
176 void postorder(
const IR::HeaderStackExpression *expression)
override {
180 void postorder(
const IR::TypeNameExpression *expression)
override {
184 void postorder(
const IR::Operation_Ternary *expression)
override {
185 auto e0 = ::P4::get(rw, expression->e0);
186 auto e1 = ::P4::get(rw, expression->e1);
187 auto e2 = ::P4::get(rw, expression->e2);
191 rw.emplace(expression, e0->join(e1)->join(e2));
194 void postorder(
const IR::AbstractSlice *expression)
override {
195 auto e = ::P4::get(rw, expression->e0);
197 rw.emplace(expression, e);
200 void postorder(
const IR::MethodCallExpression *expression)
override {
201 auto e = ::P4::get(rw, expression->method);
202 for (
auto a : *expression->arguments) {
203 auto s = ::P4::get(rw, a->expression);
207 rw.emplace(expression, e);
210 void postorder(
const IR::ConstructorCallExpression *expression)
override {
212 for (
auto e : *expression->arguments) {
213 auto s = ::P4::get(rw, e->expression);
215 result = result->join(s);
217 rw.emplace(expression, result);
220 void postorder(
const IR::StructExpression *expression)
override {
222 for (
auto e : expression->components) {
223 auto s = ::P4::get(rw, e->expression);
225 result = result->join(s);
227 rw.emplace(expression, result);
230 void postorder(
const IR::ListExpression *expression)
override {
232 for (
auto e : expression->components) {
233 auto s = ::P4::get(rw, e);
235 result = result->join(s);
237 rw.emplace(expression, result);
240 void postorder(
const IR::DefaultExpression *expression)
override {
245 expression->apply(*
this, ctxt);
246 auto result = ::P4::get(rw, expression);
248 LOG3(
"SetOfLocations(" << expression <<
")=" << result);
252 bool mayAlias(
const IR::Expression *left,
const IR::Expression *right,
254 auto llocs = get(left, ctxt);
255 auto rlocs = get(right, ctxt);
258 LOG3(
"Checking overlap between " << llocs <<
" and " << rlocs);
259 return llocs->overlaps(rlocs);
Visitor mixin for looking up names in enclosing scopes from the Visitor::Context.
Definition resolveReferences.h:35