[Mlir-commits] [mlir] [mlir] Add the ability to define dialect-specific location attrs. (PR #105584)
Aman LaChapelle
llvmlistbot at llvm.org
Wed Sep 18 09:39:09 PDT 2024
================
@@ -38,34 +38,14 @@ void BuiltinDialect::registerLocationAttributes() {
//===----------------------------------------------------------------------===//
WalkResult LocationAttr::walk(function_ref<WalkResult(Location)> walkFn) {
- if (walkFn(*this).wasInterrupted())
- return WalkResult::interrupt();
-
- return TypeSwitch<LocationAttr, WalkResult>(*this)
- .Case([&](CallSiteLoc callLoc) -> WalkResult {
- if (callLoc.getCallee()->walk(walkFn).wasInterrupted())
- return WalkResult::interrupt();
- return callLoc.getCaller()->walk(walkFn);
- })
- .Case([&](FusedLoc fusedLoc) -> WalkResult {
- for (Location subLoc : fusedLoc.getLocations())
- if (subLoc->walk(walkFn).wasInterrupted())
- return WalkResult::interrupt();
- return WalkResult::advance();
- })
- .Case([&](NameLoc nameLoc) -> WalkResult {
- return nameLoc.getChildLoc()->walk(walkFn);
- })
- .Case([&](OpaqueLoc opaqueLoc) -> WalkResult {
- return opaqueLoc.getFallbackLocation()->walk(walkFn);
- })
- .Default(WalkResult::advance());
+ AttrTypeWalker walker;
+ walker.addWalk([&](LocationAttr loc) { return walkFn(loc); });
----------------
bzcheeseman wrote:
Wouldn't `::skip()` skip the case where you have LocationAttr(Attr(LocationAttr))?
https://github.com/llvm/llvm-project/pull/105584
More information about the Mlir-commits
mailing list