Skip to content

Commit

Permalink
[NFC] Fix compiler warnings from TypeSwitch on AffineExpr (iree-org#1…
Browse files Browse the repository at this point in the history
…6306)

TypeSwitch on AffineExpr causes it to use dyn_cast directly on
AffineExpr, which is supported, but depreciated, making the compiler
spit out errors. This removes the usage of TypeSwitch on AffineExpr and
instead uses if conditions.

Fixes iree-org#16014
  • Loading branch information
Groverkss authored Feb 5, 2024
1 parent b268832 commit 7722916
Showing 1 changed file with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,20 +317,19 @@ static bool isIdentityMapWithZeros(AffineMap map) {
if (map.isEmpty())
return false;
unsigned dimsSeen = 0;
for (auto result : map.getResults()) {
bool isValidExpr = TypeSwitch<AffineExpr, bool>(result)
.Case<AffineDimExpr>([&dimsSeen](auto dimExpr) {
if (dimExpr.getPosition() != dimsSeen)
return false;
dimsSeen++;
return true;
})
.Case<AffineConstantExpr>([](auto constExpr) {
return constExpr.getValue() == 0;
})
.Default([](AffineExpr) { return false; });
if (!isValidExpr)
for (AffineExpr result : map.getResults()) {
if (auto dimExpr = dyn_cast<AffineDimExpr>(result)) {
if (dimExpr.getPosition() != dimsSeen) {
return false;
}
dimsSeen++;
} else if (auto constExpr = dyn_cast<AffineConstantExpr>(result)) {
if (constExpr.getValue() != 0) {
return false;
}
} else {
return false;
}
}
return dimsSeen == map.getNumDims();
}
Expand Down

0 comments on commit 7722916

Please sign in to comment.