summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/IR/Type.h3
-rw-r--r--llvm/lib/IR/Type.cpp12
2 files changed, 4 insertions, 11 deletions
diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h
index e24ba0f0971..bbee3f93741 100644
--- a/llvm/include/llvm/IR/Type.h
+++ b/llvm/include/llvm/IR/Type.h
@@ -304,8 +304,7 @@ public:
/// getScalarType - If this is a vector type, return the element type,
/// otherwise return 'this'.
- const Type *getScalarType() const LLVM_READONLY;
- Type *getScalarType() LLVM_READONLY;
+ Type *getScalarType() const LLVM_READONLY;
//===--------------------------------------------------------------------===//
// Type Iteration support.
diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp
index ad0013aed39..17d24465601 100644
--- a/llvm/lib/IR/Type.cpp
+++ b/llvm/lib/IR/Type.cpp
@@ -42,16 +42,10 @@ Type *Type::getPrimitiveType(LLVMContext &C, TypeID IDNumber) {
/// getScalarType - If this is a vector type, return the element type,
/// otherwise return this.
-Type *Type::getScalarType() {
- if (VectorType *VTy = dyn_cast<VectorType>(this))
- return VTy->getElementType();
- return this;
-}
-
-const Type *Type::getScalarType() const {
- if (const VectorType *VTy = dyn_cast<VectorType>(this))
+Type *Type::getScalarType() const {
+ if (auto *VTy = dyn_cast<VectorType>(this))
return VTy->getElementType();
- return this;
+ return const_cast<Type*>(this);
}
/// isIntegerTy - Return true if this is an IntegerType of the specified width.
OpenPOWER on IntegriCloud