diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2020-01-15 11:49:21 +0000 |
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2020-01-15 12:18:11 +0000 |
| commit | 7b15865225103389150153d12904041fcc57fd0e (patch) | |
| tree | 2a45ca87018c1a103b6ee34e2f24791be0adb92b | |
| parent | 7570d387c21935b58afa67cb9ee17250e38721fa (diff) | |
| download | llvm-7b15865225103389150153d12904041fcc57fd0e.tar.gz | |
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.
| -rw-r--r-- | llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
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); |
