[clang] 8a40f89 - [clang][analyzer][NFC] Replace dyn_cast with cast in MemRegion::getMemorySpace
Dmitri Gribenko via cfe-commits
cfe-commits at lists.llvm.org
Tue May 30 09:30:38 PDT 2023
Author: Dmitri Gribenko
Date: 2023-05-30T18:30:30+02:00
New Revision: 8a40f89e2e9357539db0f9a119db0fcfc77232ab
URL: https://github.com/llvm/llvm-project/commit/8a40f89e2e9357539db0f9a119db0fcfc77232ab
DIFF: https://github.com/llvm/llvm-project/commit/8a40f89e2e9357539db0f9a119db0fcfc77232ab.diff
LOG: [clang][analyzer][NFC] Replace dyn_cast with cast in MemRegion::getMemorySpace
MemRegion::getMemorySpace() is annotated with
LLVM_ATTRIBUTE_RETURNS_NONNULL (which triggers instant UB if a null
pointer is returned), and callers indeed don't check the return value
for null. Thus, even though llvm::dyn_cast is called, it can never
return null in this context. Therefore, we can safely call llvm::cast.
Reviewed By: steakhal
Differential Revision: https://reviews.llvm.org/D151727
Added:
Modified:
clang/lib/StaticAnalyzer/Core/MemRegion.cpp
Removed:
################################################################################
diff --git a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
index bb45a879471a..d7409ae6aebe 100644
--- a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -1279,7 +1279,7 @@ const MemSpaceRegion *MemRegion::getMemorySpace() const {
SR = dyn_cast<SubRegion>(R);
}
- return dyn_cast<MemSpaceRegion>(R);
+ return cast<MemSpaceRegion>(R);
}
bool MemRegion::hasStackStorage() const {
More information about the cfe-commits
mailing list