Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RKSimon committed Jan 15, 2020
1 parent 7570d38 commit 7b15865
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 7b15865

Please sign in to comment.