[Mlir-commits] [mlir] c2a8a10 - [MLIR][NFC] Remove unnecessary cast.
Sergei Grechanik
llvmlistbot at llvm.org
Mon Apr 4 10:01:02 PDT 2022
Author: antonio-cortes-perez
Date: 2022-04-04T09:46:24-07:00
New Revision: c2a8a104ec320c8bed39c3632eae2fb37f53487b
URL: https://github.com/llvm/llvm-project/commit/c2a8a104ec320c8bed39c3632eae2fb37f53487b
DIFF: https://github.com/llvm/llvm-project/commit/c2a8a104ec320c8bed39c3632eae2fb37f53487b.diff
LOG: [MLIR][NFC] Remove unnecessary cast.
I was reading this post:
https://www.fluentcpp.com/2017/05/19/crtp-helper/
And I noticed that most likely this cast is not needed.
Unless it is needed by some compiler versions.
I tested it with:
cmake --build . --target check-mlir
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D121555
Added:
Modified:
mlir/include/mlir/IR/OpDefinition.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index cc9431553ddf2..48bdec9483f84 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -322,14 +322,8 @@ class TraitBase {
protected:
/// Return the ultimate Operation being worked on.
Operation *getOperation() {
- // We have to cast up to the trait type, then to the concrete type, then to
- // the BaseState class in explicit hops because the concrete type will
- // multiply derive from the (content free) TraitBase class, and we need to
- // be able to disambiguate the path for the C++ compiler.
- auto *trait = static_cast<TraitType<ConcreteType> *>(this);
- auto *concrete = static_cast<ConcreteType *>(trait);
- auto *base = static_cast<OpState *>(concrete);
- return base->getOperation();
+ auto *concrete = static_cast<ConcreteType *>(this);
+ return concrete->getOperation();
}
};
More information about the Mlir-commits
mailing list