Skip to content

Commit 7b15865

Browse files
committed
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.
1 parent 7570d38 commit 7b15865

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

llvm/lib/Target/NVPTX/NVPTXLowerAlloca.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ bool NVPTXLowerAlloca::runOnFunction(Function &F) {
7070
for (auto &I : BB) {
7171
if (auto allocaInst = dyn_cast<AllocaInst>(&I)) {
7272
Changed = true;
73-
auto PTy = dyn_cast<PointerType>(allocaInst->getType());
74-
auto ETy = PTy->getElementType();
73+
auto ETy = cast<PointerType>(allocaInst->getType())->getElementType();
7574
auto LocalAddrTy = PointerType::get(ETy, ADDRESS_SPACE_LOCAL);
7675
auto NewASCToLocal = new AddrSpaceCastInst(allocaInst, LocalAddrTy, "");
7776
auto GenericAddrTy = PointerType::get(ETy, ADDRESS_SPACE_GENERIC);

0 commit comments

Comments
 (0)