Skip to content

Commit efc561c

Browse files
[CodeGen] Remove an unnecessary cast (NFC) (llvm#146380)
E is already of Expr * and shares the same declaration among all these cases.
1 parent 529508c commit efc561c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
24402440
case CK_BlockPointerToObjCPointerCast:
24412441
case CK_AnyPointerToBlockPointerCast:
24422442
case CK_BitCast: {
2443-
Value *Src = Visit(const_cast<Expr*>(E));
2443+
Value *Src = Visit(E);
24442444
llvm::Type *SrcTy = Src->getType();
24452445
llvm::Type *DstTy = ConvertType(DestTy);
24462446

@@ -2606,11 +2606,10 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
26062606
case CK_AtomicToNonAtomic:
26072607
case CK_NonAtomicToAtomic:
26082608
case CK_UserDefinedConversion:
2609-
return Visit(const_cast<Expr*>(E));
2609+
return Visit(E);
26102610

26112611
case CK_NoOp: {
2612-
return CE->changesVolatileQualification() ? EmitLoadOfLValue(CE)
2613-
: Visit(const_cast<Expr *>(E));
2612+
return CE->changesVolatileQualification() ? EmitLoadOfLValue(CE) : Visit(E);
26142613
}
26152614

26162615
case CK_BaseToDerived: {
@@ -2712,10 +2711,10 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
27122711
case CK_LValueToRValue:
27132712
assert(CGF.getContext().hasSameUnqualifiedType(E->getType(), DestTy));
27142713
assert(E->isGLValue() && "lvalue-to-rvalue applied to r-value!");
2715-
return Visit(const_cast<Expr*>(E));
2714+
return Visit(E);
27162715

27172716
case CK_IntegralToPointer: {
2718-
Value *Src = Visit(const_cast<Expr*>(E));
2717+
Value *Src = Visit(E);
27192718

27202719
// First, convert to the correct width so that we control the kind of
27212720
// extension.
@@ -2768,7 +2767,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
27682767
case CK_HLSLAggregateSplatCast:
27692768
case CK_VectorSplat: {
27702769
llvm::Type *DstTy = ConvertType(DestTy);
2771-
Value *Elt = Visit(const_cast<Expr *>(E));
2770+
Value *Elt = Visit(E);
27722771
// Splat the element across to all elements
27732772
llvm::ElementCount NumElements =
27742773
cast<llvm::VectorType>(DstTy)->getElementCount();
@@ -2906,7 +2905,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
29062905
case CK_HLSLVectorTruncation: {
29072906
assert((DestTy->isVectorType() || DestTy->isBuiltinType()) &&
29082907
"Destination type must be a vector or builtin type.");
2909-
Value *Vec = Visit(const_cast<Expr *>(E));
2908+
Value *Vec = Visit(E);
29102909
if (auto *VecTy = DestTy->getAs<VectorType>()) {
29112910
SmallVector<int> Mask;
29122911
unsigned NumElts = VecTy->getNumElements();

0 commit comments

Comments
 (0)