[llvm] r372743 - ConstantFold - silence static analyzer dyn_cast<> null dereference warning. NFCI.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 30 13:35:15 PDT 2019


Any test coverage for this codepath?

On Tue, Sep 24, 2019 at 5:28 AM Simon Pilgrim via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: rksimon
> Date: Tue Sep 24 05:30:13 2019
> New Revision: 372743
>
> URL: http://llvm.org/viewvc/llvm-project?rev=372743&view=rev
> Log:
> ConstantFold - silence static analyzer dyn_cast<> null dereference
> warning. NFCI.
>
> Early out if the vector element is not Constant.
>
> Modified:
>     llvm/trunk/lib/IR/ConstantFold.cpp
>
> Modified: llvm/trunk/lib/IR/ConstantFold.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ConstantFold.cpp?rev=372743&r1=372742&r2=372743&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/ConstantFold.cpp (original)
> +++ llvm/trunk/lib/IR/ConstantFold.cpp Tue Sep 24 05:30:13 2019
> @@ -747,6 +747,7 @@ Constant *llvm::ConstantFoldSelectInstru
>        Constant *V2Element = ConstantExpr::getExtractElement(V2,
>                                                      ConstantInt::get(Ty,
> i));
>        Constant *Cond = dyn_cast<Constant>(CondV->getOperand(i));
> +      if (!Cond) break;
>        if (V1Element == V2Element) {
>          V = V1Element;
>        } else if (isa<UndefValue>(Cond)) {
>
>
> _______________________________________________
> 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/20190930/bf46fc2d/attachment.html>


More information about the llvm-commits mailing list