diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -109,7 +109,7 @@ /// value-type. /// TODO(riverriddle) Remove these when all usages have been removed. Value operator*() const { return *this; } - Value *operator->() const { return (Value *)this; } + Value *operator->() const { return const_cast(this); } operator bool() const { return impl; } bool operator==(const Value &other) const { return impl == other.impl; } diff --git a/mlir/include/mlir/Pass/PassOptions.h b/mlir/include/mlir/Pass/PassOptions.h --- a/mlir/include/mlir/Pass/PassOptions.h +++ b/mlir/include/mlir/Pass/PassOptions.h @@ -176,7 +176,8 @@ /// Copy the value from the given option into this one. void copyValueFrom(const OptionBase &other) final { - (*this) = ArrayRef((ListOption &)other); + (*this) = ArrayRef( + (ListOption &)(const_cast(other))); } };