From: Simon Pilgrim Date: Wed, 15 Jan 2020 11:49:21 +0000 (+0000) Subject: Fix "pointer is null" static analyzer warning. NFCI. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7b15865225103389150153d12904041fcc57fd0e;p=platform%2Fupstream%2Fllvm.git Fix "pointer is null" static analyzer warning. NFCI. Use cast<> instead of dyn_cast<> since the pointer is always dereferenced and cast<> will perform the null assertion for us. --- diff --git a/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp b/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp index 945b728..cf488b0 100644 --- a/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp @@ -70,8 +70,7 @@ bool NVPTXLowerAlloca::runOnFunction(Function &F) { for (auto &I : BB) { if (auto allocaInst = dyn_cast(&I)) { Changed = true; - auto PTy = dyn_cast(allocaInst->getType()); - auto ETy = PTy->getElementType(); + auto ETy = cast(allocaInst->getType())->getElementType(); auto LocalAddrTy = PointerType::get(ETy, ADDRESS_SPACE_LOCAL); auto NewASCToLocal = new AddrSpaceCastInst(allocaInst, LocalAddrTy, ""); auto GenericAddrTy = PointerType::get(ETy, ADDRESS_SPACE_GENERIC);