Merge the const and non-const Type::getScalarType to a const version that returns...
authorCraig Topper <craig.topper@gmail.com>
Sat, 1 Aug 2015 22:20:27 +0000 (22:20 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sat, 1 Aug 2015 22:20:27 +0000 (22:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243843 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Type.h
lib/IR/Type.cpp

index e24ba0f0971fab4d76ffeefe738aeb243fb01ddd..bbee3f93741ece1bc95548812d41c717d11372c4 100644 (file)
@@ -304,8 +304,7 @@ public:
 
   /// getScalarType - If this is a vector type, return the element type,
   /// otherwise return 'this'.
 
   /// 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.
 
   //===--------------------------------------------------------------------===//
   // Type Iteration support.
index ad0013aed397791a42d1d6b0b3bb0c7ef48ddab5..17d24465601f27e9acb4e4a800355669ee7f78ce 100644 (file)
@@ -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.
 
 /// 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 VTy->getElementType();
-  return this;
+  return const_cast<Type*>(this);
 }
 
 /// isIntegerTy - Return true if this is an IntegerType of the specified width.
 }
 
 /// isIntegerTy - Return true if this is an IntegerType of the specified width.