From: Simon Pilgrim Date: Thu, 9 Jan 2020 14:18:58 +0000 (+0000) Subject: Don't use dyn_cast_or_null if we know the pointer is nonnull. X-Git-Tag: llvmorg-11-init~462 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e66405d8d8ed818cb9310b6c33419bd8d803d96;p=platform%2Fupstream%2Fllvm.git Don't use dyn_cast_or_null if we know the pointer is nonnull. Fix clang static analyzer null dereference warning by using dyn_cast instead. --- diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index e5f7968..80acab3 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -1128,8 +1128,7 @@ struct MemorySanitizerVisitor : public InstVisitor { OriginAlignment); } else { Value *ConvertedShadow = convertToShadowTyNoVec(Shadow, IRB); - Constant *ConstantShadow = dyn_cast_or_null(ConvertedShadow); - if (ConstantShadow) { + if (auto *ConstantShadow = dyn_cast(ConvertedShadow)) { if (ClCheckConstantShadow && !ConstantShadow->isZeroValue()) paintOrigin(IRB, updateOrigin(Origin, IRB), OriginPtr, StoreSize, OriginAlignment); @@ -1210,8 +1209,7 @@ struct MemorySanitizerVisitor : public InstVisitor { Value *ConvertedShadow = convertToShadowTyNoVec(Shadow, IRB); LLVM_DEBUG(dbgs() << " SHAD1 : " << *ConvertedShadow << "\n"); - Constant *ConstantShadow = dyn_cast_or_null(ConvertedShadow); - if (ConstantShadow) { + if (auto *ConstantShadow = dyn_cast(ConvertedShadow)) { if (ClCheckConstantShadow && !ConstantShadow->isZeroValue()) { insertWarningFn(IRB, Origin); }