Skip to content

Commit 2a2bb1c

Browse files
committed
Remove the need for one const_cast
1 parent dd30c6e commit 2a2bb1c

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

llvm/include/llvm/IR/DerivedTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class StructType : public Type {
290290
bool isSized(SmallPtrSetImpl<Type *> *Visited = nullptr) const;
291291

292292
/// Returns true if this struct contains a scalable vector.
293-
bool isScalableTy(SmallPtrSetImpl<Type *> &Visited) const;
293+
bool isScalableTy(SmallPtrSetImpl<const Type *> &Visited) const;
294294
using Type::isScalableTy;
295295

296296
/// Returns true if this struct contains homogeneous scalable vector types.

llvm/include/llvm/IR/Type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class Type {
206206
bool isScalableTargetExtTy() const;
207207

208208
/// Return true if this is a type whose size is a known multiple of vscale.
209-
bool isScalableTy(SmallPtrSetImpl<Type *> &Visited) const;
209+
bool isScalableTy(SmallPtrSetImpl<const Type *> &Visited) const;
210210
bool isScalableTy() const;
211211

212212
/// Return true if this is a FP type or a vector of FP.

llvm/lib/IR/Type.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool Type::isIntegerTy(unsigned Bitwidth) const {
5858
return isIntegerTy() && cast<IntegerType>(this)->getBitWidth() == Bitwidth;
5959
}
6060

61-
bool Type::isScalableTy(SmallPtrSetImpl<Type *> &Visited) const {
61+
bool Type::isScalableTy(SmallPtrSetImpl<const Type *> &Visited) const {
6262
if (const auto *ATy = dyn_cast<ArrayType>(this))
6363
return ATy->getElementType()->isScalableTy(Visited);
6464
if (const auto *STy = dyn_cast<StructType>(this))
@@ -67,7 +67,7 @@ bool Type::isScalableTy(SmallPtrSetImpl<Type *> &Visited) const {
6767
}
6868

6969
bool Type::isScalableTy() const {
70-
SmallPtrSet<Type *, 4> Visited;
70+
SmallPtrSet<const Type *, 4> Visited;
7171
return isScalableTy(Visited);
7272
}
7373

@@ -397,14 +397,14 @@ StructType *StructType::get(LLVMContext &Context, ArrayRef<Type*> ETypes,
397397
return ST;
398398
}
399399

400-
bool StructType::isScalableTy(SmallPtrSetImpl<Type *> &Visited) const {
400+
bool StructType::isScalableTy(SmallPtrSetImpl<const Type *> &Visited) const {
401401
if ((getSubclassData() & SCDB_ContainsScalableVector) != 0)
402402
return true;
403403

404404
if ((getSubclassData() & SCDB_NotContainsScalableVector) != 0)
405405
return false;
406406

407-
if (!Visited.insert(const_cast<StructType *>(this)).second)
407+
if (!Visited.insert(this).second)
408408
return false;
409409

410410
for (Type *Ty : elements()) {

0 commit comments

Comments
 (0)