[llvm] 7b15865 - Fix "pointer is null" static analyzer warning. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 04:18:37 PST 2020
Author: Simon Pilgrim
Date: 2020-01-15T12:18:11Z
New Revision: 7b15865225103389150153d12904041fcc57fd0e
URL: https://github.com/llvm/llvm-project/commit/7b15865225103389150153d12904041fcc57fd0e
DIFF: https://github.com/llvm/llvm-project/commit/7b15865225103389150153d12904041fcc57fd0e.diff
LOG: 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.
Added:
Modified:
llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp b/llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp
index 945b7286b03c..cf488b06f06c 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<AllocaInst>(&I)) {
Changed = true;
- auto PTy = dyn_cast<PointerType>(allocaInst->getType());
- auto ETy = PTy->getElementType();
+ auto ETy = cast<PointerType>(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);
More information about the llvm-commits
mailing list