mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-21 18:22:53 +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:
parent
87c0b7c256
commit
13a7aadf73
@ -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() {
|
||||
|
@ -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()));
|
||||
|
Loading…
Reference in New Issue
Block a user