[llvm] 2e66405 - Don't use dyn_cast_or_null if we know the pointer is nonnull.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 10 02:37:27 PST 2020
Author: Simon Pilgrim
Date: 2020-01-10T10:32:36Z
New Revision: 2e66405d8d8ed818cb9310b6c33419bd8d803d96
URL: https://github.com/llvm/llvm-project/commit/2e66405d8d8ed818cb9310b6c33419bd8d803d96
DIFF: https://github.com/llvm/llvm-project/commit/2e66405d8d8ed818cb9310b6c33419bd8d803d96.diff
LOG: 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.
Added:
Modified:
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index e5f7968d9326..80acab307578 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -1128,8 +1128,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
OriginAlignment);
} else {
Value *ConvertedShadow = convertToShadowTyNoVec(Shadow, IRB);
- Constant *ConstantShadow = dyn_cast_or_null<Constant>(ConvertedShadow);
- if (ConstantShadow) {
+ if (auto *ConstantShadow = dyn_cast<Constant>(ConvertedShadow)) {
if (ClCheckConstantShadow && !ConstantShadow->isZeroValue())
paintOrigin(IRB, updateOrigin(Origin, IRB), OriginPtr, StoreSize,
OriginAlignment);
@@ -1210,8 +1209,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
Value *ConvertedShadow = convertToShadowTyNoVec(Shadow, IRB);
LLVM_DEBUG(dbgs() << " SHAD1 : " << *ConvertedShadow << "\n");
- Constant *ConstantShadow = dyn_cast_or_null<Constant>(ConvertedShadow);
- if (ConstantShadow) {
+ if (auto *ConstantShadow = dyn_cast<Constant>(ConvertedShadow)) {
if (ClCheckConstantShadow && !ConstantShadow->isZeroValue()) {
insertWarningFn(IRB, Origin);
}
More information about the llvm-commits
mailing list