[llvm] 78aa260 - [NFC] Fix unused result of dyn_cast<VectorType> in non-assert build
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 27 21:21:28 PDT 2020
Might as well roll the if check into the assert at that point?
(assert(!isa<T>(...) || (cast<T>(x) == blah)... etc)
On Wed, Apr 22, 2020 at 6:58 AM Sander de Smalen via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
>
> Author: Sander de Smalen
> Date: 2020-04-22T14:57:28+01:00
> New Revision: 78aa260df742bc1fbe252bffdb7a1da0613ef116
>
> URL:
> https://github.com/llvm/llvm-project/commit/78aa260df742bc1fbe252bffdb7a1da0613ef116
> DIFF:
> https://github.com/llvm/llvm-project/commit/78aa260df742bc1fbe252bffdb7a1da0613ef116.diff
>
> LOG: [NFC] Fix unused result of dyn_cast<VectorType> in non-assert build
>
> Added:
>
>
> Modified:
> llvm/lib/IR/Constants.cpp
>
> Removed:
>
>
>
>
> ################################################################################
> diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
> index 338029fa00de..b86b747f7519 100644
> --- a/llvm/lib/IR/Constants.cpp
> +++ b/llvm/lib/IR/Constants.cpp
> @@ -1895,8 +1895,8 @@ Constant *ConstantExpr::getPtrToInt(Constant *C,
> Type *DstTy,
> assert(DstTy->isIntOrIntVectorTy() &&
> "PtrToInt destination must be integer or integer vector");
> assert(isa<VectorType>(C->getType()) == isa<VectorType>(DstTy));
> - if (auto *CVTy = dyn_cast<VectorType>(C->getType()))
> - assert(CVTy->getNumElements() ==
> + if (isa<VectorType>(C->getType()))
> + assert(cast<VectorType>(C->getType())->getNumElements() ==
> cast<VectorType>(DstTy)->getNumElements() &&
> "Invalid cast between a
> diff erent number of vector elements");
> return getFoldedCast(Instruction::PtrToInt, C, DstTy, OnlyIfReduced);
> @@ -1909,8 +1909,8 @@ Constant *ConstantExpr::getIntToPtr(Constant *C,
> Type *DstTy,
> assert(DstTy->isPtrOrPtrVectorTy() &&
> "IntToPtr destination must be a pointer or pointer vector");
> assert(isa<VectorType>(C->getType()) == isa<VectorType>(DstTy));
> - if (auto *CVTy = dyn_cast<VectorType>(C->getType()))
> - assert(CVTy->getNumElements() ==
> + if (isa<VectorType>(C->getType()))
> + assert(cast<VectorType>(C->getType())->getNumElements() ==
> cast<VectorType>(DstTy)->getNumElements() &&
> "Invalid cast between a
> diff erent number of vector elements");
> return getFoldedCast(Instruction::IntToPtr, C, DstTy, OnlyIfReduced);
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200427/53a93cd6/attachment-0001.html>
More information about the llvm-commits
mailing list