From 7b15865225103389150153d12904041fcc57fd0e Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Wed, 15 Jan 2020 11:49:21 +0000 Subject: [PATCH] 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. --- llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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); -- 2.7.4