1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[mlir] Add support for walking locations similarly to Operations

This allows for walking all nested locations of a given location, and is generally useful when processing locations.

Differential Revision: https://reviews.llvm.org/D100437
This commit is contained in:
River Riddle 2021-04-15 16:09:08 -07:00
parent 87c0b7c256
commit 13a7aadf73
2 changed files with 7 additions and 1 deletions

View File

@ -124,6 +124,12 @@ public:
return std::move(*result);
return defaultFn(this->value);
}
/// As a default, return the given value.
LLVM_NODISCARD ResultT Default(ResultT defaultResult) {
if (result)
return std::move(*result);
return defaultResult;
}
LLVM_NODISCARD
operator ResultT() {

View File

@ -47,7 +47,7 @@ TEST(TypeSwitchTest, CasesResult) {
return TypeSwitch<Base *, int>(&value)
.Case<DerivedA, DerivedB, DerivedD>([](auto *) { return 0; })
.Case([](DerivedC *) { return 1; })
.Default([](Base *) { return -1; });
.Default(-1);
};
EXPECT_EQ(0, translate(DerivedA()));
EXPECT_EQ(0, translate(DerivedB()));