Add cast_convert_val for derived classes of IROperandOwner.

This fixes a bug where casting from a Statement to an Operation would produce an incorrect pointer.

PiperOrigin-RevId: 220479218
This commit is contained in:
River Riddle 2018-11-07 09:51:06 -08:00 committed by jpienaar
parent d7637a1d16
commit a150e0b33d
1 changed files with 12 additions and 0 deletions

View File

@ -429,6 +429,18 @@ struct cast_convert_val<mlir::Operation, mlir::IROperandOwner *,
mlir::IROperandOwner *> { mlir::IROperandOwner *> {
static mlir::Operation *doit(const mlir::IROperandOwner *value); static mlir::Operation *doit(const mlir::IROperandOwner *value);
}; };
template <typename From>
struct cast_convert_val<mlir::Operation, From *, From *> {
template <typename FromImpl,
typename std::enable_if<std::is_base_of<
mlir::IROperandOwner, FromImpl>::value>::type * = nullptr>
static mlir::Operation *doit_impl(const FromImpl *value) {
return cast_convert_val<mlir::Operation, mlir::IROperandOwner *,
mlir::IROperandOwner *>::doit(value);
}
static mlir::Operation *doit(const From *value) { return doit_impl(value); }
};
} // namespace llvm } // namespace llvm
#endif #endif