From: Simon Pilgrim Date: Fri, 20 Sep 2019 20:52:21 +0000 (+0000) Subject: [AddressSanitizer] Don't dereference dyn_cast results. NFCI. X-Git-Tag: llvmorg-11-init~8725 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e0c95edfe0fbbded0835c3e5ec341c9a28b30e6;p=platform%2Fupstream%2Fllvm.git [AddressSanitizer] Don't dereference dyn_cast results. NFCI. The static analyzer is warning about potential null dereference, but we can use cast directly and if not assert will fire for us. llvm-svn: 372429 --- diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 21280f2..b58a943 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1048,7 +1048,7 @@ struct FunctionStackPoisoner : public InstVisitor { if (!II.isLifetimeStartOrEnd()) return; // Found lifetime intrinsic, add ASan instrumentation if necessary. - ConstantInt *Size = dyn_cast(II.getArgOperand(0)); + auto *Size = cast(II.getArgOperand(0)); // If size argument is undefined, don't do anything. if (Size->isMinusOne()) return; // Check that size doesn't saturate uint64_t and can @@ -1790,7 +1790,7 @@ void ModuleAddressSanitizer::createInitializerPoisonCalls( // Must have a function or null ptr. if (Function *F = dyn_cast(CS->getOperand(1))) { if (F->getName() == kAsanModuleCtorName) continue; - ConstantInt *Priority = dyn_cast(CS->getOperand(0)); + auto *Priority = cast(CS->getOperand(0)); // Don't instrument CTORs that will run before asan.module_ctor. if (Priority->getLimitedValue() <= GetCtorAndDtorPriority(TargetTriple)) continue;